I have a sails app(v ~0.10.0
) using sails-mongo (v 0.10.0-rc4
) and i need to execute some queries in my database through migrations.
There is any support to this feature in sails?

- 5,043
- 3
- 41
- 55
-
Can you clarify what it is you're trying to do? Is there a migration package you're using? As @InternalFX notes in his answer, MongoDB doesn't typically need migration support since it's schemaless, but I'm not sure if that's exactly what you're getting at. – sgress454 May 09 '14 at 16:40
-
first thanks for the reply, i need to write migrations for insert or update some documents, something like [active record from rails](http://guides.rubyonrails.org/migrations.html). For now i'm trying to use [mongo-migrate](https://github.com/afloyd/mongo-migrate), but would be better if sails give support for this feature – Victor May 09 '14 at 17:12
-
3You can use your `config/bootstrap.js` to seed your database with data when it lifts, but you're right that Sails doesn't do "up/down" migrations. If it's ever supported, it'll probably be in the form of a plug-in or 3rd-party module. – sgress454 May 09 '14 at 18:18
2 Answers
Sailsjs can alter your tables in development, but it's definitely NOT recommended for a production database.
However, if you are using mongoDB migrations are not even necessary because it is a schemaless database.

- 1,475
- 12
- 14
-
1I need to write migrations for insert or update some documents, not to build or change the schema – Victor Dec 17 '14 at 13:23
sails-db-migrate is a nice module which might be useful in your case. Check the npm package information
Additional Information
The above module uses db-migrate node module which is designed to work with live databases. If you plan to use db-migrate, its appropriate that you disable sails auto-migration and take control of the changes in db using the db-migration tasks. The migrations will need to be created each time you alter your db and can run through automated tasks on lift as per your requirement
You can let the auto-migration keep running if you are sure you only want to add data and no structure changes are part of the db-migrate based migrations