.
This commit is contained in:
@@ -4,3 +4,5 @@
|
|||||||
- YYYY-MM-DD | موضوع | مسیر فایل(ها) | نکتهٔ ۱ خطی
|
- YYYY-MM-DD | موضوع | مسیر فایل(ها) | نکتهٔ ۱ خطی
|
||||||
|
|
||||||
- 2026-09-06 | گیفتکارت | `database/migrations/2026_09_06_000001_create_giftcards_tables.php` | create جداول giftcards و giftcard_codes اگر نباشند؛ drop در down ندارد
|
- 2026-09-06 | گیفتکارت | `database/migrations/2026_09_06_000001_create_giftcards_tables.php` | create جداول giftcards و giftcard_codes اگر نباشند؛ drop در down ندارد
|
||||||
|
- 2026-09-08 | خطای «محدودیت فیلد قیمت» در گیفتکارت | `app/Exceptions/Handler.php` + `GiftCardController::redeem` | پیام عمومی MySQL ۱۲۶۴ (Out of range) است؛ معمولاً `amount`/`total=count*amount` از ظرفیت ستون بیشتر است، نه باگ فرم ادمین
|
||||||
|
- 2026-09-08 | widen مبلغ گیفتکارت | `migrations/2026_09_08_000001_widen_giftcard_amount_columns.php` + `deploy_safe_schema.sql` | `amount`/`total` → DECIMAL(20,4) تا مبالغ ≥۱۰۰ میلیون ریال جا شود
|
||||||
|
|||||||
@@ -14,8 +14,8 @@ return new class extends Migration
|
|||||||
$table->integer('customer_id')->nullable();
|
$table->integer('customer_id')->nullable();
|
||||||
$table->unsignedTinyInteger('use_once')->default(0);
|
$table->unsignedTinyInteger('use_once')->default(0);
|
||||||
$table->integer('count')->nullable();
|
$table->integer('count')->nullable();
|
||||||
$table->float('amount')->nullable();
|
$table->decimal('amount', 20, 4)->nullable();
|
||||||
$table->bigInteger('total')->nullable();
|
$table->decimal('total', 20, 4)->nullable();
|
||||||
$table->integer('unit')->nullable();
|
$table->integer('unit')->nullable();
|
||||||
$table->string('unique_code')->nullable();
|
$table->string('unique_code')->nullable();
|
||||||
$table->timestamp('created_at')->nullable();
|
$table->timestamp('created_at')->nullable();
|
||||||
@@ -37,7 +37,7 @@ return new class extends Migration
|
|||||||
$table->string('code')->nullable();
|
$table->string('code')->nullable();
|
||||||
$table->unsignedTinyInteger('sts')->nullable();
|
$table->unsignedTinyInteger('sts')->nullable();
|
||||||
$table->unsignedTinyInteger('unit')->nullable();
|
$table->unsignedTinyInteger('unit')->nullable();
|
||||||
$table->float('amount')->nullable();
|
$table->decimal('amount', 20, 4)->nullable();
|
||||||
$table->text('assigned_to')->nullable();
|
$table->text('assigned_to')->nullable();
|
||||||
$table->timestamp('used_at')->nullable();
|
$table->timestamp('used_at')->nullable();
|
||||||
$table->timestamp('expiry_date')->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;
|
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';
|
-- UPDATE `settings` SET `value` = 'کیلوگرم' WHERE `key` = 'unit';
|
||||||
|
|||||||
Reference in New Issue
Block a user