T-2: M0.2 — Finish shared Postgres migrations: bun run db:migrate + fresh-database schema test
This commit is contained in:
parent
654782a6a1
commit
b82fc7c905
3 changed files with 114 additions and 7 deletions
|
|
@ -60,6 +60,10 @@ export function parseDbMigrateArgs(argv: readonly string[]): DbMigrateArgs {
|
|||
return { track };
|
||||
}
|
||||
|
||||
export function loadMigrationConfig(): StockAppConfig {
|
||||
return initializeStockConfig('dataPipeline', { postgresOnly: true });
|
||||
}
|
||||
|
||||
export function resolveMigrationTarget(
|
||||
config: StockAppConfig,
|
||||
env: Record<string, string | undefined> = process.env
|
||||
|
|
@ -69,7 +73,9 @@ export function resolveMigrationTarget(
|
|||
throw new Error('PostgreSQL is disabled in the active configuration.');
|
||||
}
|
||||
|
||||
// Disable unrelated MongoDB checks so Postgres migrations only enforce PostgreSQL/environment guards.
|
||||
// Never allow the shared dev-on-QA override to bypass the PostgreSQL guard in db:migrate,
|
||||
// and disable unrelated MongoDB checks so Postgres migrations only enforce PostgreSQL/environment guards.
|
||||
const { STOCK_BOT_ALLOW_DEV_ON_QA_DB: _ignored, ...safeEnv } = env;
|
||||
assertEnvironmentSafety(
|
||||
{
|
||||
...config,
|
||||
|
|
@ -82,7 +88,7 @@ export function resolveMigrationTarget(
|
|||
},
|
||||
},
|
||||
'dataPipeline',
|
||||
env
|
||||
safeEnv
|
||||
);
|
||||
|
||||
const clientConfig: PostgreSQLClientConfig = {
|
||||
|
|
@ -108,7 +114,7 @@ export function resolveMigrationTarget(
|
|||
|
||||
async function main(argv: readonly string[]): Promise<void> {
|
||||
const { track } = parseDbMigrateArgs(argv);
|
||||
const config = initializeStockConfig('dataPipeline', { mongoReadOnly: true });
|
||||
const config = loadMigrationConfig();
|
||||
const { clientConfig, targetLabel } = resolveMigrationTarget(config, process.env);
|
||||
const logger = getLogger('db-migrate');
|
||||
const client = new PostgreSQLClient(clientConfig, logger);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue