sql-switch - v1.0.1
    Preparing search index...

    Function engineSwap

    • Run an engine swap from code, no terminal needed.

      Missing options are defaulted (see EngineSwapOptions) & the target side is created if it doesn't exist yet, so the minimum viable call is just a direction plus a reachable DATABASE_URL.

      Parameters

      Returns Promise<EngineSwapResult>

      A per table breakdown of what moved.

      ConfigurationError if the direction is missing/invalid or no connection string can be resolved.

      A schema or table name that doesn't match ^[a-zA-Z0-9_-]+$ is skipped & reported in skippedNames, not thrown on => aborting halfway through would leave part of a shared database migrated and files already renamed. Nothing outside those names is read or written.

      An interrupted run (SIGINT/SIGTERM) stops at the next boundary, leaves a journal in the data dir & sets aborted => run the same swap again to finish it. Nothing is deleted on the way out.

      await engineSwap({
      direction: 'up',
      onConflict: 'overwrite',
      onProgress: (line) => console.log(`[swap] ${line}`),
      });
      await engineSwap({
      direction: 'up',
      onConflict: (c) => c.schema !== 'economy', // never clobber economy
      });