58 lines
1.4 KiB
PHP
58 lines
1.4 KiB
PHP
<?php
|
|
|
|
use Illuminate\Database\Migrations\Migration;
|
|
use Illuminate\Database\Schema\Blueprint;
|
|
use Illuminate\Support\Facades\Schema;
|
|
use App\Models\Season;
|
|
use App\Models\Player;
|
|
use App\Models\Club;
|
|
|
|
return new class extends Migration
|
|
{
|
|
/**
|
|
* Run the migrations.
|
|
*/
|
|
public function up(): void
|
|
{
|
|
Schema::create('seasons', function (Blueprint $table) {
|
|
$table->id();
|
|
$table->string('title_ru');
|
|
$table->string('title_en');
|
|
$table->timestamps();
|
|
});
|
|
|
|
// test seed
|
|
for ($i = 2020; $i < 2026; $i++) {
|
|
Season::create([
|
|
'title_ru' => $i . ' год',
|
|
'title_en' => $i . ' year',
|
|
]);
|
|
}
|
|
|
|
Schema::create('player_season', function (Blueprint $table) {
|
|
$table->id();
|
|
|
|
$table->foreignIdFor(Season::class)
|
|
->constrained()
|
|
->onUpdate('cascade')
|
|
->onDelete('restrict');
|
|
|
|
$table->foreignIdFor(Player::class)
|
|
->constrained()
|
|
->onUpdate('cascade')
|
|
->onDelete('restrict');
|
|
|
|
$table->unique(['season_id', 'player_id']);
|
|
});
|
|
}
|
|
|
|
/**
|
|
* Reverse the migrations.
|
|
*/
|
|
public function down(): void
|
|
{
|
|
Schema::dropIfExists('player_season');
|
|
Schema::dropIfExists('seasons');
|
|
}
|
|
};
|