From fcf5400f712488682be72ae307343ebadd1a4226 Mon Sep 17 00:00:00 2001 From: James Collins Date: Fri, 1 Sep 2023 08:43:57 +1000 Subject: [PATCH] added --- ...4_remove_status_and_update_media_table.php | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 database/migrations/2023_08_31_224314_remove_status_and_update_media_table.php diff --git a/database/migrations/2023_08_31_224314_remove_status_and_update_media_table.php b/database/migrations/2023_08_31_224314_remove_status_and_update_media_table.php new file mode 100644 index 0000000..04efdc4 --- /dev/null +++ b/database/migrations/2023_08_31_224314_remove_status_and_update_media_table.php @@ -0,0 +1,37 @@ +where('status', '<>', 'OK')->delete(); + + // Remove the 'status' column from the 'media' table + Schema::table('media', function (Blueprint $table) { + $table->dropColumn('status'); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + // Add the 'status' column back with a default value of an empty string + Schema::table('media', function (Blueprint $table) { + $table->string('status')->default(''); + }); + + // Update the 'status' column of all rows to 'OK' + DB::table('media')->update(['status' => 'OK']); + } +};