| 1234567891011121314151617181920212223242526272829303132333435363738 |
- <?php
- use Illuminate\Database\Migrations\Migration;
- use Illuminate\Support\Facades\DB;
- use Illuminate\Support\Facades\Schema;
- return new class extends Migration {
- public function up(): void
- {
- if (!Schema::hasTable('maintenance_settings')) return;
- $table = Schema::getConnection()->getTablePrefix() . 'maintenance_settings';
- $driver = Schema::getConnection()->getDriverName();
- if ($driver === 'mysql') {
- DB::statement("ALTER TABLE `{$table}` MODIFY `scope_code` VARCHAR(64) NOT NULL");
- } elseif ($driver === 'pgsql') {
- DB::statement("ALTER TABLE \"{$table}\" ALTER COLUMN scope_code TYPE VARCHAR(64)");
- }
- }
- public function down(): void
- {
- if (!Schema::hasTable('maintenance_settings')) return;
- // The old admin only recognizes site and category scopes. The FK removes child translations.
- DB::table('maintenance_settings')
- ->where('scope_code', 'like', 'third:%:%')
- ->orWhere('scope_code', 'like', 'self:lottery:%')
- ->orWhere('scope_code', 'like', 'self:sport:%')
- ->delete();
- $table = Schema::getConnection()->getTablePrefix() . 'maintenance_settings';
- $driver = Schema::getConnection()->getDriverName();
- if ($driver === 'mysql') {
- DB::statement("ALTER TABLE `{$table}` MODIFY `scope_code` VARCHAR(32) NOT NULL");
- } elseif ($driver === 'pgsql') {
- DB::statement("ALTER TABLE \"{$table}\" ALTER COLUMN scope_code TYPE VARCHAR(32)");
- }
- }
- };
|