envive/tenant-migrate

laravel migrate command tool for multi-tenant pattern

1.0.2 2018-10-30 11:37 UTC

This package is not auto-updated.

Last update: 2025-07-06 09:20:52 UTC


README

Add multi-tenant support for Laravel migrate command

Installation

composer require envive/tenant-migrate

Automatic service registration

Using auto discovery, the tenancy package will be auto detected by Laravel automatically.

Manual service registration

In case you want to disable webserver integration or prefer manual integration, set the dont-discover in your application composer.json, like so:

{
    "extra": {
        "laravel": {
            "dont-discover": "envive/tenant-migrate"
        }
    }
}

If you disable auto discovery you are able to configure the providers by yourself.

Register the service provider in your config/app.php:

    'providers' => [
        // [..]
        // Tenant migrate.
         Envive\TenantMigrate\TenantMigrateServiceProvider::class,
    ],

Deploy configuration

Publish the configuration file so you can modify it to your needs:

 php artisan vendor:publish --provider=Envive\\TenantMigrate\\TenantMigrateServiceProvider

Open the config/tenant.php file and modify to your needs. Put your tenant database connection information into the connection and add tenant_prefix if needed.

This package will add seven commands below into your artisan list. You can get more information with option help.

  tenant:migrate           Run the database migrations with multi-tenant support
  tenant:migrate:fresh     Drop all tables and re-run all migrations with multi-tenant support
  tenant:migrate:install   Create the migration repository with multi-tenant support
  tenant:migrate:refresh   Reset and re-run all migrations with multi-tenant support
  tenant:migrate:reset     Rollback all database migrations with multi-tenant support
  tenant:migrate:rollback  Rollback the last database migration with multi-tenant support
  tenant:migrate:status    Show the status of each migration with multi-tenant support