0.0.1 • Published 8 years ago

cirrent-migrator v0.0.1

Weekly downloads
237
License
MIT
Repository
github
Last release
8 years ago

cirrent-migrator

raw MySQL migrations for node

Example

In your project

// migrate.js
var path = require('path');

require('cirrent-migrator').run({
    basedir: __dirname,
    migrationsDir: path.resolve(__dirname, 'migrations'),
    user: 'root',
    host: 'localhost',
    password: '',
    db: 'sql_migrations'
});

CLI

run node ./migrate.js with arguments


node ./migrate create migration_name

will create two migration files (up and down)

./migrations/1415860098827_up_migration_name.sql
./migrations/1415860098827_down_migration_name.sql

node ./migrate migrate

will run all pending migrations


node ./migrate.js rollback

will rollback the last migration if there is one

Migration files

write raw sql in your migrations example

-- ./migrations/1415860098827_up_migration_name.sql
create table "test_table" (id bigint, name varchar(255));
-- ./migrations/1415860098827_down_migration_name.sql
drop table "test_table";