fix price 2
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
if (! Schema::hasTable('products')) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (Schema::hasColumn('products', 'direct_price')) {
|
||||
return;
|
||||
}
|
||||
|
||||
Schema::table('products', function (Blueprint $table) {
|
||||
if (Schema::hasColumn('products', 'inventory')) {
|
||||
$table->unsignedTinyInteger('direct_price')->default(0)->after('inventory');
|
||||
} elseif (Schema::hasColumn('products', 'bubble')) {
|
||||
$table->unsignedTinyInteger('direct_price')->default(0)->after('bubble');
|
||||
} else {
|
||||
$table->unsignedTinyInteger('direct_price')->default(0);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
if (! Schema::hasTable('products') || ! Schema::hasColumn('products', 'direct_price')) {
|
||||
return;
|
||||
}
|
||||
|
||||
Schema::table('products', function (Blueprint $table) {
|
||||
$table->dropColumn('direct_price');
|
||||
});
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user