mirror of
https://github.com/snipe/snipe-it.git
synced 2025-02-20 19:05:55 -08:00
adds migration to update new with old if blank and remove old barcod variables
This commit is contained in:
parent
44447b85c9
commit
ae3cb7b37b
|
@ -0,0 +1,46 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*/
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
// Copy values if target columns are blank
|
||||||
|
DB::table('settings')->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')
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
};
|
Loading…
Reference in a new issue