1. 2 / 8
Why?
●
Well-know db-migrate tool doesn`t support semver
– Number of fles in migrations folder grows extremely
fast.
– It`s not possible to tell which migrations correspond to
which product version.
3. 3 / 8
Migro
●
Supports and endorces semver!
– It`s easy to tell which migrations where added to which
version.
●
Makes it possible to up/down migrate the DB either version
by version or by single migration.
●
Does not abstract the familiar DB client API away by its own
interface.
4. 4 / 8
Examples
1. Install migro either locally or globally:
npmi-gmigro
2. Create .migrorcfle in the root of your project and provide
database connection options there.
3. $> migrocreate-versionmain0.1.0
4. $> migrocreatemaincreate-table-Users
5. $> migroupmain
5. 5 / 8
Example of .migrorc
{
"database":{
"main":{
"host":"localhost",
"port":5432,
"user":"postgres",
"password":"S3cur3P@55w0rd",
"database":"my_cool_db"
}
},
"workingDir":"/path/to/your/project",
"driver":"pg"
}
6. 6 / 8
Example of a migration
'usestrict';
exports.up=asyncdb=>{
awaitdb.query('createtable"Users"(iduuid);');
};
exports.down=asyncdb=>{
awaitdb.query('droptable"Users";');
};
7. 7 / 8
Links
●
Contribute & star at GitHub:
https://github.com/YBogomolov/migro
●
Install at NPM:
https://www.npmjs.com/package/migro
●
Contact me at:
– Twitter: @YuriyBogomolov
– Email: yuriy.bogomolov@gmail.com