fix bug 22/4 2

This commit is contained in:
2026-07-13 19:03:30 +03:30
parent 7eb4650b80
commit 277cf31d93
8 changed files with 217 additions and 29 deletions
@@ -16,8 +16,12 @@ return new class extends Migration
if (! Schema::hasColumn('products', 'has_physical_delivery')) {
$table->boolean('has_physical_delivery')->default(false);
}
if (! Schema::hasColumn('products', 'min_physical_delivery_grams')) {
$table->decimal('min_physical_delivery_grams', 12, 3)->nullable();
// مقدار حداقل تحویل بر حسب واحد خود محصول (عدد برای تعدادی، گرم/کیلوگرم برای وزنی)
if (
! Schema::hasColumn('products', 'min_physical_delivery_quantity')
&& ! Schema::hasColumn('products', 'min_physical_delivery_grams')
) {
$table->decimal('min_physical_delivery_quantity', 12, 3)->nullable();
}
});
}
@@ -29,6 +33,9 @@ return new class extends Migration
}
Schema::table('products', function (Blueprint $table) {
if (Schema::hasColumn('products', 'min_physical_delivery_quantity')) {
$table->dropColumn('min_physical_delivery_quantity');
}
if (Schema::hasColumn('products', 'min_physical_delivery_grams')) {
$table->dropColumn('min_physical_delivery_grams');
}
@@ -0,0 +1,54 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
/**
* حد تحویل فیزیکی از «گرم» به «واحد خود محصول» تغییر کرد
* (عدد برای محصولات تعدادی، گرم/کیلوگرم برای وزنی).
* سرورهایی که نسخهٔ قبلی مایگریشن را اجرا کرده‌اند ستون min_physical_delivery_grams دارند
* که اینجا به min_physical_delivery_quantity تغییر نام می‌یابد (بدون از دست رفتن داده).
*
* از SQL خام استفاده شده تا نیاز به doctrine/dbal نباشد. پایگاه‌داده MySQL است.
*/
return new class extends Migration
{
public function up(): void
{
if (! Schema::hasTable('products')) {
return;
}
if (
Schema::hasColumn('products', 'min_physical_delivery_grams')
&& ! Schema::hasColumn('products', 'min_physical_delivery_quantity')
) {
$table = DB::getTablePrefix().'products';
DB::statement(
"ALTER TABLE `{$table}` CHANGE `min_physical_delivery_grams` `min_physical_delivery_quantity` DECIMAL(12,3) NULL DEFAULT NULL"
);
DB::purge();
DB::reconnect();
}
}
public function down(): void
{
if (! Schema::hasTable('products')) {
return;
}
if (
Schema::hasColumn('products', 'min_physical_delivery_quantity')
&& ! Schema::hasColumn('products', 'min_physical_delivery_grams')
) {
$table = DB::getTablePrefix().'products';
DB::statement(
"ALTER TABLE `{$table}` CHANGE `min_physical_delivery_quantity` `min_physical_delivery_grams` DECIMAL(12,3) NULL DEFAULT NULL"
);
DB::purge();
DB::reconnect();
}
}
};
@@ -0,0 +1,36 @@
<?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', 'app_price')) {
Schema::table('products', function (Blueprint $table) {
if (Schema::hasColumn('products', 'direct_price')) {
$table->boolean('app_price')->default(false)->after('direct_price');
} else {
$table->boolean('app_price')->default(false);
}
});
}
}
public function down(): void
{
if (! Schema::hasTable('products') || ! Schema::hasColumn('products', 'app_price')) {
return;
}
Schema::table('products', function (Blueprint $table) {
$table->dropColumn('app_price');
});
}
};