How to use the node-pg-migrate.default function in node-pg-migrate

To help you get started, we’ve selected a few node-pg-migrate examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github adrach / starter-postgres-express-react / scripts / db-migrate.js View on Github external
function main() {
  // Execute the migrations
  console.log("Running the migrations...");
  return migrate.default({
    databaseUrl,
    migrationsTable,
    migrationsSchema,
    schema,
    direction,
    dir
  });
}
github cardstack / cardstack / packages / pgsearch / client.js View on Github external
async _migrateDb() {
    let client = new Client(Object.assign({}, config, { database: 'postgres' }));
    try {
      await client.connect();
      let response = await client.query(`select count(*)=1 as has_database from pg_database where datname=$1`, [
        config.database,
      ]);
      if (!response.rows[0].has_database) {
        await client.query(`create database ${safeDatabaseName(config.database)}`);
      }
    } finally {
      client.end();
    }

    await migrate({
      direction: 'up',
      migrationsTable: 'migrations',
      singleTransaction: true,
      checkOrder: false,
      databaseUrl: {
        user: config.user,
        host: config.host,
        database: config.database,
        password: config.password,
        port: config.port,
      },
      dir: join(__dirname, 'migrations'),
      log: (...args) => log.debug(...args),
    });
  }
github cardstack / cardstack / packages / postgresql / indexer.js View on Github external
async _runMigrations() {
    let config = this.config;
    if (!config.migrationsDir) {
      return;
    }
    let dir = path.join(this.projectPath, config.migrationsDir);

    await migrate({
      direction: 'up',
      migrationsTable: 'migrations',
      singleTransaction: true,
      checkOrder: false,
      databaseUrl: {
        user: config.user,
        host: config.host,
        database: config.database,
        password: config.password,
        port: config.port
      },
      dir,
      log: (...args) => log.debug(...args)
    });
  }
});
github cardstack / cardstack / packages / ethereum / cardstack / transaction-index-base.js View on Github external
async _migrateDb() {
    let client = new Client(Object.assign({}, config, { database: 'postgres' }));
    try {
      await client.connect();
      let response = await client.query(`select count(*)=1 as has_database from pg_database where datname=$1`, [config.database]);
      if (!response.rows[0].has_database) {
        await client.query(`create database ${this.safeDatabaseName(config.database)}`);
      }
    } finally {
      client.end();
    }

    await migrate({
      direction: 'up',
      migrationsTable: 'migrations',
      singleTransaction: true,
      checkOrder: false,
      databaseUrl: {
        user: config.user,
        host: config.host,
        database: config.database,
        password: config.password,
        port: config.port
      },
      dir: join(__dirname, 'migrations'),
      log: (...args) => log.debug(...args)
    });
  }
github cardstack / cardstack / packages / ethereum / cardstack / transaction-index.js View on Github external
async _migrateDb() {
    let client = new Client(Object.assign({}, config, { database: 'postgres' }));
    try {
      await client.connect();
      let response = await client.query(`select count(*)=1 as has_database from pg_database where datname=$1`, [config.database]);
      if (!response.rows[0].has_database) {
        await client.query(`create database ${safeDatabaseName(config.database)}`);
      }
    } finally {
      client.end();
    }

    await migrate({
      direction: 'up',
      migrationsTable: 'migrations',
      singleTransaction: true,
      checkOrder: false,
      databaseUrl: {
        user: config.user,
        host: config.host,
        database: config.database,
        password: config.password,
        port: config.port
      },
      dir: join(__dirname, 'migrations'),
      log: (...args) => log.debug(...args)
    });
  }

node-pg-migrate

PostgreSQL database migration management tool for node.js

MIT
Latest version published 7 days ago

Package Health Score

84 / 100
Full package analysis

Popular node-pg-migrate functions