feat: интерактивный установщик install.sh (Docker / Ubuntu, админ, БД)
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
const { query } = require('./db');
|
||||
|
||||
async function seedPromoCodes() {
|
||||
const { rows } = await query('SELECT COUNT(*)::int AS n FROM promo_codes');
|
||||
if (rows[0].n > 0) return;
|
||||
|
||||
const expires = new Date();
|
||||
expires.setDate(expires.getDate() + 30);
|
||||
|
||||
await query(
|
||||
`INSERT INTO promo_codes (code, description, discount_type, discount_value, expires_at, min_order_cents)
|
||||
VALUES
|
||||
('WELCOME10', 'Скидка 10% новым покупателям', 'percent', 10, $1, 0),
|
||||
('SALE500', 'Скидка 500 ₽ от 3000 ₽', 'fixed', 50000, $1, 300000)`,
|
||||
[expires.toISOString()]
|
||||
);
|
||||
console.log('Демо-промокоды: WELCOME10, SALE500');
|
||||
}
|
||||
|
||||
module.exports = { seedPromoCodes };
|
||||
Reference in New Issue
Block a user