fix price 2

This commit is contained in:
2026-06-14 13:31:32 +03:30
parent f07e56ed70
commit 6f86e8242c
3 changed files with 66 additions and 0 deletions
@@ -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');
});
}
};