MigrateRepository queries the database for a MigrateService. You could stub this out to talk to a different database, or to customise how migrations are stored in postgres.

const client: PostgresClient

const migrateRepo = new MigrateRepository(client)

Hierarchy

  • MigrateRepository

Constructors

Methods

  • Performs a migration using a postgres transation. It will attempt to run the migration then COMMIT it, but if the migration throws / rejects it will ROLLBACK.

    await migrateRepo.runMigration({
    id: 'add-logs-table',
    async run(client) {
    await client.sql`
    CREATE TABLE "logs" (
    "id" serial PRIMARY KEY,
    "created" timestamp DEFAULT CURRENT_TIMESTAMP,
    ...
    );
    `
    },
    })

    Type Parameters

    • T

    Parameters

    • migration: Migration
    • logError: {
          (...data: any[]): void;
          (message?: any, ...optionalParams: any[]): void;
      } = console.error
        • (...data: any[]): void
        • Parameters

          • Rest ...data: any[]

          Returns void

        • (message?: any, ...optionalParams: any[]): void
        • Prints to stderr with newline. Multiple arguments can be passed, with the first used as the primary message and all additional used as substitution values similar to printf(3) (the arguments are all passed to util.format()).

          const code = 5;
          console.error('error #%d', code);
          // Prints: error #5, to stderr
          console.error('error', code);
          // Prints: error 5, to stderr

          If formatting elements (e.g. %d) are not found in the first string then util.inspect() is called on each argument and the resulting string values are concatenated. See util.format() for more information.

          Since

          v0.1.100

          Parameters

          • Optional message: any
          • Rest ...optionalParams: any[]

          Returns void

    Returns Promise<void>

Generated using TypeDoc