diff --git a/database/migrations/2024_10_31_212512_update_new_and_drop_old_barcode_settings.php b/database/migrations/2024_10_31_212512_update_new_and_drop_old_barcode_settings.php new file mode 100644 index 0000000000..a802f04290 --- /dev/null +++ b/database/migrations/2024_10_31_212512_update_new_and_drop_old_barcode_settings.php @@ -0,0 +1,46 @@ +whereNull('label2_2d_type')->orWhere('label2_2d_type', '')->update([ + 'label2_2d_type' => DB::raw('barcode_type') + ]); + + DB::table('settings')->whereNull('label2_1d_type')->orWhere('label2_1d_type', '')->update([ + 'label2_1d_type' => DB::raw('alt_barcode') + ]); + + + Schema::table('settings', function (Blueprint $table) { + $table->dropColumn(['barcode_type', 'alt_barcode']); + }); + } + + public function down() + { + Schema::table('settings', function (Blueprint $table) { + // Re-add the columns that were dropped in case of rollback + $table->string('barcode_type')->nullable(); + $table->string('alt_barcode')->nullable(); + }); + + DB::table('settings')->whereNull('barcode_type')->orWhere('barcode_type', '')->update([ + 'barcode_type' => DB::raw('label2_2d_type') + ]); + + DB::table('settings')->whereNull('alt_barcode')->orWhere('alt_barcode', '')->update([ + 'alt_barcode' => DB::raw('label2_1d_type') + ]); + } +};