You've already forked Atomcms-edit
36 lines
1.2 KiB
PHP
Executable File
36 lines
1.2 KiB
PHP
Executable File
<?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
|
|
{
|
|
try {
|
|
if (Schema::hasColumn('users', 'radio_points')) {
|
|
DB::statement('CREATE INDEX IF NOT EXISTS users_radio_points_index ON users (radio_points)');
|
|
}
|
|
|
|
if (Schema::hasTable('radio_listener_points')) {
|
|
DB::statement('CREATE INDEX IF NOT EXISTS rlp_user_earned_index ON radio_listener_points (user_id, earned_at)');
|
|
DB::statement('CREATE INDEX IF NOT EXISTS rlp_earned_index ON radio_listener_points (earned_at)');
|
|
}
|
|
} catch (Exception $e) {
|
|
report($e);
|
|
}
|
|
}
|
|
|
|
public function down(): void
|
|
{
|
|
try {
|
|
DB::statement('DROP INDEX IF EXISTS users_radio_points_index ON users');
|
|
DB::statement('DROP INDEX IF EXISTS rlp_user_earned_index ON radio_listener_points');
|
|
DB::statement('DROP INDEX IF EXISTS rlp_earned_index ON radio_listener_points');
|
|
} catch (Exception $e) {
|
|
report($e);
|
|
}
|
|
}
|
|
};
|