| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- <?php
- use Illuminate\Database\Migrations\Migration;
- use Illuminate\Database\Schema\Blueprint;
- use Illuminate\Support\Facades\Schema;
- return new class extends Migration
- {
- /**
- * Run the migrations.
- */
- public function up(): void
- {
- Schema::create('leagues', function (Blueprint $table) {
- $table->id();
- // 来自 API 的联赛唯一标识
- $table->unsignedBigInteger('league_id')->unique()->comment('API-Sports 联赛唯一ID');
-
- // 联赛基本信息
- $table->string('name', 100)->comment('联赛名称 e.g. "Ligue 2", "Premier League"');
- $table->string('type', 50)->nullable()->comment('League / Cup 等');
- $table->string('logo', 255)->nullable()->comment('联赛logo URL');
- // 国家信息(扁平化,方便按国家筛选)
- $table->string('country_name', 100)->comment('国家名称');
- $table->string('country_code', 25)->nullable()->comment('国家代码');
- $table->string('country_flag', 255)->nullable()->comment('国旗 SVG/PNG URL');
- // 赛季信息 - 直接存 JSON 数组
- // 示例结构:[{"year":2010,"start":"2010-08-06","end":"2011-05-20","current":false,"coverage":{...}}, ...]
- $table->json('seasons')->nullable()->comment('赛季列表 JSON');
- // 辅助字段(根据实际业务需要)
- $table->boolean('is_active')->default(true)->comment('是否当前活跃联赛');
- $table->timestamp('last_synced_at')->nullable()->comment('最后从API同步时间');
- $table->timestamps();
- });
- }
- /**
- * Reverse the migrations.
- */
- public function down(): void
- {
- Schema::dropIfExists('leagues');
- }
- };
|