WIP main worktree changes before merge
This commit is contained in:
@@ -4,6 +4,10 @@ import { dirname } from 'node:path';
|
||||
import { Database } from 'bun:sqlite';
|
||||
import { drizzle } from 'drizzle-orm/bun-sqlite';
|
||||
import { migrate } from 'drizzle-orm/bun-sqlite/migrator';
|
||||
import {
|
||||
ensureFinancialIngestionSchemaHealthy,
|
||||
resolveFinancialSchemaRepairMode
|
||||
} from '../lib/server/db/financial-ingestion-schema';
|
||||
import { resolveSqlitePath } from './dev-env';
|
||||
|
||||
function trim(value: string | undefined) {
|
||||
@@ -74,6 +78,13 @@ function runDatabaseMigrations() {
|
||||
try {
|
||||
client.exec('PRAGMA foreign_keys = ON;');
|
||||
migrate(drizzle(client), { migrationsFolder: './drizzle' });
|
||||
|
||||
const repairResult = ensureFinancialIngestionSchemaHealthy(client, {
|
||||
mode: resolveFinancialSchemaRepairMode(process.env.FINANCIAL_SCHEMA_REPAIR_MODE)
|
||||
});
|
||||
if (!repairResult.ok) {
|
||||
throw new Error(repairResult.error ?? `financial ingestion schema is ${repairResult.mode}`);
|
||||
}
|
||||
} finally {
|
||||
client.close();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user