Files
boursecu_server/database/sql/bazre_tala_settings_update.sql
T
2026-06-10 13:11:51 +03:30

550 lines
41 KiB
SQL

-- =============================================================================
-- بذر طلا (bazretala) — merge ماژولار settings + const
--
-- USE `ak`; -- یا نام دیتابیس بذر طلا
-- SOURCE bazre_tala_settings_update.sql;
--
-- اصول:
-- • value ردیف موجود overwrite نمی‌شود
-- • title_fa / type / can_edit / is_active به‌روز می‌شود
-- • INSERT کلیدهای modular + کلیدهای legacy (liman_* / const)
-- • اگر const از قبل پر است → فقط خالی‌های settings پر می‌شود
-- • DELETE ندارد — legacy می‌ماند تا خودتان پاک کنید
--
-- قبل از اجرا: بکاپ کامل
-- =============================================================================
START TRANSACTION;
SET NAMES utf8mb4 COLLATE utf8mb4_unicode_ci;
ALTER TABLE `settings`
MODIFY COLUMN `description` TEXT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
MODIFY COLUMN `title_fa` VARCHAR(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
MODIFY COLUMN `type` VARCHAR(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL;
ALTER TABLE `const`
MODIFY COLUMN `title_fa` VARCHAR(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL;
-- -----------------------------------------------------------------------------
-- قیمت — منبع و zaarbox / main_product
-- -----------------------------------------------------------------------------
INSERT INTO `settings` (`key`, `value`, `title_fa`, `can_edit`, `is_active`, `description`)
SELECT 'price_provider', 'montzar', 'منبع قیمت', 1, 1, 'montzar | zaarbox | main_product | taban_gohar | etehadie'
WHERE NOT EXISTS (SELECT 1 FROM `settings` WHERE `key` = 'price_provider' LIMIT 1);
INSERT INTO `settings` (`key`, `value`, `title_fa`, `can_edit`, `is_active`, `description`)
SELECT 'main_product', '13', 'محصول آبشده (id یا reading_method)', 1, 1, NULL
WHERE NOT EXISTS (SELECT 1 FROM `settings` WHERE `key` = 'main_product' LIMIT 1);
INSERT INTO `settings` (`key`, `value`, `title_fa`, `can_edit`, `is_active`, `description`)
SELECT 'zaarbox_api_url', 'https://price.zaarbox.ir/api/free', 'آدرس API تابلو Zaarbox', 1, 1, NULL
WHERE NOT EXISTS (SELECT 1 FROM `settings` WHERE `key` = 'zaarbox_api_url' LIMIT 1);
INSERT INTO `settings` (`key`, `value`, `title_fa`, `can_edit`, `is_active`, `description`)
SELECT 'zaarbox_price_key', '', 'شناسه ردیف تابلو (key یا UUID)', 1, 1, NULL
WHERE NOT EXISTS (SELECT 1 FROM `settings` WHERE `key` = 'zaarbox_price_key' LIMIT 1);
INSERT INTO `settings` (`key`, `value`, `title_fa`, `can_edit`, `is_active`, `description`)
SELECT 'chart_id', '', 'UUID نمودار Zaarbox', 1, 1, 'خالی = ca3800a0-1f57-3528-b963-178f9168e04f'
WHERE NOT EXISTS (SELECT 1 FROM `settings` WHERE `key` = 'chart_id' LIMIT 1);
INSERT INTO `settings` (`key`, `value`, `title_fa`, `can_edit`, `is_active`, `description`)
SELECT 'etehadie_api_url', 'http://109.122.246.48:4949/api/free', 'آدرس API اتحادیه', 1, 1, NULL
WHERE NOT EXISTS (SELECT 1 FROM `settings` WHERE `key` = 'etehadie_api_url' LIMIT 1);
INSERT INTO `settings` (`key`, `value`, `title_fa`, `can_edit`, `is_active`, `description`)
SELECT 'main_product_price', 'false', 'دریافت قیمت از محصولات (legacy)', 1, 1, 'جایگزین: price_provider=main_product'
WHERE NOT EXISTS (SELECT 1 FROM `settings` WHERE `key` = 'main_product_price' LIMIT 1);
INSERT INTO `settings` (`key`, `value`, `title_fa`, `can_edit`, `is_active`, `description`)
SELECT 'tabanGohar_price', 'false', 'دریافت قیمت تابان گوهر', 1, 1, NULL
WHERE NOT EXISTS (SELECT 1 FROM `settings` WHERE `key` = 'tabanGohar_price' LIMIT 1);
INSERT INTO `settings` (`key`, `value`, `title_fa`, `can_edit`, `is_active`, `description`)
SELECT 'show_last_price', 'true', 'نمایش آخرین قیمت DB وقتی API قطع است', 1, 1, NULL
WHERE NOT EXISTS (SELECT 1 FROM `settings` WHERE `key` = 'show_last_price' LIMIT 1);
-- -----------------------------------------------------------------------------
-- Montzar / همکار (لیمان)
-- -----------------------------------------------------------------------------
INSERT INTO `settings` (`key`, `value`, `title_fa`, `can_edit`, `is_active`, `description`)
SELECT 'montzar_price', 'false', 'دریافت قیمت از همکار', 1, 1, 'true یا price_provider=montzar'
WHERE NOT EXISTS (SELECT 1 FROM `settings` WHERE `key` = 'montzar_price' LIMIT 1);
INSERT INTO `settings` (`key`, `value`, `title_fa`, `can_edit`, `is_active`, `description`)
SELECT 'montzar_mobile', '', 'موبایل ورود API همکار', 1, 1, NULL
WHERE NOT EXISTS (SELECT 1 FROM `settings` WHERE `key` = 'montzar_mobile' LIMIT 1);
INSERT INTO `settings` (`key`, `value`, `title_fa`, `can_edit`, `is_active`, `description`)
SELECT 'montzar_password', '', 'رمز ورود API همکار', 1, 1, NULL
WHERE NOT EXISTS (SELECT 1 FROM `settings` WHERE `key` = 'montzar_password' LIMIT 1);
INSERT INTO `settings` (`key`, `value`, `title_fa`, `can_edit`, `is_active`, `description`)
SELECT 'montzar_product_id', '25', 'کد محصول همکار', 1, 1, NULL
WHERE NOT EXISTS (SELECT 1 FROM `settings` WHERE `key` = 'montzar_product_id' LIMIT 1);
INSERT INTO `settings` (`key`, `value`, `title_fa`, `can_edit`, `is_active`, `description`)
SELECT 'montzar_base_url', 'https://limangold.ir', 'آدرس سرور همکار', 1, 1, NULL
WHERE NOT EXISTS (SELECT 1 FROM `settings` WHERE `key` = 'montzar_base_url' LIMIT 1);
INSERT INTO `settings` (`key`, `value`, `title_fa`, `can_edit`, `is_active`, `description`)
SELECT 'montzar_token', '', 'توکن همکار (سیستم)', 0, 1, 'خودکار پر می‌شود'
WHERE NOT EXISTS (SELECT 1 FROM `settings` WHERE `key` = 'montzar_token' LIMIT 1);
INSERT INTO `settings` (`key`, `value`, `title_fa`, `can_edit`, `is_active`, `description`)
SELECT 'montzar_closed', 'false', 'بسته بودن سرویس همکار', 0, 1, NULL
WHERE NOT EXISTS (SELECT 1 FROM `settings` WHERE `key` = 'montzar_closed' LIMIT 1);
INSERT INTO `settings` (`key`, `value`, `title_fa`, `can_edit`, `is_active`, `description`)
SELECT 'montzar_open_buy', 'true', 'باز بودن خرید همکار', 1, 1, NULL
WHERE NOT EXISTS (SELECT 1 FROM `settings` WHERE `key` = 'montzar_open_buy' LIMIT 1);
INSERT INTO `settings` (`key`, `value`, `title_fa`, `can_edit`, `is_active`, `description`)
SELECT 'montzar_open_sell', 'true', 'باز بودن فروش همکار', 1, 1, NULL
WHERE NOT EXISTS (SELECT 1 FROM `settings` WHERE `key` = 'montzar_open_sell' LIMIT 1);
INSERT INTO `settings` (`key`, `value`, `title_fa`, `can_edit`, `is_active`, `description`)
SELECT 'montzar_diff', '0', 'اختلاف قیمت همکار (سیستم)', 0, 1, NULL
WHERE NOT EXISTS (SELECT 1 FROM `settings` WHERE `key` = 'montzar_diff' LIMIT 1);
INSERT INTO `settings` (`key`, `value`, `title_fa`, `can_edit`, `is_active`, `description`)
SELECT 'montzar_live_price', '0', 'قیمت لحظه‌ای همکار', 0, 1, NULL
WHERE NOT EXISTS (SELECT 1 FROM `settings` WHERE `key` = 'montzar_live_price' LIMIT 1);
INSERT INTO `settings` (`key`, `value`, `title_fa`, `can_edit`, `is_active`, `description`)
SELECT 'montzar_mazaneh', '0', 'مظنه همکار', 0, 1, NULL
WHERE NOT EXISTS (SELECT 1 FROM `settings` WHERE `key` = 'montzar_mazaneh' LIMIT 1);
INSERT INTO `settings` (`key`, `value`, `title_fa`, `can_edit`, `is_active`, `description`)
SELECT 'montzar_truly_buy_mazaneh', '0', 'مظنه خرید واقعی همکار', 0, 1, NULL
WHERE NOT EXISTS (SELECT 1 FROM `settings` WHERE `key` = 'montzar_truly_buy_mazaneh' LIMIT 1);
INSERT INTO `settings` (`key`, `value`, `title_fa`, `can_edit`, `is_active`, `description`)
SELECT 'montzar_truly_sell_mazaneh', '0', 'مظنه فروش واقعی همکار', 0, 1, NULL
WHERE NOT EXISTS (SELECT 1 FROM `settings` WHERE `key` = 'montzar_truly_sell_mazaneh' LIMIT 1);
INSERT INTO `settings` (`key`, `value`, `title_fa`, `can_edit`, `is_active`, `description`)
SELECT 'display_montzar', 'true', 'نمایش بلوک همکار در UI', 1, 1, NULL
WHERE NOT EXISTS (SELECT 1 FROM `settings` WHERE `key` = 'display_montzar' LIMIT 1);
INSERT INTO `settings` (`key`, `value`, `title_fa`, `can_edit`, `is_active`, `description`)
SELECT 'liman_token', '', 'توکن لیمان (legacy)', 1, 1, NULL
WHERE NOT EXISTS (SELECT 1 FROM `settings` WHERE `key` = 'liman_token' LIMIT 1);
-- -----------------------------------------------------------------------------
-- کارمزد نمایش و سفارش
-- -----------------------------------------------------------------------------
INSERT INTO `settings` (`key`, `value`, `title_fa`, `can_edit`, `is_active`, `description`)
SELECT 'fee_single', '500000', 'اختلاف پایه نمایش (ریال)', 1, 1, NULL
WHERE NOT EXISTS (SELECT 1 FROM `settings` WHERE `key` = 'fee_single' LIMIT 1);
INSERT INTO `settings` (`key`, `value`, `title_fa`, `can_edit`, `is_active`, `description`)
SELECT 'buy_fee', '500000', 'سود خرید نمایش', 1, 1, NULL
WHERE NOT EXISTS (SELECT 1 FROM `settings` WHERE `key` = 'buy_fee' LIMIT 1);
INSERT INTO `settings` (`key`, `value`, `title_fa`, `can_edit`, `is_active`, `description`)
SELECT 'sell_fee', '500000', 'سود فروش نمایش', 1, 1, NULL
WHERE NOT EXISTS (SELECT 1 FROM `settings` WHERE `key` = 'sell_fee' LIMIT 1);
INSERT INTO `settings` (`key`, `value`, `title_fa`, `can_edit`, `is_active`, `description`)
SELECT 'fee_cash', '500000', 'اختلاف ریالی سفارش (legacy)', 1, 1, 'zaarbox/main از buy_fee هم استفاده می‌شود'
WHERE NOT EXISTS (SELECT 1 FROM `settings` WHERE `key` = 'fee_cash' LIMIT 1);
INSERT INTO `settings` (`key`, `value`, `title_fa`, `can_edit`, `is_active`, `description`)
SELECT 'fee_service_charge_percentage', '0.005', 'درصد کارمزد سفارش', 1, 1, NULL
WHERE NOT EXISTS (SELECT 1 FROM `settings` WHERE `key` = 'fee_service_charge_percentage' LIMIT 1);
-- -----------------------------------------------------------------------------
-- Jibit — settings
-- -----------------------------------------------------------------------------
INSERT INTO `settings` (`key`, `value`, `title_fa`, `can_edit`, `is_active`, `description`)
SELECT 'jibit_verification', 'false', 'تأیید کارت بانکی با جیبیت', 1, 1, 'true/false'
WHERE NOT EXISTS (SELECT 1 FROM `settings` WHERE `key` = 'jibit_verification' LIMIT 1);
INSERT INTO `settings` (`key`, `value`, `title_fa`, `can_edit`, `is_active`, `description`)
SELECT 'register_jibit_verify', 'false', 'تأیید کدملی/موبایل در ثبت‌نام', 1, 1, 'true/false'
WHERE NOT EXISTS (SELECT 1 FROM `settings` WHERE `key` = 'register_jibit_verify' LIMIT 1);
-- -----------------------------------------------------------------------------
-- ساعات بسته بودن قیمت
-- -----------------------------------------------------------------------------
INSERT INTO `settings` (`key`, `value`, `title_fa`, `can_edit`, `is_active`, `description`)
SELECT 'close_price', 'false', 'بستن قیمت در بازه زمانی', 1, 1, NULL
WHERE NOT EXISTS (SELECT 1 FROM `settings` WHERE `key` = 'close_price' LIMIT 1);
INSERT INTO `settings` (`key`, `value`, `title_fa`, `can_edit`, `is_active`, `description`)
SELECT 'startDay', '10:00', 'شروع بازه معامله', 1, 1, NULL
WHERE NOT EXISTS (SELECT 1 FROM `settings` WHERE `key` = 'startDay' LIMIT 1);
INSERT INTO `settings` (`key`, `value`, `title_fa`, `can_edit`, `is_active`, `description`)
SELECT 'endDay', '20:30', 'پایان بازه معامله', 1, 1, NULL
WHERE NOT EXISTS (SELECT 1 FROM `settings` WHERE `key` = 'endDay' LIMIT 1);
-- -----------------------------------------------------------------------------
-- const — شمارنده و موارد پرکاربرد (جدول const یا cnt)
-- -----------------------------------------------------------------------------
INSERT INTO `const` (`key`, `value`, `title_fa`)
SELECT 'jibit_counter', '0', 'شمارنده درخواست جیبیت'
WHERE NOT EXISTS (SELECT 1 FROM `const` WHERE `key` = 'jibit_counter' LIMIT 1);
INSERT INTO `const` (`key`, `value`, `title_fa`)
SELECT 'main_product', '13', 'محصول آبشده (پشتیبان settings)'
WHERE NOT EXISTS (SELECT 1 FROM `const` WHERE `key` = 'main_product' LIMIT 1);
INSERT INTO `const` (`key`, `value`, `title_fa`)
SELECT 'limited_price', '0', 'سقف واریز اولیه'
WHERE NOT EXISTS (SELECT 1 FROM `const` WHERE `key` = 'limited_price' LIMIT 1);
INSERT INTO `const` (`key`, `value`, `title_fa`)
SELECT 'liman', '', 'توکن لیمان (legacy const)'
WHERE NOT EXISTS (SELECT 1 FROM `const` WHERE `key` = 'liman' LIMIT 1);
INSERT INTO `const` (`key`, `value`, `title_fa`)
SELECT 'liman_diff', '0', 'اختلاف لیمان'
WHERE NOT EXISTS (SELECT 1 FROM `const` WHERE `key` = 'liman_diff' LIMIT 1);
INSERT INTO `const` (`key`, `value`, `title_fa`)
SELECT 'liman_price', '0', 'قیمت گرم لیمان'
WHERE NOT EXISTS (SELECT 1 FROM `const` WHERE `key` = 'liman_price' LIMIT 1);
INSERT INTO `const` (`key`, `value`, `title_fa`)
SELECT 'liman_mazaneh', '0', 'مظنه لیمان'
WHERE NOT EXISTS (SELECT 1 FROM `const` WHERE `key` = 'liman_mazaneh' LIMIT 1);
INSERT INTO `const` (`key`, `value`, `title_fa`)
SELECT 'liman_truly_buy_mazaneh', '0', 'مظنه خرید واقعی لیمان'
WHERE NOT EXISTS (SELECT 1 FROM `const` WHERE `key` = 'liman_truly_buy_mazaneh' LIMIT 1);
INSERT INTO `const` (`key`, `value`, `title_fa`)
SELECT 'liman_truly_sell_mazaneh', '0', 'مظنه فروش واقعی لیمان'
WHERE NOT EXISTS (SELECT 1 FROM `const` WHERE `key` = 'liman_truly_sell_mazaneh' LIMIT 1);
INSERT INTO `const` (`key`, `value`, `title_fa`)
SELECT 'log', '{}', 'لاگ محصول لیمان'
WHERE NOT EXISTS (SELECT 1 FROM `const` WHERE `key` = 'log' LIMIT 1);
INSERT INTO `const` (`key`, `value`, `title_fa`)
SELECT 'liman_closed', 'false', 'بسته بودن لیمان'
WHERE NOT EXISTS (SELECT 1 FROM `const` WHERE `key` = 'liman_closed' LIMIT 1);
INSERT INTO `const` (`key`, `value`, `title_fa`)
SELECT 'liman_order_response', 'null', 'پاسخ سفارش لیمان'
WHERE NOT EXISTS (SELECT 1 FROM `const` WHERE `key` = 'liman_order_response' LIMIT 1);
INSERT INTO `const` (`key`, `value`, `title_fa`)
SELECT 'liman_password', '', 'رمز لیمان'
WHERE NOT EXISTS (SELECT 1 FROM `const` WHERE `key` = 'liman_password' LIMIT 1);
INSERT INTO `const` (`key`, `value`, `title_fa`)
SELECT 'liman_mobile', '', 'موبایل لیمان'
WHERE NOT EXISTS (SELECT 1 FROM `const` WHERE `key` = 'liman_mobile' LIMIT 1);
INSERT INTO `const` (`key`, `value`, `title_fa`)
SELECT 'liman_open_buy', 'true', 'باز بودن خرید لیمان'
WHERE NOT EXISTS (SELECT 1 FROM `const` WHERE `key` = 'liman_open_buy' LIMIT 1);
INSERT INTO `const` (`key`, `value`, `title_fa`)
SELECT 'liman_open_sell', 'true', 'باز بودن فروش لیمان'
WHERE NOT EXISTS (SELECT 1 FROM `const` WHERE `key` = 'liman_open_sell' LIMIT 1);
INSERT INTO `const` (`key`, `value`, `title_fa`)
SELECT 'app_closed', 'false', 'بسته بودن اپ'
WHERE NOT EXISTS (SELECT 1 FROM `const` WHERE `key` = 'app_closed' LIMIT 1);
INSERT INTO `const` (`key`, `value`, `title_fa`)
SELECT 'last_order_log', '', 'آخرین پاسخ سفارش (legacy)'
WHERE NOT EXISTS (SELECT 1 FROM `const` WHERE `key` = 'last_order_log' LIMIT 1);
-- -----------------------------------------------------------------------------
-- settings — کلیدهای legacy (کنار montzar_*)
-- -----------------------------------------------------------------------------
INSERT INTO `settings` (`key`, `value`, `title_fa`, `can_edit`, `is_active`, `description`, `type`)
SELECT 'liman_password', '', 'رمز لیمان (legacy)', 1, 1, NULL, 'text'
WHERE NOT EXISTS (SELECT 1 FROM `settings` WHERE `key` = 'liman_password' LIMIT 1);
INSERT INTO `settings` (`key`, `value`, `title_fa`, `can_edit`, `is_active`, `description`, `type`)
SELECT 'liman_mobile', '', 'موبایل لیمان (legacy)', 1, 1, NULL, 'text'
WHERE NOT EXISTS (SELECT 1 FROM `settings` WHERE `key` = 'liman_mobile' LIMIT 1);
INSERT INTO `settings` (`key`, `value`, `title_fa`, `can_edit`, `is_active`, `description`, `type`)
SELECT 'do_send_liman', 'false', 'ارسال سفارش به لیمان (legacy)', 1, 1, NULL, 'switch'
WHERE NOT EXISTS (SELECT 1 FROM `settings` WHERE `key` = 'do_send_liman' LIMIT 1);
INSERT INTO `settings` (`key`, `value`, `title_fa`, `can_edit`, `is_active`, `description`, `type`)
SELECT 'price_liman', 'false', 'دریافت قیمت از لیمان (legacy)', 1, 1, NULL, 'switch'
WHERE NOT EXISTS (SELECT 1 FROM `settings` WHERE `key` = 'price_liman' LIMIT 1);
INSERT INTO `settings` (`key`, `value`, `title_fa`, `can_edit`, `is_active`, `description`, `type`)
SELECT 'montzar_order_response', '[]', 'پاسخ سفارش همکار', 0, 1, NULL, 'longtext'
WHERE NOT EXISTS (SELECT 1 FROM `settings` WHERE `key` = 'montzar_order_response' LIMIT 1);
INSERT INTO `settings` (`key`, `value`, `title_fa`, `can_edit`, `is_active`, `description`, `type`)
SELECT 'montzar_last_product_log', '{}', 'لاگ محصول همکار', 0, 1, NULL, 'longtext'
WHERE NOT EXISTS (SELECT 1 FROM `settings` WHERE `key` = 'montzar_last_product_log' LIMIT 1);
-- -----------------------------------------------------------------------------
-- const پر شده → settings خالی (مهاجرت؛ value پر overwrite نمی‌شود)
-- -----------------------------------------------------------------------------
UPDATE `settings` s
INNER JOIN `const` c ON c.`key` = 'liman'
SET s.`value` = c.`value`, s.`updated_at` = NOW()
WHERE s.`key` IN ('montzar_token', 'liman_token')
AND (s.`value` IS NULL OR TRIM(s.`value`) = '');
UPDATE `settings` s
INNER JOIN `const` c ON c.`key` = 'liman_diff'
SET s.`value` = c.`value`, s.`updated_at` = NOW()
WHERE s.`key` = 'montzar_diff'
AND (s.`value` IS NULL OR TRIM(s.`value`) = '' OR s.`value` = '0');
UPDATE `settings` s
INNER JOIN `const` c ON c.`key` = 'liman_price'
SET s.`value` = c.`value`, s.`updated_at` = NOW()
WHERE s.`key` = 'montzar_live_price'
AND (s.`value` IS NULL OR TRIM(s.`value`) = '' OR s.`value` = '0');
UPDATE `settings` s
INNER JOIN `const` c ON c.`key` = 'liman_mazaneh'
SET s.`value` = c.`value`, s.`updated_at` = NOW()
WHERE s.`key` = 'montzar_mazaneh'
AND (s.`value` IS NULL OR TRIM(s.`value`) = '' OR s.`value` = '0');
UPDATE `settings` s
INNER JOIN `const` c ON c.`key` = 'liman_truly_buy_mazaneh'
SET s.`value` = c.`value`, s.`updated_at` = NOW()
WHERE s.`key` = 'montzar_truly_buy_mazaneh'
AND (s.`value` IS NULL OR TRIM(s.`value`) = '' OR s.`value` = '0');
UPDATE `settings` s
INNER JOIN `const` c ON c.`key` = 'liman_truly_sell_mazaneh'
SET s.`value` = c.`value`, s.`updated_at` = NOW()
WHERE s.`key` = 'montzar_truly_sell_mazaneh'
AND (s.`value` IS NULL OR TRIM(s.`value`) = '' OR s.`value` = '0');
UPDATE `settings` s
INNER JOIN `const` c ON c.`key` = 'log'
SET s.`value` = c.`value`, s.`updated_at` = NOW()
WHERE s.`key` = 'montzar_last_product_log'
AND (s.`value` IS NULL OR TRIM(s.`value`) = '' OR s.`value` = '{}');
UPDATE `settings` s
INNER JOIN `const` c ON c.`key` = 'liman_closed'
SET s.`value` = c.`value`, s.`updated_at` = NOW()
WHERE s.`key` = 'montzar_closed'
AND (s.`value` IS NULL OR TRIM(s.`value`) = '');
UPDATE `settings` s
INNER JOIN `const` c ON c.`key` = 'liman_order_response'
SET s.`value` = c.`value`, s.`updated_at` = NOW()
WHERE s.`key` = 'montzar_order_response'
AND (s.`value` IS NULL OR TRIM(s.`value`) = '' OR s.`value` = '[]');
UPDATE `settings` s
INNER JOIN `const` c ON c.`key` = 'liman_password'
SET s.`value` = c.`value`, s.`updated_at` = NOW()
WHERE s.`key` IN ('montzar_password', 'liman_password')
AND (s.`value` IS NULL OR TRIM(s.`value`) = '');
UPDATE `settings` s
INNER JOIN `const` c ON c.`key` = 'liman_mobile'
SET s.`value` = c.`value`, s.`updated_at` = NOW()
WHERE s.`key` IN ('montzar_mobile', 'liman_mobile')
AND (s.`value` IS NULL OR TRIM(s.`value`) = '');
UPDATE `settings` s
INNER JOIN `const` c ON c.`key` = 'liman_open_buy'
SET s.`value` = c.`value`, s.`updated_at` = NOW()
WHERE s.`key` = 'montzar_open_buy'
AND (s.`value` IS NULL OR TRIM(s.`value`) = '');
UPDATE `settings` s
INNER JOIN `const` c ON c.`key` = 'liman_open_sell'
SET s.`value` = c.`value`, s.`updated_at` = NOW()
WHERE s.`key` = 'montzar_open_sell'
AND (s.`value` IS NULL OR TRIM(s.`value`) = '');
UPDATE `settings` s
INNER JOIN `const` c ON c.`key` = 'main_product'
SET s.`value` = c.`value`, s.`updated_at` = NOW()
WHERE s.`key` = 'main_product'
AND (s.`value` IS NULL OR TRIM(s.`value`) = '');
-- -----------------------------------------------------------------------------
-- API خارجی Node (HMAC) — NODE_CLIENT_ID / NODE_SHARED_SECRET
-- -----------------------------------------------------------------------------
INSERT INTO `settings` (`key`, `value`, `title_fa`, `can_edit`, `is_active`, `description`)
SELECT 'node_client_id', '', 'شناسه کلاینت API خارجی (X-Client-Id)', 1, 1, 'fallback: .env NODE_CLIENT_ID'
WHERE NOT EXISTS (SELECT 1 FROM `settings` WHERE `key` = 'node_client_id' LIMIT 1);
INSERT INTO `settings` (`key`, `value`, `title_fa`, `can_edit`, `is_active`, `description`)
SELECT 'node_shared_secret', '', 'کلید امضای HMAC API خارجی', 1, 1, 'fallback: .env NODE_SHARED_SECRET'
WHERE NOT EXISTS (SELECT 1 FROM `settings` WHERE `key` = 'node_shared_secret' LIMIT 1);
INSERT INTO `settings` (`key`, `value`, `title_fa`, `can_edit`, `is_active`, `description`)
SELECT 'external_order_api_enabled', 'false', 'API سفارش خارجی (get_wallet / order)', 1, 1, NULL
WHERE NOT EXISTS (SELECT 1 FROM `settings` WHERE `key` = 'external_order_api_enabled' LIMIT 1);
-- -----------------------------------------------------------------------------
-- title_fa + type (value دست نخورده) — همه کلیدهای modular + legacy
-- -----------------------------------------------------------------------------
UPDATE `settings` SET `title_fa` = 'نام فارسی', `type` = 'text', `is_active` = COALESCE(`is_active`, 1) WHERE `key` = 'name_fa';
UPDATE `settings` SET `title_fa` = 'نام انگلیسی', `type` = 'text', `is_active` = COALESCE(`is_active`, 1) WHERE `key` = 'name_en';
UPDATE `settings` SET `title_fa` = 'آدرس اپ (کاربر)', `type` = 'text', `is_active` = COALESCE(`is_active`, 1) WHERE `key` = 'app_url';
UPDATE `settings` SET `title_fa` = 'آدرس پایه سرور', `type` = 'text', `is_active` = COALESCE(`is_active`, 1) WHERE `key` = 'bace_url';
UPDATE `settings` SET `title_fa` = 'لوگوی ورود', `type` = 'text', `is_active` = COALESCE(`is_active`, 1) WHERE `key` = 'logo_login';
UPDATE `settings` SET `title_fa` = 'لوگوی ثبت‌نام', `type` = 'text', `is_active` = COALESCE(`is_active`, 1) WHERE `key` = 'logo_register';
UPDATE `settings` SET `title_fa` = 'آدرس پنل ادمین', `type` = 'text', `is_active` = COALESCE(`is_active`, 1) WHERE `key` = 'admin_url';
UPDATE `settings` SET `title_fa` = 'عنوان PWA', `type` = 'text', `is_active` = COALESCE(`is_active`, 1) WHERE `key` = 'title_pwa';
UPDATE `settings` SET `title_fa` = 'عنوان favicon', `type` = 'text', `is_active` = COALESCE(`is_active`, 1) WHERE `key` = 'title_fav';
UPDATE `settings` SET `title_fa` = 'متن قوانین', `type` = 'longtext', `is_active` = COALESCE(`is_active`, 1) WHERE `key` = 'text_rule';
UPDATE `settings` SET `title_fa` = 'متن درباره ما', `type` = 'longtext', `is_active` = COALESCE(`is_active`, 1) WHERE `key` = 'text_about';
UPDATE `settings` SET `title_fa` = 'نوع فلز', `type` = 'text', `is_active` = COALESCE(`is_active`, 1) WHERE `key` = 'metal_type';
UPDATE `settings` SET `title_fa` = 'توکن ته‌حساب', `type` = 'text', `is_active` = COALESCE(`is_active`, 1), `can_edit` = 0 WHERE `key` = 'tahesab_token';
UPDATE `settings` SET `title_fa` = 'دیتابیس ته‌حساب', `type` = 'text', `is_active` = COALESCE(`is_active`, 1), `can_edit` = 0 WHERE `key` = 'tahesab_db';
UPDATE `settings` SET `title_fa` = 'حساب بانکی ته‌حساب', `type` = 'text', `is_active` = COALESCE(`is_active`, 1), `can_edit` = 0 WHERE `key` = 'tahesab_bank_account';
UPDATE `settings` SET `title_fa` = 'صفحه کسب درآمد', `type` = 'switch', `is_active` = COALESCE(`is_active`, 1) WHERE `key` = 'has_page_earn_money';
UPDATE `settings` SET `title_fa` = 'صفحه صندوق', `type` = 'switch', `is_active` = COALESCE(`is_active`, 1) WHERE `key` = 'has_page_fund';
UPDATE `settings` SET `title_fa` = 'صفحه مجوزها', `type` = 'switch', `is_active` = COALESCE(`is_active`, 1) WHERE `key` = 'has_page_permission';
UPDATE `settings` SET `title_fa` = 'صفحه هشدار قیمت', `type` = 'switch', `is_active` = COALESCE(`is_active`, 1) WHERE `key` = 'has_page_price_trigger';
UPDATE `settings` SET `title_fa` = 'صفحه طلای فیزیکی', `type` = 'switch', `is_active` = COALESCE(`is_active`, 1) WHERE `key` = 'has_page_physical_gold';
UPDATE `settings` SET `title_fa` = 'رنگ اصلی', `type` = 'text', `is_active` = COALESCE(`is_active`, 1) WHERE `key` = 'color_primary';
UPDATE `settings` SET `title_fa` = 'رنگ ثانویه', `type` = 'text', `is_active` = COALESCE(`is_active`, 1) WHERE `key` = 'color_secondary';
UPDATE `settings` SET `title_fa` = 'چت', `type` = 'switch', `is_active` = COALESCE(`is_active`, 1) WHERE `key` = 'has_chat';
UPDATE `settings` SET `title_fa` = 'آدرس API سرور', `type` = 'text', `is_active` = COALESCE(`is_active`, 1) WHERE `key` = 'server_url';
UPDATE `settings` SET `title_fa` = 'کلید اپ', `type` = 'text', `is_active` = COALESCE(`is_active`, 1) WHERE `key` = 'key';
UPDATE `settings` SET `title_fa` = 'توکن بات تلگرام', `type` = 'text', `is_active` = COALESCE(`is_active`, 1), `can_edit` = 0 WHERE `key` = 'telegram_bot_token';
UPDATE `settings` SET `title_fa` = 'توکن بات بله', `type` = 'text', `is_active` = COALESCE(`is_active`, 1), `can_edit` = 0 WHERE `key` = 'bale_bot_token';
UPDATE `settings` SET `title_fa` = 'پیامک شارژ ادمین', `type` = 'switch', `is_active` = COALESCE(`is_active`, 1) WHERE `key` = 'charge_notif';
UPDATE `settings` SET `title_fa` = 'پیامک گروهی', `type` = 'switch', `is_active` = COALESCE(`is_active`, 1) WHERE `key` = 'group_sms';
UPDATE `settings` SET `title_fa` = 'فعال‌سازی خودکار کاربر', `type` = 'switch', `is_active` = COALESCE(`is_active`, 1) WHERE `key` = 'auto_active_customer';
UPDATE `settings` SET `title_fa` = 'ثبت‌نام باز', `type` = 'switch', `is_active` = COALESCE(`is_active`, 1) WHERE `key` = 'open_register';
UPDATE `settings` SET `title_fa` = 'ارسال اسناد به ته‌حساب', `type` = 'switch', `is_active` = COALESCE(`is_active`, 1) WHERE `key` = 'send_to_tahesab';
UPDATE `settings` SET `title_fa` = 'کد معرف اجباری (legacy)', `type` = 'switch', `is_active` = COALESCE(`is_active`, 1) WHERE `key` = 'is_requaire_referral';
UPDATE `settings` SET `title_fa` = 'کد معرف', `type` = 'select', `is_active` = COALESCE(`is_active`, 1), `description` = 'required = اجباری|required,' WHERE `key` = 'referral_id';
UPDATE `settings` SET `title_fa` = 'محدودیت دعوت', `type` = 'number', `is_active` = COALESCE(`is_active`, 0) WHERE `key` = 'referral_limit';
UPDATE `settings` SET `title_fa` = 'پاداش معرف', `type` = 'number', `is_active` = COALESCE(`is_active`, 1) WHERE `key` = 'gift_for_referrer';
UPDATE `settings` SET `title_fa` = 'پاداش معرفی‌شده', `type` = 'number', `is_active` = COALESCE(`is_active`, 1) WHERE `key` = 'gift_for_referral';
UPDATE `settings` SET `title_fa` = 'حداقل برداشت', `type` = 'number', `is_active` = COALESCE(`is_active`, 1) WHERE `key` = 'min_withdraw';
UPDATE `settings` SET `title_fa` = 'حداقل اولین خرید', `type` = 'number', `is_active` = COALESCE(`is_active`, 1) WHERE `key` = 'min_first_buy';
UPDATE `settings` SET `title_fa` = 'حداقل فروش', `type` = 'number', `is_active` = COALESCE(`is_active`, 1) WHERE `key` = 'minimum_sell';
UPDATE `settings` SET `title_fa` = 'کارمزد رایگان (تعداد)', `type` = 'number', `is_active` = COALESCE(`is_active`, 1) WHERE `key` = 'fee_free';
UPDATE `settings` SET `title_fa` = 'کارمزد درصدی (legacy)', `type` = 'number', `is_active` = COALESCE(`is_active`, 1) WHERE `key` = 'fee';
UPDATE `settings` SET `title_fa` = 'کارمزد درصدی', `type` = 'number', `is_active` = COALESCE(`is_active`, 1) WHERE `key` = 'fee_service_charge_percentage';
UPDATE `settings` SET `title_fa` = 'کارمزد درصدی (alias)', `type` = 'number', `is_active` = COALESCE(`is_active`, 1) WHERE `key` = 'service_charge_percentage';
UPDATE `settings` SET `title_fa` = 'کارمزد ریالی', `type` = 'number', `is_active` = COALESCE(`is_active`, 1) WHERE `key` = 'fee_cash';
UPDATE `settings` SET `title_fa` = 'اختلاف با قیمت واقعی', `type` = 'number', `is_active` = COALESCE(`is_active`, 1) WHERE `key` = 'fee_single';
UPDATE `settings` SET `title_fa` = 'سود خرید', `type` = 'number', `is_active` = COALESCE(`is_active`, 1) WHERE `key` = 'buy_fee';
UPDATE `settings` SET `title_fa` = 'سود فروش', `type` = 'number', `is_active` = COALESCE(`is_active`, 1) WHERE `key` = 'sell_fee';
UPDATE `settings` SET `title_fa` = 'منبع قیمت', `type` = 'select', `is_active` = COALESCE(`is_active`, 1), `can_edit` = 1, `description` = 'montzar,zaarbox,main_product,etehadie,taban_gohar' WHERE `key` = 'price_provider';
UPDATE `settings` SET `title_fa` = 'منبع قیمت (legacy)', `type` = 'text', `is_active` = COALESCE(`is_active`, 1) WHERE `key` = 'price_primary_source';
UPDATE `settings` SET `title_fa` = 'محصول آبشده', `type` = 'text', `is_active` = COALESCE(`is_active`, 1), `can_edit` = 1 WHERE `key` = 'main_product';
UPDATE `settings` SET `title_fa` = 'آدرس API Zaarbox', `type` = 'text', `is_active` = COALESCE(`is_active`, 1), `can_edit` = 1 WHERE `key` = 'zaarbox_api_url';
UPDATE `settings` SET `title_fa` = 'شناسه ردیف Zaarbox', `type` = 'text', `is_active` = COALESCE(`is_active`, 1), `can_edit` = 1 WHERE `key` = 'zaarbox_price_key';
UPDATE `settings` SET `title_fa` = 'UUID نمودار Zaarbox', `type` = 'text', `is_active` = COALESCE(`is_active`, 1), `can_edit` = 1 WHERE `key` = 'chart_id';
UPDATE `settings` SET `title_fa` = 'آدرس API اتحادیه', `type` = 'text', `is_active` = COALESCE(`is_active`, 1) WHERE `key` = 'etehadie_api_url';
UPDATE `settings` SET `title_fa` = 'دریافت قیمت از محصولات', `type` = 'switch', `is_active` = COALESCE(`is_active`, 1) WHERE `key` = 'main_product_price';
UPDATE `settings` SET `title_fa` = 'دریافت قیمت تابان‌گوهر', `type` = 'switch', `is_active` = COALESCE(`is_active`, 1) WHERE `key` = 'tabanGohar_price';
UPDATE `settings` SET `title_fa` = 'نشان دادن آخرین قیمت', `type` = 'switch', `is_active` = COALESCE(`is_active`, 1) WHERE `key` = 'show_last_price';
UPDATE `settings` SET `title_fa` = 'بستن قیمت در ساعات مشخص', `type` = 'switch', `is_active` = COALESCE(`is_active`, 1) WHERE `key` = 'close_price';
UPDATE `settings` SET `title_fa` = 'ساعت شروع', `type` = 'text', `is_active` = COALESCE(`is_active`, 1) WHERE `key` = 'startDay';
UPDATE `settings` SET `title_fa` = 'ساعت پایان', `type` = 'text', `is_active` = COALESCE(`is_active`, 1) WHERE `key` = 'endDay';
UPDATE `settings` SET `title_fa` = 'بیشترین قیمت امروز', `type` = 'number', `is_active` = COALESCE(`is_active`, 1), `can_edit` = 0 WHERE `key` = 'up_price';
UPDATE `settings` SET `title_fa` = 'کمترین قیمت امروز', `type` = 'number', `is_active` = COALESCE(`is_active`, 1), `can_edit` = 0 WHERE `key` = 'down_price';
UPDATE `settings` SET `title_fa` = 'تاریخ min/max روز', `type` = 'text', `is_active` = COALESCE(`is_active`, 1), `can_edit` = 0 WHERE `key` = 'price_extreme_date';
UPDATE `settings` SET `title_fa` = 'دریافت قیمت از همکار', `type` = 'switch', `is_active` = COALESCE(`is_active`, 1) WHERE `key` = 'montzar_price';
UPDATE `settings` SET `title_fa` = 'نمایش بلوک همکار', `type` = 'switch', `is_active` = COALESCE(`is_active`, 1) WHERE `key` = 'display_montzar';
UPDATE `settings` SET `title_fa` = 'شماره همراه همکار', `type` = 'text', `is_active` = COALESCE(`is_active`, 1) WHERE `key` = 'montzar_mobile';
UPDATE `settings` SET `title_fa` = 'کلمه عبور همکار', `type` = 'text', `is_active` = COALESCE(`is_active`, 1) WHERE `key` = 'montzar_password';
UPDATE `settings` SET `title_fa` = 'کد محصول همکار', `type` = 'number', `is_active` = COALESCE(`is_active`, 1) WHERE `key` = 'montzar_product_id';
UPDATE `settings` SET `title_fa` = 'آدرس API همکار', `type` = 'text', `is_active` = COALESCE(`is_active`, 1), `can_edit` = 0 WHERE `key` = 'montzar_base_url';
UPDATE `settings` SET `title_fa` = 'توکن همکار', `type` = 'text', `is_active` = COALESCE(`is_active`, 1), `can_edit` = 0 WHERE `key` = 'montzar_token';
UPDATE `settings` SET `title_fa` = 'بسته بودن سرویس همکار', `type` = 'switch', `is_active` = COALESCE(`is_active`, 1), `can_edit` = 0 WHERE `key` = 'montzar_closed';
UPDATE `settings` SET `title_fa` = 'باز بودن خرید همکار', `type` = 'switch', `is_active` = COALESCE(`is_active`, 1), `can_edit` = 0 WHERE `key` = 'montzar_open_buy';
UPDATE `settings` SET `title_fa` = 'باز بودن فروش همکار', `type` = 'switch', `is_active` = COALESCE(`is_active`, 1), `can_edit` = 0 WHERE `key` = 'montzar_open_sell';
UPDATE `settings` SET `title_fa` = 'اختلاف قیمت همکار', `type` = 'text', `is_active` = COALESCE(`is_active`, 1), `can_edit` = 0 WHERE `key` = 'montzar_diff';
UPDATE `settings` SET `title_fa` = 'قیمت لحظه‌ای همکار', `type` = 'text', `is_active` = COALESCE(`is_active`, 1), `can_edit` = 0 WHERE `key` = 'montzar_live_price';
UPDATE `settings` SET `title_fa` = 'مظنه همکار', `type` = 'text', `is_active` = COALESCE(`is_active`, 1), `can_edit` = 0 WHERE `key` = 'montzar_mazaneh';
UPDATE `settings` SET `title_fa` = 'مظنه خرید واقعی همکار', `type` = 'text', `is_active` = COALESCE(`is_active`, 1), `can_edit` = 0 WHERE `key` = 'montzar_truly_buy_mazaneh';
UPDATE `settings` SET `title_fa` = 'مظنه فروش واقعی همکار', `type` = 'text', `is_active` = COALESCE(`is_active`, 1), `can_edit` = 0 WHERE `key` = 'montzar_truly_sell_mazaneh';
UPDATE `settings` SET `title_fa` = 'پاسخ سفارش همکار', `type` = 'longtext', `is_active` = COALESCE(`is_active`, 1), `can_edit` = 0 WHERE `key` = 'montzar_order_response';
UPDATE `settings` SET `title_fa` = 'لاگ محصول همکار', `type` = 'longtext', `is_active` = COALESCE(`is_active`, 1), `can_edit` = 0 WHERE `key` = 'montzar_last_product_log';
UPDATE `settings` SET `title_fa` = 'توکن لیمان (legacy)', `type` = 'text', `is_active` = COALESCE(`is_active`, 1) WHERE `key` = 'liman_token';
UPDATE `settings` SET `title_fa` = 'رمز لیمان (legacy)', `type` = 'text', `is_active` = COALESCE(`is_active`, 1) WHERE `key` = 'liman_password';
UPDATE `settings` SET `title_fa` = 'موبایل لیمان (legacy)', `type` = 'text', `is_active` = COALESCE(`is_active`, 1) WHERE `key` = 'liman_mobile';
UPDATE `settings` SET `title_fa` = 'ارسال سفارش به لیمان', `type` = 'switch', `is_active` = COALESCE(`is_active`, 1) WHERE `key` = 'do_send_liman';
UPDATE `settings` SET `title_fa` = 'دریافت قیمت از لیمان', `type` = 'switch', `is_active` = COALESCE(`is_active`, 1) WHERE `key` = 'price_liman';
UPDATE `settings` SET `title_fa` = 'تأیید کارت با جیبیت', `type` = 'switch', `is_active` = COALESCE(`is_active`, 1) WHERE `key` = 'jibit_verification';
UPDATE `settings` SET `title_fa` = 'تأیید کد ملی در ثبت‌نام', `type` = 'switch', `is_active` = COALESCE(`is_active`, 1) WHERE `key` = 'register_jibit_verify';
UPDATE `settings` SET `title_fa` = 'بروزرسانی قیمت در لیست', `type` = 'switch', `is_active` = COALESCE(`is_active`, 1) WHERE `key` = 'product_update_price_on_list';
UPDATE `settings` SET `title_fa` = 'باز/بسته خودکار محصول در لیست', `type` = 'switch', `is_active` = COALESCE(`is_active`, 1) WHERE `key` = 'product_auto_close_open_on_list';
UPDATE `settings` SET `title_fa` = 'شناسه کلاینت API خارجی', `type` = 'text', `is_active` = COALESCE(`is_active`, 1) WHERE `key` = 'node_client_id';
UPDATE `settings` SET `title_fa` = 'کلید HMAC API خارجی', `type` = 'text', `is_active` = COALESCE(`is_active`, 1) WHERE `key` = 'node_shared_secret';
UPDATE `settings` SET `title_fa` = 'API سفارش خارجی', `type` = 'switch', `is_active` = COALESCE(`is_active`, 1) WHERE `key` = 'external_order_api_enabled';
UPDATE `settings` SET `title_fa` = 'پیام‌رسان پشتیبانی', `type` = 'select', `is_active` = COALESCE(`is_active`, 1), `description` = 'bale,telegram,whatsapp,rubika,eitaa,soroush' WHERE `key` = 'support_messenger';
UPDATE `settings` SET `title_fa` = 'شناسه پشتیبانی', `type` = 'text', `is_active` = COALESCE(`is_active`, 1) WHERE `key` = 'support_messenger_id';
UPDATE `settings` SET `title_fa` = 'متن پشتیبانی', `type` = 'text', `is_active` = COALESCE(`is_active`, 1) WHERE `key` = 'support_messenger_text';
UPDATE `settings` SET `title_fa` = 'نام Montify', `type` = 'text', `is_active` = COALESCE(`is_active`, 1) WHERE `key` = 'montify_name';
UPDATE `settings` SET `title_fa` = 'API سود طلا', `type` = 'switch', `is_active` = COALESCE(`is_active`, 0) WHERE `key` = 'profit_gold_api_enabled';
-- const — عنوان فارسی
UPDATE `const` SET `title_fa` = 'شمارنده جیبیت' WHERE `key` = 'jibit_counter' AND (`title_fa` IS NULL OR TRIM(`title_fa`) = '');
UPDATE `const` SET `title_fa` = 'محصول آبشده (fallback)' WHERE `key` = 'main_product' AND (`title_fa` IS NULL OR TRIM(`title_fa`) = '');
UPDATE `const` SET `title_fa` = 'سقف واریز اولیه' WHERE `key` = 'limited_price' AND (`title_fa` IS NULL OR TRIM(`title_fa`) = '');
UPDATE `const` SET `title_fa` = 'توکن لیمان (legacy)' WHERE `key` = 'liman' AND (`title_fa` IS NULL OR TRIM(`title_fa`) = '');
UPDATE `const` SET `title_fa` = 'اختلاف لیمان' WHERE `key` = 'liman_diff' AND (`title_fa` IS NULL OR TRIM(`title_fa`) = '');
UPDATE `const` SET `title_fa` = 'قیمت گرم لیمان' WHERE `key` = 'liman_price' AND (`title_fa` IS NULL OR TRIM(`title_fa`) = '');
UPDATE `const` SET `title_fa` = 'مظنه لیمان' WHERE `key` = 'liman_mazaneh' AND (`title_fa` IS NULL OR TRIM(`title_fa`) = '');
UPDATE `const` SET `title_fa` = 'بسته بودن لیمان' WHERE `key` = 'liman_closed' AND (`title_fa` IS NULL OR TRIM(`title_fa`) = '');
UPDATE `const` SET `title_fa` = 'لاگ محصول لیمان' WHERE `key` = 'log' AND (`title_fa` IS NULL OR TRIM(`title_fa`) = '');
UPDATE `const` SET `title_fa` = 'بسته بودن اپ' WHERE `key` = 'app_closed' AND (`title_fa` IS NULL OR TRIM(`title_fa`) = '');
UPDATE `const` SET `title_fa` = 'لاگ آخرین سفارش' WHERE `key` = 'last_order_log' AND (`title_fa` IS NULL OR TRIM(`title_fa`) = '');
-- type پیش‌فرض برای ردیف‌های بدون type
UPDATE `settings` SET `type` = 'text' WHERE (`type` IS NULL OR TRIM(`type`) = '') AND `key` NOT IN (
'montzar_order_response', 'montzar_last_product_log', 'text_rule', 'text_about'
);
-- =============================================================================
-- products — محدودیت مبلغ سفارش (ستون‌های جدول products؛ مقدار از پنل ادمین)
-- patch: database/sql/add_product_order_limit_columns.sql
-- =============================================================================
SET @db = DATABASE();
SET @sql = IF(
(SELECT COUNT(*) FROM information_schema.COLUMNS
WHERE TABLE_SCHEMA = @db AND TABLE_NAME = 'products' AND COLUMN_NAME = 'order_limit_enabled') = 0,
'ALTER TABLE `products` ADD COLUMN `order_limit_enabled` TINYINT(1) NOT NULL DEFAULT 0 AFTER `percent_fee_buy`',
'SELECT 1'
);
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 = 'products' AND COLUMN_NAME = 'min_order_cash') = 0,
'ALTER TABLE `products` ADD COLUMN `min_order_cash` BIGINT UNSIGNED NULL DEFAULT NULL AFTER `order_limit_enabled`',
'SELECT 1'
);
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 = 'products' AND COLUMN_NAME = 'max_order_cash') = 0,
'ALTER TABLE `products` ADD COLUMN `max_order_cash` BIGINT UNSIGNED NULL DEFAULT NULL AFTER `min_order_cash`',
'SELECT 1'
);
PREPARE stmt FROM @sql;
EXECUTE stmt;
DEALLOCATE PREPARE stmt;
COMMIT;
SELECT 'bazre_tala_settings_update.sql finished' AS status;
-- بذر طلا: valueهای اختصاصی (name_fa، price_provider، montzar_* و ...) از پنل تنظیم می‌شود.
-- حذف legacy (وقتی بک‌اند قدیمی خاموش شد): goldali_cleanup_legacy_keys.sql