1
0
Fork 0
mirror of https://github.com/archtechx/tenancy.git synced 2025-12-12 12:44:02 +00:00

[4.x] Add tenant schema dump command (#807)

* Add tenant dump command

* Register tenant schema dump command

* Added tests for tenant schema dump command

* remove docblocks, fix tenant() logic

* trigger ci

* Install mysql-client

* mysql-client -> mariadb-client

* add tenant-schema-test.dump to .gitignore

Co-authored-by: Samuel Štancl <samuel@archte.ch>
Co-authored-by: Samuel Štancl <samuel.stancl@gmail.com>
This commit is contained in:
Victor R 2022-06-01 10:12:59 -04:00 committed by GitHub
parent d0de09aa53
commit 7d98ebb5d1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 155 additions and 1 deletions

View file

@ -91,6 +91,38 @@ class CommandsTest extends TestCase
$this->assertTrue(Schema::hasTable('users'));
}
/** @test */
public function migrate_command_loads_schema_state()
{
$tenant = Tenant::create();
$this->assertFalse(Schema::hasTable('schema_users'));
$this->assertFalse(Schema::hasTable('users'));
Artisan::call('tenants:migrate --schema-path="tests/Etc/tenant-schema.dump"');
$this->assertFalse(Schema::hasTable('schema_users'));
$this->assertFalse(Schema::hasTable('users'));
tenancy()->initialize($tenant);
// Check for both tables to see if missing migrations also get executed
$this->assertTrue(Schema::hasTable('schema_users'));
$this->assertTrue(Schema::hasTable('users'));
}
/** @test */
public function dump_command_works()
{
$tenant = Tenant::create();
Artisan::call('tenants:migrate');
tenancy()->initialize($tenant);
Artisan::call('tenants:dump --path="tests/Etc/tenant-schema-test.dump"');
$this->assertFileExists('tests/Etc/tenant-schema-test.dump');
}
/** @test */
public function rollback_command_works()
{