/
WebsiteSupport

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

  1. Put migrations in database/migrations/. They are loaded for every installed add-on (app/Providers/AddonServiceProvider.php:118-125).
  2. Start every file name with <Y>_<m>_<d>_<time>_<slug>_, for example 2027_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).
  3. Write down(). Uninstall drops the add-on's tables and records (app/Console/Commands/AddonAppCommand.php:43-46).
  4. Put a company_id on business records and read only the user's active companies: CompanyContext::activeIds() (app/Support/CompanyContext.php:283). New records go to CompanyContext::defaultCompanyId(), which is activeIds()[0] (:456-460).

See also