| @@ 6-39 (lines=34) @@ | ||
| 3 | use Illuminate\Database\Migrations\Migration; |
|
| 4 | use Illuminate\Database\Schema\Blueprint; |
|
| 5 | ||
| 6 | class CreateTeamTable extends Migration |
|
| 7 | { |
|
| 8 | public function up() |
|
| 9 | { |
|
| 10 | Schema::create('team', function (Blueprint $table) { |
|
| 11 | $table->increments('id'); |
|
| 12 | $table->string('name'); |
|
| 13 | $table->integer('championship_id')->unsigned()->index(); // A checar |
|
| 14 | $table->string('picture')->nullable(); |
|
| 15 | $table->string('entity_type')->nullable(); // Club, Assoc, Fed |
|
| 16 | $table->integer('entity_id')->unsigned()->nullable()->index(); |
|
| 17 | $table->timestamps(); |
|
| 18 | ||
| 19 | $table->foreign('championship_id') |
|
| 20 | ->references('id') |
|
| 21 | ->on('championship') |
|
| 22 | ->onUpdate('cascade') |
|
| 23 | ->onDelete('cascade'); |
|
| 24 | ||
| 25 | $table->unique(['championship_id', 'name']); |
|
| 26 | }); |
|
| 27 | } |
|
| 28 | ||
| 29 | public function down() |
|
| 30 | { |
|
| 31 | DB::statement('SET FOREIGN_KEY_CHECKS = 0'); |
|
| 32 | Schema::drop('team'); |
|
| 33 | DB::statement('SET FOREIGN_KEY_CHECKS = 1'); |
|
| 34 | } |
|
| 35 | } |
|
| 36 | ||
| @@ 7-51 (lines=45) @@ | ||
| 4 | use Illuminate\Database\Schema\Blueprint; |
|
| 5 | use Illuminate\Support\Facades\Schema; |
|
| 6 | ||
| 7 | class CreateRoundCompetitorTable extends Migration |
|
| 8 | { |
|
| 9 | /** |
|
| 10 | * Run the migrations. |
|
| 11 | * |
|
| 12 | * @return void |
|
| 13 | */ |
|
| 14 | public function up() |
|
| 15 | { |
|
| 16 | Schema::create('round_competitor', function (Blueprint $table) { |
|
| 17 | $table->increments('id'); |
|
| 18 | $table->integer('competitor_id')->unsigned()->nullable()->index(); |
|
| 19 | $table->integer('round_id')->unsigned()->index(); // A checar |
|
| 20 | $table->timestamps(); |
|
| 21 | ||
| 22 | $table->foreign('competitor_id') |
|
| 23 | ->references('id') |
|
| 24 | ->on('competitor') |
|
| 25 | ->onUpdate('cascade') |
|
| 26 | ->onDelete('cascade'); |
|
| 27 | ||
| 28 | $table->foreign('round_id') |
|
| 29 | ->references('id') |
|
| 30 | ->on('round') |
|
| 31 | ->onUpdate('cascade') |
|
| 32 | ->onDelete('cascade'); |
|
| 33 | ||
| 34 | $table->unique(['competitor_id', 'round_id']); |
|
| 35 | }); |
|
| 36 | } |
|
| 37 | ||
| 38 | /** |
|
| 39 | * Reverse the migrations. |
|
| 40 | * |
|
| 41 | * @return void |
|
| 42 | */ |
|
| 43 | public function down() |
|
| 44 | { |
|
| 45 | DB::statement('SET FOREIGN_KEY_CHECKS = 0'); |
|
| 46 | Schema::dropIfExists('round_competitor'); |
|
| 47 | DB::statement('SET FOREIGN_KEY_CHECKS = 1'); |
|
| 48 | } |
|
| 49 | } |
|
| 50 | ||
| @@ 7-51 (lines=45) @@ | ||
| 4 | use Illuminate\Database\Schema\Blueprint; |
|
| 5 | use Illuminate\Support\Facades\Schema; |
|
| 6 | ||
| 7 | class CreateRoundTeamTable extends Migration |
|
| 8 | { |
|
| 9 | /** |
|
| 10 | * Run the migrations. |
|
| 11 | * |
|
| 12 | * @return void |
|
| 13 | */ |
|
| 14 | public function up() |
|
| 15 | { |
|
| 16 | Schema::create('round_team', function (Blueprint $table) { |
|
| 17 | $table->increments('id'); |
|
| 18 | $table->integer('team_id')->unsigned()->nullable()->index(); |
|
| 19 | $table->integer('round_id')->unsigned()->index(); // A checar |
|
| 20 | $table->timestamps(); |
|
| 21 | ||
| 22 | $table->foreign('team_id') |
|
| 23 | ->references('id') |
|
| 24 | ->on('team') |
|
| 25 | ->onUpdate('cascade') |
|
| 26 | ->onDelete('cascade'); |
|
| 27 | ||
| 28 | $table->foreign('round_id') |
|
| 29 | ->references('id') |
|
| 30 | ->on('round') |
|
| 31 | ->onUpdate('cascade') |
|
| 32 | ->onDelete('cascade'); |
|
| 33 | ||
| 34 | $table->unique(['team_id', 'round_id']); |
|
| 35 | }); |
|
| 36 | } |
|
| 37 | ||
| 38 | /** |
|
| 39 | * Reverse the migrations. |
|
| 40 | * |
|
| 41 | * @return void |
|
| 42 | */ |
|
| 43 | public function down() |
|
| 44 | { |
|
| 45 | DB::statement('SET FOREIGN_KEY_CHECKS = 0'); |
|
| 46 | Schema::dropIfExists('round_team'); |
|
| 47 | DB::statement('SET FOREIGN_KEY_CHECKS = 1'); |
|
| 48 | } |
|
| 49 | } |
|
| 50 | ||
| @@ 7-46 (lines=40) @@ | ||
| 4 | use Illuminate\Database\Schema\Blueprint; |
|
| 5 | use Illuminate\Support\Facades\Schema; |
|
| 6 | ||
| 7 | class CreateFightTable extends Migration |
|
| 8 | { |
|
| 9 | /** |
|
| 10 | * Run the migrations. |
|
| 11 | * |
|
| 12 | * @return void |
|
| 13 | */ |
|
| 14 | public function up() |
|
| 15 | { |
|
| 16 | Schema::create('fight', function (Blueprint $table) { |
|
| 17 | $table->increments('id'); |
|
| 18 | $table->integer('round_id')->unsigned()->index(); |
|
| 19 | $table->foreign('round_id') |
|
| 20 | ->references('id') |
|
| 21 | ->on('round') |
|
| 22 | ->onUpdate('cascade') |
|
| 23 | ->onDelete('cascade'); |
|
| 24 | $table->integer('c1')->nullable()->unsigned()->index(); |
|
| 25 | ||
| 26 | $table->integer('c2')->nullable()->unsigned()->index(); |
|
| 27 | ||
| 28 | $table->tinyInteger('area'); |
|
| 29 | $table->tinyInteger('order'); |
|
| 30 | $table->timestamps(); |
|
| 31 | $table->engine = 'InnoDB'; |
|
| 32 | }); |
|
| 33 | } |
|
| 34 | ||
| 35 | /** |
|
| 36 | * Reverse the migrations. |
|
| 37 | * |
|
| 38 | * @return void |
|
| 39 | */ |
|
| 40 | public function down() |
|
| 41 | { |
|
| 42 | DB::statement('SET FOREIGN_KEY_CHECKS = 0'); |
|
| 43 | Schema::dropIfExists('fight'); |
|
| 44 | DB::statement('SET FOREIGN_KEY_CHECKS = 1'); |
|
| 45 | } |
|
| 46 | } |
|
| 47 | ||