| @@ 8-38 (lines=31) @@ | ||
| 5 | use Xoco70\LaravelTournaments\DBHelpers; |
|
| 6 | use Xoco70\LaravelTournaments\Models\Team; |
|
| 7 | ||
| 8 | class CreateLtTeamTable extends Migration |
|
| 9 | { |
|
| 10 | public function up() |
|
| 11 | { |
|
| 12 | Schema::create('team', function (Blueprint $table) { |
|
| 13 | $table->increments('id'); |
|
| 14 | $table->integer('short_id')->unsigned()->nullable(); |
|
| 15 | $table->string('name'); |
|
| 16 | $table->integer('championship_id')->unsigned()->index(); // A checar |
|
| 17 | $table->string('picture')->nullable(); |
|
| 18 | $table->string('entity_type')->nullable(); // Club, Assoc, Fed |
|
| 19 | $table->integer('entity_id')->unsigned()->nullable()->index(); |
|
| 20 | $table->timestamps(); |
|
| 21 | ||
| 22 | $table->foreign('championship_id') |
|
| 23 | ->references('id') |
|
| 24 | ->on('championship') |
|
| 25 | ->onUpdate('cascade') |
|
| 26 | ->onDelete('cascade'); |
|
| 27 | ||
| 28 | $table->unique(['championship_id', 'name']); |
|
| 29 | }); |
|
| 30 | } |
|
| 31 | ||
| 32 | public function down() |
|
| 33 | { |
|
| 34 | DBHelpers::setFKCheckOff(); |
|
| 35 | Schema::drop('team'); |
|
| 36 | DBHelpers::setFKCheckOn(); |
|
| 37 | } |
|
| 38 | } |
|
| 39 | ||
| @@ 8-51 (lines=44) @@ | ||
| 5 | use Illuminate\Support\Facades\Schema; |
|
| 6 | use Xoco70\LaravelTournaments\DBHelpers; |
|
| 7 | ||
| 8 | class CreateLtFightersGroupCompetitorTable extends Migration |
|
| 9 | { |
|
| 10 | /** |
|
| 11 | * Run the migrations. |
|
| 12 | * |
|
| 13 | * @return void |
|
| 14 | */ |
|
| 15 | public function up() |
|
| 16 | { |
|
| 17 | Schema::create('fighters_group_competitor', function (Blueprint $table) { |
|
| 18 | $table->increments('id'); |
|
| 19 | $table->integer('competitor_id')->unsigned()->nullable()->index(); |
|
| 20 | $table->integer('fighters_group_id')->unsigned()->index(); |
|
| 21 | $table->integer('order')->unsigned()->nullable(); |
|
| 22 | $table->timestamps(); |
|
| 23 | ||
| 24 | $table->foreign('competitor_id') |
|
| 25 | ->references('id') |
|
| 26 | ->on('competitor') |
|
| 27 | ->onUpdate('cascade') |
|
| 28 | ->onDelete('cascade'); |
|
| 29 | ||
| 30 | $table->foreign('fighters_group_id') |
|
| 31 | ->references('id') |
|
| 32 | ->on('fighters_groups') |
|
| 33 | ->onUpdate('cascade') |
|
| 34 | ->onDelete('cascade'); |
|
| 35 | ||
| 36 | $table->unique(['competitor_id', 'fighters_group_id']); |
|
| 37 | }); |
|
| 38 | } |
|
| 39 | ||
| 40 | /** |
|
| 41 | * Reverse the migrations. |
|
| 42 | * |
|
| 43 | * @return void |
|
| 44 | */ |
|
| 45 | public function down() |
|
| 46 | { |
|
| 47 | DBHelpers::setFKCheckOff(); |
|
| 48 | Schema::dropIfExists('fighters_group_competitor'); |
|
| 49 | DBHelpers::setFKCheckOn(); |
|
| 50 | } |
|
| 51 | } |
|
| 52 | ||
| @@ 8-51 (lines=44) @@ | ||
| 5 | use Illuminate\Support\Facades\Schema; |
|
| 6 | use Xoco70\LaravelTournaments\DBHelpers; |
|
| 7 | ||
| 8 | class CreateLtFightersGroupTeamTable extends Migration |
|
| 9 | { |
|
| 10 | /** |
|
| 11 | * Run the migrations. |
|
| 12 | * |
|
| 13 | * @return void |
|
| 14 | */ |
|
| 15 | public function up() |
|
| 16 | { |
|
| 17 | Schema::create('fighters_group_team', function (Blueprint $table) { |
|
| 18 | $table->increments('id'); |
|
| 19 | $table->integer('team_id')->unsigned()->nullable()->index(); |
|
| 20 | $table->integer('fighters_group_id')->unsigned()->index(); |
|
| 21 | $table->integer('order')->unsigned()->nullable(); |
|
| 22 | $table->timestamps(); |
|
| 23 | ||
| 24 | $table->foreign('team_id') |
|
| 25 | ->references('id') |
|
| 26 | ->on('team') |
|
| 27 | ->onUpdate('cascade') |
|
| 28 | ->onDelete('cascade'); |
|
| 29 | ||
| 30 | $table->foreign('fighters_group_id') |
|
| 31 | ->references('id') |
|
| 32 | ->on('fighters_groups') |
|
| 33 | ->onUpdate('cascade') |
|
| 34 | ->onDelete('cascade'); |
|
| 35 | ||
| 36 | $table->unique(['team_id', 'fighters_group_id']); |
|
| 37 | }); |
|
| 38 | } |
|
| 39 | ||
| 40 | /** |
|
| 41 | * Reverse the migrations. |
|
| 42 | * |
|
| 43 | * @return void |
|
| 44 | */ |
|
| 45 | public function down() |
|
| 46 | { |
|
| 47 | DBHelpers::setFKCheckOff(); |
|
| 48 | Schema::dropIfExists('fighters_group_team'); |
|
| 49 | DBHelpers::setFKCheckOn(); |
|
| 50 | } |
|
| 51 | } |
|
| 52 | ||
| @@ 8-51 (lines=44) @@ | ||
| 5 | use Illuminate\Support\Facades\Schema; |
|
| 6 | use Xoco70\LaravelTournaments\DBHelpers; |
|
| 7 | ||
| 8 | class CreateLtCompetitorTeamTable extends Migration |
|
| 9 | { |
|
| 10 | /** |
|
| 11 | * Run the migrations. |
|
| 12 | * |
|
| 13 | * @return void |
|
| 14 | */ |
|
| 15 | public function up() |
|
| 16 | { |
|
| 17 | Schema::create('competitor_team', function (Blueprint $table) { |
|
| 18 | $table->increments('id'); |
|
| 19 | $table->integer('team_id')->unsigned()->nullable()->index(); |
|
| 20 | $table->integer('competitor_id')->unsigned()->index(); |
|
| 21 | $table->integer('order')->unsigned()->nullable(); |
|
| 22 | $table->timestamps(); |
|
| 23 | ||
| 24 | $table->foreign('team_id') |
|
| 25 | ->references('id') |
|
| 26 | ->on('team') |
|
| 27 | ->onUpdate('cascade') |
|
| 28 | ->onDelete('cascade'); |
|
| 29 | ||
| 30 | $table->foreign('competitor_id') |
|
| 31 | ->references('id') |
|
| 32 | ->on('competitor') |
|
| 33 | ->onUpdate('cascade') |
|
| 34 | ->onDelete('cascade'); |
|
| 35 | ||
| 36 | $table->unique(['team_id', 'competitor_id']); |
|
| 37 | }); |
|
| 38 | } |
|
| 39 | ||
| 40 | /** |
|
| 41 | * Reverse the migrations. |
|
| 42 | * |
|
| 43 | * @return void |
|
| 44 | */ |
|
| 45 | public function down() |
|
| 46 | { |
|
| 47 | DBHelpers::setFKCheckOff(); |
|
| 48 | Schema::dropIfExists('competitor_team'); |
|
| 49 | DBHelpers::setFKCheckOn(); |
|
| 50 | } |
|
| 51 | } |
|
| 52 | ||