Reputation: 109
I tried using https://github.com/building5/sails-db-migrate module for creating migrations but it did not run correctly. Table used to get generated but few columns were missing. Is there a better way to create and run migrations? Sorry i am new to sails, recently migrated from Php.
Upvotes: 3
Views: 3818
Reputation: 1200
Time is pass, but nothing changes with sails. Beware use it. If you already in this trap - try https://www.npmjs.com/package/sails-migrations
Upvotes: 1
Reputation: 1288
So people will get a clean and correct answer: The sails ORM (waterline) already supports auto migration, you can change this in the config file (/config/models.js):
module.exports.models = {
migrate: 'alter'
};
It accepts the following options:
safe
- never auto-migrate my database(s). I will do it myself (by hand)
alter
- auto-migrate, but attempt to keep my existing data (experimental)
drop
- wipe/drop ALL my data and rebuild models every time I lift Sails
http://sailsjs.org/#!/documentation/concepts/ORM/model-settings.html
Upvotes: -1
Reputation: 109
So, it turn out i was stupid to think we need a module to write migration in sails. It turn out on sails lift the application automatically creates the table from attributes of the model.
But on trying that i realized the waterline module which takes care of this does not create for foreign-key constraints as of now.They are still working on it.
If you are using a nosql db then you can use the associations http://sailsjs.org/#!/documentation/concepts/ORM
Upvotes: 3