2.4.1 • Published 5 years ago

anydb-sql-migrations v2.4.1

Weekly downloads
49
License
MIT
Repository
github
Last release
5 years ago

anydb-sql-migrations

Database migrations for anydb-sql

usage

Create a script called migrate.js and add the following

#!/usr/bin/env node

var myanydbsql = require('./path/to/my/database/instance');

require('anydb-sql-migrate')
.create(myanydbsql, '/path/to/migrations/dir')
.run();

In your migrations dir, create a file named '001-empty-test.js' and add the code

exports.up = function(transaction) {}
exports.down = function(transaction) {}

The first method is run when upgrading the db, while the second is run when downgrading it. Both methods accept a single parameter - the transaction within which that migration should run.

To check for pending migrations, use

./path/to/migrate.js --check

It should show 001-empty-test and return a nonzero exit code

To run pending migrations, use

./path/to/migrate.js --execute

It should run the exported empty up function.

If you want to silently run the migrations, you can pass { silent: true } to run and migrate functions

require('anydb-sql-migrate')
.create(myanydbsql, '/path/to/migrations/dir')
.migrate({ silent: true }); // it will supress only console.logs, not errors

license

MIT

2.4.1

5 years ago

2.4.0

5 years ago

2.3.1

5 years ago

2.3.0

5 years ago

2.2.4

6 years ago

2.2.3

6 years ago

2.2.2

6 years ago

2.2.1

6 years ago

2.2.0

6 years ago

2.1.6

7 years ago

2.1.5

7 years ago

2.1.4

7 years ago

2.1.3

7 years ago

2.1.2

7 years ago

2.1.1

7 years ago

2.1.0

7 years ago

2.0.0

8 years ago

1.0.12

8 years ago

1.0.11

8 years ago

1.0.10

8 years ago

1.0.8

9 years ago

1.0.7

9 years ago

1.0.6

9 years ago

1.0.5

9 years ago

1.0.4

9 years ago

1.0.3

9 years ago

1.0.2

9 years ago

1.0.1

9 years ago