yiekheng fa4970a76c feat(db): add drizzle schema for all tables + initial migration
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-09 15:19:36 +08:00

30 lines
807 B
TypeScript

import { createClient, operators } from "./index.js";
const databaseUrl = process.env.DATABASE_URL;
const operatorTelegramId = process.env.SEED_OPERATOR_TELEGRAM_ID;
const operatorName = process.env.SEED_OPERATOR_NAME ?? "Operator";
if (!databaseUrl) {
console.error("DATABASE_URL not set");
process.exit(1);
}
if (!operatorTelegramId || operatorTelegramId === "0") {
console.error("SEED_OPERATOR_TELEGRAM_ID not set");
process.exit(1);
}
const { db, pool } = createClient(databaseUrl);
await db
.insert(operators)
.values({
telegramUserId: Number(operatorTelegramId),
displayName: operatorName,
role: "admin",
defaultTimezone: "Asia/Kuala_Lumpur",
})
.onConflictDoNothing();
console.log(`Seeded operator with telegram_user_id=${operatorTelegramId}`);
await pool.end();