From 741faa38fb56f706733d518661e7000f066da3e4 Mon Sep 17 00:00:00 2001 From: safavimohadeseh78 Date: Tue, 8 Sep 2026 14:06:28 +0330 Subject: [PATCH] . --- .../abshode-domain-lookup/learned-notes.md | 2 + ...6_09_06_000001_create_giftcards_tables.php | 6 +-- ...8_000001_widen_giftcard_amount_columns.php | 41 +++++++++++++++++++ database/sql/deploy_safe_schema.sql | 33 +++++++++++++++ 4 files changed, 79 insertions(+), 3 deletions(-) create mode 100644 database/migrations/2026_09_08_000001_widen_giftcard_amount_columns.php diff --git a/.cursor/skills/abshode-domain-lookup/learned-notes.md b/.cursor/skills/abshode-domain-lookup/learned-notes.md index 810d1b5..643ca8f 100644 --- a/.cursor/skills/abshode-domain-lookup/learned-notes.md +++ b/.cursor/skills/abshode-domain-lookup/learned-notes.md @@ -4,3 +4,5 @@ - YYYY-MM-DD | موضوع | مسیر فایل(ها) | نکتهٔ ۱ خطی - 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) تا مبالغ ≥۱۰۰ میلیون ریال جا شود diff --git a/database/migrations/2026_09_06_000001_create_giftcards_tables.php b/database/migrations/2026_09_06_000001_create_giftcards_tables.php index 9afc4ed..169ecd6 100644 --- a/database/migrations/2026_09_06_000001_create_giftcards_tables.php +++ b/database/migrations/2026_09_06_000001_create_giftcards_tables.php @@ -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(); diff --git a/database/migrations/2026_09_08_000001_widen_giftcard_amount_columns.php b/database/migrations/2026_09_08_000001_widen_giftcard_amount_columns.php new file mode 100644 index 0000000..2f48f63 --- /dev/null +++ b/database/migrations/2026_09_08_000001_widen_giftcard_amount_columns.php @@ -0,0 +1,41 @@ + 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';