| 123456789101112131415161718192021222324252627282930 |
- <?php
- use Illuminate\Database\Migrations\Migration;
- use Illuminate\Database\Schema\Blueprint;
- use Illuminate\Support\Facades\DB;
- use Illuminate\Support\Facades\Schema;
- return new class extends Migration {
- public function up(): void
- {
- Schema::create('maintenance_settings', function (Blueprint $table) {
- $table->id(); $table->string('scope_code', 32)->unique(); $table->json('platforms');
- $table->boolean('enabled')->default(false)->index(); $table->dateTime('starts_at');
- $table->dateTime('ends_at')->nullable(); $table->string('timezone', 64); $table->timestamps();
- });
- Schema::create('maintenance_translations', function (Blueprint $table) {
- $table->id(); $table->unsignedBigInteger('maintenance_id'); $table->string('language', 8); $table->text('content');
- $table->unique(['maintenance_id', 'language']);
- $table->foreign('maintenance_id')->references('id')->on('maintenance_settings')->onDelete('cascade');
- });
- // Fixed scopes. Deployment must never start maintenance on its own.
- $now = gmdate('Y-m-d H:i:s');
- foreach (['site', 'third:1', 'third:2', 'third:3', 'third:4', 'third:5', 'third:6', 'third:7', 'self:sport', 'self:lottery'] as $scope) {
- DB::table('maintenance_settings')->insert(['scope_code' => $scope, 'platforms' => '["PC","H5","APP"]',
- 'enabled' => false, 'starts_at' => $now, 'ends_at' => null, 'timezone' => 'Asia/Shanghai', 'created_at' => $now, 'updated_at' => $now]);
- }
- }
- public function down(): void { Schema::dropIfExists('maintenance_translations'); Schema::dropIfExists('maintenance_settings'); }
- };
|