diff --git a/database/migrations/2023_04_05_222458_add_storage_description_to_media_table.php b/database/migrations/2023_04_05_222458_add_storage_description_to_media_table.php deleted file mode 100644 index 4ef9f0d..0000000 --- a/database/migrations/2023_04_05_222458_add_storage_description_to_media_table.php +++ /dev/null @@ -1,34 +0,0 @@ -string('storage')->default("cdn"); - $table->string('description')->default(""); - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::table('media', function (Blueprint $table) { - $table->dropColumn('description'); - $table->dropColumn('storage'); - }); - } -}; diff --git a/database/migrations/2023_04_05_222458_add_storage_description_variants_defaults_to_media_table.php b/database/migrations/2023_04_05_222458_add_storage_description_variants_defaults_to_media_table.php new file mode 100644 index 0000000..bfb627e --- /dev/null +++ b/database/migrations/2023_04_05_222458_add_storage_description_variants_defaults_to_media_table.php @@ -0,0 +1,59 @@ +whereNull('mime')->update(['mime' => '']); + + // Update null 'permission' values to empty strings + DB::table('media')->whereNull('permission')->update(['permission' => '']); + + $table->renameColumn('mime', 'mime_type'); + + $table->bigInteger('size')->default(0)->change(); + $table->string('mime_type')->default("")->nullable(false)->change(); + $table->string('permission')->default("")->nullable(false)->change(); + + $table->string('storage')->default("cdn"); + $table->string('description')->default(""); + $table->string('status')->default(""); + $table->string('dimensions')->default(""); + $table->text('variants')->default(""); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('media', function (Blueprint $table) { + $table->bigInteger('size')->change(); + $table->string('mime_type')->nullable(true)->change(); + $table->string('permission')->nullable(true)->change(); + + $table->renameColumn('mime_type', 'mime'); + + $table->dropColumn('status'); + $table->dropColumn('dimensions'); + $table->dropColumn('variants'); + $table->dropColumn('description'); + $table->dropColumn('storage'); + }); + } +};