@@ 7-38 (lines=32) @@ | ||
4 | use Illuminate\Database\Schema\Blueprint; |
|
5 | use Illuminate\Database\Migrations\Migration; |
|
6 | ||
7 | class CreateFeatureTenantTable extends Migration |
|
8 | { |
|
9 | /** |
|
10 | * Run the migrations. |
|
11 | * |
|
12 | * @return void |
|
13 | */ |
|
14 | public function up() |
|
15 | { |
|
16 | $tenant_singular = str_singular(config('multi-tenant.table_name')); |
|
17 | ||
18 | Schema::create('feature_' . $tenant_singular, function (Blueprint $table) use ($tenant_singular) { |
|
19 | $table->increments('id'); |
|
20 | $table->integer('feature_id')->unsigned(); |
|
21 | $table->integer($tenant_singular . '_id')->unsigned(); |
|
22 | $table->timestamps(); |
|
23 | ||
24 | $table->index('feature_id', 'feature_' . $tenant_singular . '_feature_id_index'); |
|
25 | $table->index($tenant_singular . '_id', 'feature_' . $tenant_singular . '_' . $tenant_singular . '_id_index'); |
|
26 | }); |
|
27 | } |
|
28 | ||
29 | /** |
|
30 | * Reverse the migrations. |
|
31 | * |
|
32 | * @return void |
|
33 | */ |
|
34 | public function down() |
|
35 | { |
|
36 | Schema::dropIfExists('feature_' . str_singular(config('multi-tenant.table_name'))); |
|
37 | } |
|
38 | } |
|
39 |
@@ 7-38 (lines=32) @@ | ||
4 | use Illuminate\Database\Schema\Blueprint; |
|
5 | use Illuminate\Database\Migrations\Migration; |
|
6 | ||
7 | class CreateTenantUserTable extends Migration |
|
8 | { |
|
9 | /** |
|
10 | * Run the migrations. |
|
11 | * |
|
12 | * @return void |
|
13 | */ |
|
14 | public function up() |
|
15 | { |
|
16 | $tenant_singular = str_singular(config('multi-tenant.table_name')); |
|
17 | ||
18 | Schema::create($tenant_singular . '_user', function (Blueprint $table) use ($tenant_singular) { |
|
19 | $table->increments('id'); |
|
20 | $table->integer($tenant_singular . '_id')->unsigned(); |
|
21 | $table->integer('user_id')->unsigned(); |
|
22 | $table->timestamps(); |
|
23 | ||
24 | $table->index($tenant_singular . '_id', $tenant_singular . '_user_' . $tenant_singular . '_id_index'); |
|
25 | $table->index('user_id', $tenant_singular . '_user_user_id_index'); |
|
26 | }); |
|
27 | } |
|
28 | ||
29 | /** |
|
30 | * Reverse the migrations. |
|
31 | * |
|
32 | * @return void |
|
33 | */ |
|
34 | public function down() |
|
35 | { |
|
36 | Schema::dropIfExists(str_singular(config('multi-tenant.table_name')) . '_user'); |
|
37 | } |
|
38 | } |
|
39 |