Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to write database migration in sails.js application

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.

like image 580
tejesh Avatar asked Apr 28 '26 13:04

tejesh


2 Answers

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

like image 80
tejesh Avatar answered Apr 30 '26 01:04

tejesh


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

like image 39
Crusader Avatar answered Apr 30 '26 02:04

Crusader