fixed register

This commit is contained in:
2026-06-25 21:16:47 +03:30
parent 65f74453f3
commit 05dc2fecae
2 changed files with 19 additions and 3 deletions
+15 -2
View File
@@ -3,8 +3,21 @@
START TRANSACTION;
ALTER TABLE `customers`
ADD COLUMN `total_referrals` INT UNSIGNED NOT NULL DEFAULT 0 AFTER `referral_to_id`;
SET @db = DATABASE();
SET @sql = IF(
(SELECT COUNT(*) FROM information_schema.COLUMNS
WHERE TABLE_SCHEMA = @db AND TABLE_NAME = 'customers' AND COLUMN_NAME = 'total_referrals') = 0,
IF(
(SELECT COUNT(*) FROM information_schema.COLUMNS
WHERE TABLE_SCHEMA = @db AND TABLE_NAME = 'customers' AND COLUMN_NAME = 'referral_to_id') > 0,
'ALTER TABLE `customers` ADD COLUMN `total_referrals` INT UNSIGNED NOT NULL DEFAULT 0 AFTER `referral_to_id`',
'ALTER TABLE `customers` ADD COLUMN `total_referrals` INT UNSIGNED NOT NULL DEFAULT 0'
),
'SELECT ''skip customers.total_referrals'' AS info'
);
PREPARE stmt FROM @sql;
EXECUTE stmt;
DEALLOCATE PREPARE stmt;
-- هم‌تراز با تعداد ثبت‌نام‌های واقعی (اختیاری ولی توصیه می‌شود)
UPDATE `customers` AS c