From a0115663c9d6d8cf8a1574e7b8c5dae4a04c906c Mon Sep 17 00:00:00 2001 From: Daniel Date: Wed, 10 Jul 2024 16:07:19 +0200 Subject: [PATCH] hotfix migration from last release --- ...024_07_10_094930_change_objects_to_uuid.php | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/database/migrations/2024_07_10_094930_change_objects_to_uuid.php b/database/migrations/2024_07_10_094930_change_objects_to_uuid.php index 6dddb4ffc..d28dbed1e 100644 --- a/database/migrations/2024_07_10_094930_change_objects_to_uuid.php +++ b/database/migrations/2024_07_10_094930_change_objects_to_uuid.php @@ -12,31 +12,31 @@ public function up(): void { Schema::table('training_object_attachments', function (Blueprint $table) { - // Add a new UUID column - $table->uuid('uuid')->first(); // Adding it as the first column for convenience + // Step 1: Add a new UUID column + $table->uuid('uuid')->first(); }); - // Assuming all your rows have unique IDs and you can iterate through them - // Populate the new uuid column with UUIDs + // Step 2: Populate the new uuid column with UUIDs DB::table('training_object_attachments')->get()->each(function ($item) { DB::table('training_object_attachments') ->where('id', $item->id) ->update(['uuid' => \Illuminate\Support\Str::uuid()]); }); + // Step 3: Remove auto-increment from the 'id' column Schema::table('training_object_attachments', function (Blueprint $table) { - $table->dropPrimary(); + $table->dropPrimary(['id']); // Drop the primary key + $table->unsignedBigInteger('id')->autoIncrement(false)->change(); // Remove auto-increment }); + // Step 4: Drop the 'id' column Schema::table('training_object_attachments', function (Blueprint $table) { $table->dropColumn('id'); }); + // Step 5 & 6: Rename 'uuid' column to 'id' and set it as the primary key Schema::table('training_object_attachments', function (Blueprint $table) { $table->renameColumn('uuid', 'id'); - }); - - Schema::table('training_object_attachments', function (Blueprint $table) { $table->primary('id'); }); } @@ -48,4 +48,4 @@ public function down(): void { // Breaking change, but harmless as things continue to work } -}; +}; \ No newline at end of file