Add migration check command and cleanup orphaned migrations

This commit is contained in:
root
2026-05-09 18:14:37 +02:00
parent 9d73f82529
commit 8b6e028ae6
8 changed files with 352 additions and 242 deletions
@@ -1,36 +0,0 @@
<?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
{
if (config('habbo.migrations.rename_tables') && Schema::hasTable('personal_access_tokens')) {
Schema::rename('personal_access_tokens', sprintf('personal_access_tokens_%s', time()));
}
Schema::create('personal_access_tokens', function (Blueprint $table) {
$table->id();
$table->morphs('tokenable');
$table->string('name');
$table->string('token', 64)->unique();
$table->text('abilities')->nullable();
$table->timestamp('last_used_at')->nullable();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('personal_access_tokens');
}
};
@@ -1,36 +0,0 @@
<?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
{
if (config('habbo.migrations.rename_tables') && Schema::hasTable('users_session_logs')) {
Schema::rename('users_session_logs', sprintf('users_session_logs_%s', time()));
}
Schema::create('users_session_logs', function (Blueprint $table) {
$table->id();
$table->unsignedInteger('user_id');
$table->string('ip', 100)->default('0');
$table->text('browser')->nullable();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('users_session_logs');
}
};
@@ -1,32 +0,0 @@
<?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::dropIfExists('users_session_logs');
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::create('users_session_logs', function (Blueprint $table) {
$table->id();
$table->unsignedInteger('user_id');
$table->string('ip', 100)->default('0');
$table->text('browser')->nullable();
$table->timestamps();
});
}
};
@@ -1,33 +0,0 @@
<?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::table('radio_contests', function (Blueprint $table) {
$table->string('title');
$table->text('description')->nullable();
$table->boolean('is_active')->default(false);
$table->boolean('is_ended')->default(false);
$table->timestamp('start_date')->nullable();
$table->timestamp('end_date')->nullable();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('radio_contests', function (Blueprint $table) {
$table->dropColumn(['title', 'description', 'is_active', 'is_ended', 'start_date', 'end_date']);
});
}
};
@@ -1,32 +0,0 @@
<?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::table('radio_giveaways', function (Blueprint $table) {
$table->string('title');
$table->text('description')->nullable();
$table->boolean('is_active')->default(false);
$table->boolean('is_ended')->default(false);
$table->timestamp('end_date')->nullable();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('radio_giveaways', function (Blueprint $table) {
$table->dropColumn(['title', 'description', 'is_active', 'is_ended', 'end_date']);
});
}
};
@@ -1,22 +0,0 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public function up(): void
{
Schema::table('radio_ranks', function (Blueprint $table) {
$table->dropColumn('is_active');
});
}
public function down(): void
{
Schema::table('radio_ranks', function (Blueprint $table) {
$table->boolean('is_active')->default(true)->after('badge_code');
});
}
};
@@ -1,51 +0,0 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public function up(): void
{
Schema::table('website_ip_whitelist', function (Blueprint $table) {
$table->string('country_code')->nullable()->after('asn');
$table->string('country_name')->nullable()->after('country_code');
$table->boolean('whitelist_country')->default(false)->after('country_name');
});
Schema::table('website_ip_blacklist', function (Blueprint $table) {
$table->string('country_code')->nullable()->after('asn');
$table->string('country_name')->nullable()->after('country_code');
$table->boolean('blacklist_country')->default(false)->after('country_name');
});
Schema::create('website_blocked_countries', function (Blueprint $table) {
$table->id();
$table->string('country_code', 2);
$table->string('country_name');
$table->timestamps();
});
Schema::create('website_api_settings', function (Blueprint $table) {
$table->id();
$table->string('key')->unique();
$table->string('value')->nullable();
$table->timestamps();
});
}
public function down(): void
{
Schema::dropIfExists('website_blocked_countries');
Schema::dropIfExists('website_api_settings');
Schema::table('website_ip_whitelist', function (Blueprint $table) {
$table->dropColumn(['country_code', 'country_name', 'whitelist_country']);
});
Schema::table('website_ip_blacklist', function (Blueprint $table) {
$table->dropColumn(['country_code', 'country_name', 'blacklist_country']);
});
}
};