.
This commit is contained in:
@@ -14,8 +14,8 @@ return new class extends Migration
|
||||
$table->integer('customer_id')->nullable();
|
||||
$table->unsignedTinyInteger('use_once')->default(0);
|
||||
$table->integer('count')->nullable();
|
||||
$table->float('amount')->nullable();
|
||||
$table->bigInteger('total')->nullable();
|
||||
$table->decimal('amount', 20, 4)->nullable();
|
||||
$table->decimal('total', 20, 4)->nullable();
|
||||
$table->integer('unit')->nullable();
|
||||
$table->string('unique_code')->nullable();
|
||||
$table->timestamp('created_at')->nullable();
|
||||
@@ -37,7 +37,7 @@ return new class extends Migration
|
||||
$table->string('code')->nullable();
|
||||
$table->unsignedTinyInteger('sts')->nullable();
|
||||
$table->unsignedTinyInteger('unit')->nullable();
|
||||
$table->float('amount')->nullable();
|
||||
$table->decimal('amount', 20, 4)->nullable();
|
||||
$table->text('assigned_to')->nullable();
|
||||
$table->timestamp('used_at')->nullable();
|
||||
$table->timestamp('expiry_date')->nullable();
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* سقف قبلی amount (مثلاً FLOAT/DECIMAL با precision کم) جلوی مبالغ ~۱۰۰ میلیون ریال را میگرفت (خطای ۱۲۶۴).
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
if (Schema::hasTable('giftcards') && Schema::hasColumn('giftcards', 'amount')) {
|
||||
DB::statement('ALTER TABLE `giftcards` MODIFY `amount` DECIMAL(20,4) NULL');
|
||||
}
|
||||
|
||||
if (Schema::hasTable('giftcards') && Schema::hasColumn('giftcards', 'total')) {
|
||||
DB::statement('ALTER TABLE `giftcards` MODIFY `total` DECIMAL(20,4) NULL');
|
||||
}
|
||||
|
||||
if (Schema::hasTable('giftcard_codes') && Schema::hasColumn('giftcard_codes', 'amount')) {
|
||||
DB::statement('ALTER TABLE `giftcard_codes` MODIFY `amount` DECIMAL(20,4) NULL');
|
||||
}
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
if (Schema::hasTable('giftcards') && Schema::hasColumn('giftcards', 'amount')) {
|
||||
DB::statement('ALTER TABLE `giftcards` MODIFY `amount` FLOAT NULL');
|
||||
}
|
||||
|
||||
if (Schema::hasTable('giftcards') && Schema::hasColumn('giftcards', 'total')) {
|
||||
DB::statement('ALTER TABLE `giftcards` MODIFY `total` BIGINT NULL');
|
||||
}
|
||||
|
||||
if (Schema::hasTable('giftcard_codes') && Schema::hasColumn('giftcard_codes', 'amount')) {
|
||||
DB::statement('ALTER TABLE `giftcard_codes` MODIFY `amount` FLOAT NULL');
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -771,6 +771,39 @@ SET @sql = IF(
|
||||
);
|
||||
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
||||
|
||||
-- ---------------------------------------------------------------------------
|
||||
-- giftcards: ظرفیت مبلغ ریالی (خطای 1264 روی amount ~۱۰۰ میلیون)
|
||||
-- ---------------------------------------------------------------------------
|
||||
SET @sql = IF(
|
||||
(SELECT COUNT(*) FROM information_schema.COLUMNS
|
||||
WHERE TABLE_SCHEMA=@db AND TABLE_NAME='giftcards' AND COLUMN_NAME='amount') > 0
|
||||
AND (SELECT IFNULL(NUMERIC_PRECISION, 0) FROM information_schema.COLUMNS
|
||||
WHERE TABLE_SCHEMA=@db AND TABLE_NAME='giftcards' AND COLUMN_NAME='amount') < 20,
|
||||
'ALTER TABLE `giftcards` MODIFY `amount` DECIMAL(20,4) NULL',
|
||||
'SELECT ''skip giftcards.amount widen'' AS info'
|
||||
);
|
||||
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
||||
|
||||
SET @sql = IF(
|
||||
(SELECT COUNT(*) FROM information_schema.COLUMNS
|
||||
WHERE TABLE_SCHEMA=@db AND TABLE_NAME='giftcards' AND COLUMN_NAME='total') > 0
|
||||
AND (SELECT IFNULL(NUMERIC_PRECISION, 0) FROM information_schema.COLUMNS
|
||||
WHERE TABLE_SCHEMA=@db AND TABLE_NAME='giftcards' AND COLUMN_NAME='total') < 20,
|
||||
'ALTER TABLE `giftcards` MODIFY `total` DECIMAL(20,4) NULL',
|
||||
'SELECT ''skip giftcards.total widen'' AS info'
|
||||
);
|
||||
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
||||
|
||||
SET @sql = IF(
|
||||
(SELECT COUNT(*) FROM information_schema.COLUMNS
|
||||
WHERE TABLE_SCHEMA=@db AND TABLE_NAME='giftcard_codes' AND COLUMN_NAME='amount') > 0
|
||||
AND (SELECT IFNULL(NUMERIC_PRECISION, 0) FROM information_schema.COLUMNS
|
||||
WHERE TABLE_SCHEMA=@db AND TABLE_NAME='giftcard_codes' AND COLUMN_NAME='amount') < 20,
|
||||
'ALTER TABLE `giftcard_codes` MODIFY `amount` DECIMAL(20,4) NULL',
|
||||
'SELECT ''skip giftcard_codes.amount widen'' AS info'
|
||||
);
|
||||
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
||||
|
||||
-- ---------------------------------------------------------------------------
|
||||
-- پایان — برای بورسمس (اختیاری، جدا اجرا کنید):
|
||||
-- UPDATE `settings` SET `value` = 'کیلوگرم' WHERE `key` = 'unit';
|
||||
|
||||
Reference in New Issue
Block a user