How to use the postgrator.migrate function in postgrator

To help you get started, we’ve selected a few postgrator 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 nearform / udaru / scripts / init / database / install_001.js View on Github external
var postgrator = require('postgrator')

postgrator.setConfig({
  migrationDirectory: __dirname + '/migrations',
  schemaTable: 'schemaversion', // optional. default is 'schemaversion'
  driver: 'pg', // or mysql, mssql
  host: '127.0.0.1',
  port: 5432, // optionally provide port
  database: 'authorization',
  username: 'postgres',
  password: 'postgres'
})

postgrator.migrate('001', function (err, migrations) {
  if (err) {
    console.log(err)
  } else {
    console.log(migrations)
  }
  postgrator.endConnection(function () {
      // connection is closed, or will close in the case of SQL Server
  })
})
github codeforamerica / colonel-clark / db / migrator.js View on Github external
var applyMigrations = function(migrationId) {

    console.log("Target migration = " + migrationId);
    
    postgrator.setMigrationDirectory(__dirname + '/migrations');
    postgrator.setConnectionString(process.env.DATABASE_URL || config.db_connection_string);
    postgrator.migrate(migrationId, function(err, migrationsRun) {
	      if (err) {
	          console.error("Error: " + err);
	          process.exit(2);
	      }
    });

}
github CoderDojo / cp-dojos-service / migrate-psql-db.js View on Github external
module.exports = function migrate (cb) {
  postgrator.setConfig({
    migrationDirectory: './scripts/database/pg/migrations',
    driver: 'pg',
    host: config['postgresql-store'].host,
    database: config['postgresql-store'].name,
    username: config['postgresql-store'].username,
    password: config['postgresql-store'].password
  });

  postgrator.migrate('max', function (err, migrations) {
    postgrator.endConnection(function () {
      return cb(err, migrations);
    });
  });
};
github medic / couch2pg / libs / xmlforms / index.js View on Github external
return new Promise(function (resolve, reject) {
    postgrator.setConfig({
      migrationDirectory: __dirname + '/migrations',
      schemaTable: 'xmlforms_migrations',
      driver: 'pg',
      connectionString: POSTGRESQL_URL
    });

    postgrator.migrate('201606201000', function(err, migrations) {
      if (err) {
        reject(err);
      } else {
        postgrator.endConnection(function() {
          resolve(migrations);
        });
      }
    });
  });
};
github medic / couch2pg / libs / xmlforms / migrator.js View on Github external
return new rsvp.Promise(function (resolve, reject) {
      postgrator.setConfig({
        migrationDirectory: __dirname + '/migrations',
        schemaTable: 'xmlforms_migrations',
        driver: 'pg',
        logProgress: log.getLevel() <= log.levels.DEBUG,
        connectionString: postgresUrl
      });

      postgrator.migrate('201606281159', function(err, migrations) {
        if (err) {
          reject(err);
        } else {
          postgrator.endConnection(function() {
            resolve(migrations);
          });
        }
      });
    });
  };

postgrator

A SQL migration tool for SQL people

MIT
Latest version published 1 month ago

Package Health Score

75 / 100
Full package analysis