Fix issues with unique keys

Signed-off-by: Shaggy84675 <admin@RainbowShaggy.com>
This commit is contained in:
Shaggy84675
2025-08-02 17:21:32 +02:00
parent eb094193d9
commit b16593c162
2 changed files with 22 additions and 3 deletions

View File

@@ -11,8 +11,19 @@
*/
public function up(): void
{
if (Schema::hasIndex('game_files', ['name', 'hash', 'version'])) {
Schema::table('game_files', function (Blueprint $table) {
$table->dropUnique(['name', 'hash', 'version']);
});
}
//Schema doesn't support tinyint
DB::statement("ALTER TABLE `game_files` CHANGE `version` `patchline` TINYINT UNSIGNED NOT NULL DEFAULT '1';");
Schema::table('game_files', function (Blueprint $table) {
$table->unique(['name', 'hash', 'patchline']);
});
}
/**
@@ -20,11 +31,19 @@ public function up(): void
*/
public function down(): void
{
if (Schema::hasIndex('game_files', ['name', 'hash', 'patchline'])) {
Schema::table('game_files', function (Blueprint $table) {
$table->dropUnique(['name', 'hash', 'patchline']);
});
}
Schema::table('game_files', function (Blueprint $table) {
$table->integer('patchline')->default(1)->change();
});
Schema::table('game_files', function (Blueprint $table) {
$table->renameColumn('patchline', 'version');
});
Schema::table('game_files', function (Blueprint $table) {
$table->unique(['name', 'hash', 'version']);
});
}
};

View File

@@ -14,11 +14,11 @@ public function up(): void
//Schema doesn't support tinyint
DB::statement("ALTER TABLE `game_files` ADD COLUMN `is_additional` TINYINT UNSIGNED NOT NULL DEFAULT '0' AFTER `action`;");
if (Schema::hasIndex('game_files', ['name', 'hash', 'version'])) {
if (Schema::hasIndex('game_files', ['name', 'hash', 'patchline'])) {
Schema::table('game_files', function (Blueprint $table) {
$table->dropUnique(['name', 'hash', 'version']);
$table->dropUnique(['name', 'hash', 'patchline']);
});
}
}
Schema::table('game_files', function (Blueprint $table) {
$table->renameColumn('name', 'filename');