I\'m close to having my project ready to launch. I have big plans for after launch and the database structure is going to change -- new columns in existing tables as well as
Sequelize can run arbitrary SQL asynchronously.
What I would do is:
mysql_dump -uUSER -pPASS DBNAME > FILE.SQLvar baseSQL = "LOTS OF SQL and it's EVIL because you gotta put \
backslashes before line breakes and \"quotes\" and/or sum" +
" one string for each line, or everything will break";var baseSQL = fs.readFileSync('../seed/baseDump.sql');module.exports = {
up: function (migration, DataTypes) {
var baseSQL = "whatever" // I recommend loading a file
migration.migrator.sequelize.query(baseSQL);
}
}
That should take care of setting up the database, albeit the async thing may become a problem. If that happens, I'd look at a way to defer returning the up sequelize function until the async query function is finished.
More about mysql_dump: http://dev.mysql.com/doc/refman/5.1/en/mysqldump.html
More about Sequelize Migrations: http://sequelize.readthedocs.org/en/latest/docs/migrations/
More about Running SQL from within Sequelize Migration: https://github.com/sequelize/sequelize/issues/313