change gift-card

This commit is contained in:
2026-09-21 11:09:40 +03:30
parent ba2ac5aefe
commit 698fbed805
4 changed files with 105 additions and 20 deletions
@@ -0,0 +1,22 @@
<?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('giftcards') && ! Schema::hasColumn('giftcards', 'show_in_app')) {
Schema::table('giftcards', function (Blueprint $table) {
$table->unsignedTinyInteger('show_in_app')->default(0)->after('use_once');
});
}
}
public function down(): void
{
// ستون ممکن است روی نصب‌های قدیمی استفاده شود؛ drop نمی‌کنیم.
}
};
+8
View File
@@ -794,6 +794,14 @@ SET @sql = IF(
);
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='show_in_app') = 0,
'ALTER TABLE `giftcards` ADD COLUMN `show_in_app` TINYINT UNSIGNED NOT NULL DEFAULT 0 AFTER `use_once`',
'SELECT ''skip giftcards.show_in_app'' 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