launch-migration.mjs 654 B

123456
  1. import {readFile} from 'node:fs/promises';
  2. export const launchMigrationFiles=['account-security.sql','payroll-integrity.sql','payroll-cutoff.sql','account-deletion.sql'];
  3. // A legacy standalone file has BEGIN/COMMIT. Remove only its top-level wrapper so
  4. // the publisher's transaction also protects the routines installed before/after it.
  5. export function withoutTransactionWrapper(source){return source.replace(/^(?:BEGIN|COMMIT);[ \t]*\r?$/gm,'');}
  6. export async function launchMigrationSql(){return (await Promise.all(launchMigrationFiles.map(name=>readFile(new URL('../sql/'+name,import.meta.url),'utf8')))).map(withoutTransactionWrapper).join('\n');}