added some keys into setting

This commit is contained in:
2026-07-07 14:34:00 +03:30
parent 20a884a874
commit d2843d79a0
5 changed files with 488 additions and 3 deletions
+87
View File
@@ -0,0 +1,87 @@
-- =============================================================================
-- price_channel_settings.sql — کلیدهای «ارسال قیمت به کانال» برای نصب‌های موجود
--
-- این کلیدها در deploy_settings_const.sql هم هستند (روی هر deploy اجرا می‌شوند).
-- این فایل فقط برای افزودن سریع به یک DB موجود، بدون اجرای کل deploy، است.
--
-- قبل از اجرا: USE `نام_دیتابیس`; + بکاپ
-- idempotent — چند بار قابل اجرا (value ردیف موجود دست نمی‌خورد).
-- =============================================================================
START TRANSACTION;
SET NAMES utf8mb4 COLLATE utf8mb4_unicode_ci;
-- توکن روبیکا (توکن بله/تلگرام از قبل موجودند) — سیستمی (can_edit=0)
INSERT INTO `settings` (`key`, `value`, `title_fa`, `can_edit`, `is_active`, `description`)
SELECT 'rubika_bot_token', '', 'توکن بات روبیکا', 0, 1, NULL
WHERE NOT EXISTS (SELECT 1 FROM `settings` WHERE `key` = 'rubika_bot_token' LIMIT 1);
-- محتوا — قابل ویرایش (can_edit=1)
INSERT INTO `settings` (`key`, `value`, `title_fa`, `can_edit`, `is_active`, `description`, `type`)
SELECT 'price_channel_enabled', 'false', 'ارسال قیمت به کانال', 1, 1,
'روشن: بعد از هر تغییر قیمت، مظنه به کانال‌های پیام‌رسان انتخاب‌شده ارسال می‌شود.', 'switch'
WHERE NOT EXISTS (SELECT 1 FROM `settings` WHERE `key` = 'price_channel_enabled' LIMIT 1);
INSERT INTO `settings` (`key`, `value`, `title_fa`, `can_edit`, `is_active`, `description`, `type`)
SELECT 'price_channel_messengers', '', 'پیام‌رسان‌های ارسال قیمت', 1, 1,
'کدام پیام‌رسان‌ها قیمت بگیرند؟ با ویرگول جدا کنید. گزینه‌ها: bale,telegram,rubika', 'text'
WHERE NOT EXISTS (SELECT 1 FROM `settings` WHERE `key` = 'price_channel_messengers' LIMIT 1);
INSERT INTO `settings` (`key`, `value`, `title_fa`, `can_edit`, `is_active`, `description`, `type`)
SELECT 'price_channel_diff', '0', 'اختلاف قیمت کانال (ریال)', 1, 1,
'مبلغی که به قیمت خرید کانال اضافه و از قیمت فروش کم می‌شود (اسپرد اضافه فقط برای کانال).', 'price'
WHERE NOT EXISTS (SELECT 1 FROM `settings` WHERE `key` = 'price_channel_diff' LIMIT 1);
INSERT INTO `settings` (`key`, `value`, `title_fa`, `can_edit`, `is_active`, `description`, `type`)
SELECT 'price_channel_min_seconds', '120', 'حداقل فاصله ارسال (ثانیه)', 1, 1,
'حداقل فاصله بین دو ارسال به کانال؛ جلوی سیل پیام را می‌گیرد. صفر = هر تغییر قیمت.', 'number'
WHERE NOT EXISTS (SELECT 1 FROM `settings` WHERE `key` = 'price_channel_min_seconds' LIMIT 1);
INSERT INTO `settings` (`key`, `value`, `title_fa`, `can_edit`, `is_active`, `description`, `type`)
SELECT 'price_channel_footer_id', '', 'آیدی کانال در پیام', 1, 1,
'اگر پر باشد در انتهای پیام نمایش داده می‌شود (مثلاً یوزرنیم کانال). خالی = نمایش داده نمی‌شود.', 'text'
WHERE NOT EXISTS (SELECT 1 FROM `settings` WHERE `key` = 'price_channel_footer_id' LIMIT 1);
INSERT INTO `settings` (`key`, `value`, `title_fa`, `can_edit`, `is_active`, `description`, `type`)
SELECT 'price_channel_footer_phone', '', 'شماره تماس در پیام', 1, 1,
'اگر پر باشد در انتهای پیام نمایش داده می‌شود. خالی = نمایش داده نمی‌شود.', 'text'
WHERE NOT EXISTS (SELECT 1 FROM `settings` WHERE `key` = 'price_channel_footer_phone' LIMIT 1);
INSERT INTO `settings` (`key`, `value`, `title_fa`, `can_edit`, `is_active`, `description`, `type`)
SELECT 'price_channel_footer_link', '', 'لینک در پیام', 1, 1,
'اگر پر باشد در انتهای پیام نمایش داده می‌شود. خالی = نمایش داده نمی‌شود.', 'text'
WHERE NOT EXISTS (SELECT 1 FROM `settings` WHERE `key` = 'price_channel_footer_link' LIMIT 1);
INSERT INTO `settings` (`key`, `value`, `title_fa`, `can_edit`, `is_active`, `description`, `type`)
SELECT 'change_mesghal', '4.3318', 'وزن مثقال (گرم)', 1, 1,
'ضریب تبدیل قیمت مثقال به گرم برای نمایش خط «هر گرم» در پیام کانال.', 'number'
WHERE NOT EXISTS (SELECT 1 FROM `settings` WHERE `key` = 'change_mesghal' LIMIT 1);
-- مقصد ارسال هر پیام‌رسان (آیدی چنل/گروه) — سیستمی (can_edit=0)
INSERT INTO `settings` (`key`, `value`, `title_fa`, `can_edit`, `is_active`, `description`, `type`)
SELECT 'price_channel_bale_to', '', 'مقصد ارسال بله', 0, 1,
'آیدی چنل/گروه بله برای ارسال قیمت (چند مقصد با ویرگول).', 'text'
WHERE NOT EXISTS (SELECT 1 FROM `settings` WHERE `key` = 'price_channel_bale_to' LIMIT 1);
INSERT INTO `settings` (`key`, `value`, `title_fa`, `can_edit`, `is_active`, `description`, `type`)
SELECT 'price_channel_telegram_to', '', 'مقصد ارسال تلگرام', 0, 1,
'آیدی چنل/گروه تلگرام برای ارسال قیمت (چند مقصد با ویرگول).', 'text'
WHERE NOT EXISTS (SELECT 1 FROM `settings` WHERE `key` = 'price_channel_telegram_to' LIMIT 1);
INSERT INTO `settings` (`key`, `value`, `title_fa`, `can_edit`, `is_active`, `description`, `type`)
SELECT 'price_channel_rubika_to', '', 'مقصد ارسال روبیکا', 0, 1,
'آیدی چنل/گروه روبیکا برای ارسال قیمت (چند مقصد با ویرگول).', 'text'
WHERE NOT EXISTS (SELECT 1 FROM `settings` WHERE `key` = 'price_channel_rubika_to' LIMIT 1);
-- استانداردسازی can_edit
UPDATE `settings` SET `can_edit` = 0 WHERE `key` IN (
'rubika_bot_token',
'price_channel_bale_to', 'price_channel_telegram_to', 'price_channel_rubika_to'
);
UPDATE `settings` SET `can_edit` = 1 WHERE `key` IN (
'price_channel_enabled', 'price_channel_messengers', 'price_channel_diff',
'price_channel_min_seconds', 'price_channel_footer_id', 'price_channel_footer_phone',
'price_channel_footer_link', 'change_mesghal'
);
COMMIT;