DocsDeveloper guideBuild an add-on
Tables and models
Your add-on owns its tables: its migrations run with core's migrate, and an uninstall rolls back exactly those.
1 min read
- Put migrations in
database/migrations/. They are loaded for every installed add-on (app/Providers/AddonServiceProvider.php:118-125). - Start every file name with
<Y>_<m>_<d>_<time>_<slug>_, for example2027_04_01_000100_hello_create_notes.php. That prefix is how the system tells your migrations from core's (app/Support/Addons/BundledAddons.php:103-112). Laravel records migrations by file name, so they never run twice (app/Providers/AddonServiceProvider.php:118-121). - Write
down(). Uninstall drops the add-on's tables and records (app/Console/Commands/AddonAppCommand.php:43-46). - Put a
company_idon business records and read only the user's active companies:CompanyContext::activeIds()(app/Support/CompanyContext.php:283). New records go toCompanyContext::defaultCompanyId(), which isactiveIds()[0](:456-460).