feat: billing period for subscriptions, costs in redundancy analysis

This commit is contained in:
root
2026-07-29 23:46:58 +02:00
parent deabe36727
commit 44cc29b8fe
6 changed files with 109 additions and 14 deletions
+15
View File
@@ -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();