feat: billing period for subscriptions, costs in redundancy analysis
This commit is contained in:
@@ -149,6 +149,20 @@ async function ensureVoterTokenColumn(): Promise<void> {
|
||||
}
|
||||
}
|
||||
|
||||
async function ensureBillingPeriodColumn(): Promise<void> {
|
||||
try {
|
||||
const exists = await db.execute(
|
||||
sql`SELECT EXISTS (SELECT FROM information_schema.columns WHERE table_name = 'tool_costs' AND column_name = 'billing_period')`,
|
||||
);
|
||||
const rows = exists.rows as [{ exists: boolean }];
|
||||
if (rows[0]?.exists) return;
|
||||
await db.execute(sql`ALTER TABLE "tool_costs" ADD COLUMN "billing_period" text`);
|
||||
logger.info("billing_period column added to tool_costs");
|
||||
} catch (err) {
|
||||
logger.error({ err }, "Failed to add billing_period column");
|
||||
}
|
||||
}
|
||||
|
||||
async function ensureAdminTier(): Promise<void> {
|
||||
try {
|
||||
const result = await db
|
||||
@@ -169,6 +183,7 @@ async function start(): Promise<void> {
|
||||
await ensureToolRelationsTable();
|
||||
await ensureToolCostsTable();
|
||||
await ensureVoterTokenColumn();
|
||||
await ensureBillingPeriodColumn();
|
||||
await ensureUserColumns();
|
||||
await seedAdminUser();
|
||||
await ensureAdminTier();
|
||||
|
||||
Reference in New Issue
Block a user