| @@ 7-50 (lines=44) @@ | ||
| 4 | use Illuminate\Database\Schema\Blueprint; |
|
| 5 | use Illuminate\Support\Facades\Schema; |
|
| 6 | ||
| 7 | class CreateFightersGroupCompetitorTable extends Migration |
|
| 8 | { |
|
| 9 | /** |
|
| 10 | * Run the migrations. |
|
| 11 | * |
|
| 12 | * @return void |
|
| 13 | */ |
|
| 14 | public function up() |
|
| 15 | { |
|
| 16 | Schema::create('fighters_group_competitor', function (Blueprint $table) { |
|
| 17 | $table->increments('id'); |
|
| 18 | $table->integer('competitor_id')->unsigned()->nullable()->index(); |
|
| 19 | $table->integer('fighters_group_id')->unsigned()->index(); |
|
| 20 | $table->integer('order')->unsigned()->nullable(); |
|
| 21 | $table->timestamps(); |
|
| 22 | ||
| 23 | $table->foreign('competitor_id') |
|
| 24 | ->references('id') |
|
| 25 | ->on('competitor') |
|
| 26 | ->onUpdate('cascade') |
|
| 27 | ->onDelete('cascade'); |
|
| 28 | ||
| 29 | $table->foreign('fighters_group_id') |
|
| 30 | ->references('id') |
|
| 31 | ->on('fighters_groups') |
|
| 32 | ->onUpdate('cascade') |
|
| 33 | ->onDelete('cascade'); |
|
| 34 | ||
| 35 | $table->unique(['competitor_id', 'fighters_group_id']); |
|
| 36 | }); |
|
| 37 | } |
|
| 38 | ||
| 39 | /** |
|
| 40 | * Reverse the migrations. |
|
| 41 | * |
|
| 42 | * @return void |
|
| 43 | */ |
|
| 44 | public function down() |
|
| 45 | { |
|
| 46 | DB::statement('SET FOREIGN_KEY_CHECKS = 0'); |
|
| 47 | Schema::dropIfExists('fighters_group_competitor'); |
|
| 48 | DB::statement('SET FOREIGN_KEY_CHECKS = 1'); |
|
| 49 | } |
|
| 50 | } |
|
| 51 | ||
| @@ 7-50 (lines=44) @@ | ||
| 4 | use Illuminate\Database\Schema\Blueprint; |
|
| 5 | use Illuminate\Support\Facades\Schema; |
|
| 6 | ||
| 7 | class CreateFightersGroupTeamTable extends Migration |
|
| 8 | { |
|
| 9 | /** |
|
| 10 | * Run the migrations. |
|
| 11 | * |
|
| 12 | * @return void |
|
| 13 | */ |
|
| 14 | public function up() |
|
| 15 | { |
|
| 16 | Schema::create('fighters_group_team', function (Blueprint $table) { |
|
| 17 | $table->increments('id'); |
|
| 18 | $table->integer('team_id')->unsigned()->nullable()->index(); |
|
| 19 | $table->integer('fighters_group_id')->unsigned()->index(); |
|
| 20 | $table->integer('order')->unsigned()->nullable(); |
|
| 21 | $table->timestamps(); |
|
| 22 | ||
| 23 | $table->foreign('team_id') |
|
| 24 | ->references('id') |
|
| 25 | ->on('team') |
|
| 26 | ->onUpdate('cascade') |
|
| 27 | ->onDelete('cascade'); |
|
| 28 | ||
| 29 | $table->foreign('fighters_group_id') |
|
| 30 | ->references('id') |
|
| 31 | ->on('fighters_groups') |
|
| 32 | ->onUpdate('cascade') |
|
| 33 | ->onDelete('cascade'); |
|
| 34 | ||
| 35 | $table->unique(['team_id', 'fighters_group_id']); |
|
| 36 | }); |
|
| 37 | } |
|
| 38 | ||
| 39 | /** |
|
| 40 | * Reverse the migrations. |
|
| 41 | * |
|
| 42 | * @return void |
|
| 43 | */ |
|
| 44 | public function down() |
|
| 45 | { |
|
| 46 | DB::statement('SET FOREIGN_KEY_CHECKS = 0'); |
|
| 47 | Schema::dropIfExists('fighters_group_team'); |
|
| 48 | DB::statement('SET FOREIGN_KEY_CHECKS = 1'); |
|
| 49 | } |
|
| 50 | } |
|
| 51 | ||
| @@ 7-50 (lines=44) @@ | ||
| 4 | use Illuminate\Database\Schema\Blueprint; |
|
| 5 | use Illuminate\Support\Facades\Schema; |
|
| 6 | ||
| 7 | class CreateCompetitorTeamTable extends Migration |
|
| 8 | { |
|
| 9 | /** |
|
| 10 | * Run the migrations. |
|
| 11 | * |
|
| 12 | * @return void |
|
| 13 | */ |
|
| 14 | public function up() |
|
| 15 | { |
|
| 16 | Schema::create('competitor_team', function (Blueprint $table) { |
|
| 17 | $table->increments('id'); |
|
| 18 | $table->integer('team_id')->unsigned()->nullable()->index(); |
|
| 19 | $table->integer('competitor_id')->unsigned()->index(); |
|
| 20 | $table->integer('order')->unsigned()->nullable(); |
|
| 21 | $table->timestamps(); |
|
| 22 | ||
| 23 | $table->foreign('team_id') |
|
| 24 | ->references('id') |
|
| 25 | ->on('team') |
|
| 26 | ->onUpdate('cascade') |
|
| 27 | ->onDelete('cascade'); |
|
| 28 | ||
| 29 | $table->foreign('competitor_id') |
|
| 30 | ->references('id') |
|
| 31 | ->on('competitor') |
|
| 32 | ->onUpdate('cascade') |
|
| 33 | ->onDelete('cascade'); |
|
| 34 | ||
| 35 | $table->unique(['team_id', 'competitor_id']); |
|
| 36 | }); |
|
| 37 | } |
|
| 38 | ||
| 39 | /** |
|
| 40 | * Reverse the migrations. |
|
| 41 | * |
|
| 42 | * @return void |
|
| 43 | */ |
|
| 44 | public function down() |
|
| 45 | { |
|
| 46 | DB::statement('SET FOREIGN_KEY_CHECKS = 0'); |
|
| 47 | Schema::dropIfExists('competitor_team'); |
|
| 48 | DB::statement('SET FOREIGN_KEY_CHECKS = 1'); |
|
| 49 | } |
|
| 50 | } |
|
| 51 | ||