Data Loss Issue - Migrate : Alter

34 views
Skip to first unread message

Natarajan P

unread,
Oct 2, 2015, 11:38:22 AM10/2/15
to sails.js
I'm using Mongo DB and Sails framework. The problem over here is, there is data loss (not consistent).. It's dropping the DB - Collection, when I deploy my changes to the server. How to fix this?  Migrate is set to 'Alter' as we used to add new fields to the model... What am I doing wrong?

Sávio Lucena

unread,
Oct 2, 2015, 2:46:40 PM10/2/15
to Natarajan P, sails.js
Hey Natarajan,

Check SailsJS documentation about Models Settings (http://sailsjs.org/documentation/concepts/models-and-orm/model-settings), it's stated there:

"Note, by using drop, or even alter, you risk losing your data. Be careful. Never use drop oralter with a production dataset. Additionally, on large databases alter may take a long time to complete at startup. This may cause commands like sails console to appear to hang."

Hope it helps,

Regards,

Sávio Lucena

2015-10-02 12:38 GMT-03:00 Natarajan P <pnatar...@gmail.com>:
I'm using Mongo DB and Sails framework. The problem over here is, there is data loss (not consistent).. It's dropping the DB - Collection, when I deploy my changes to the server. How to fix this?  Migrate is set to 'Alter' as we used to add new fields to the model... What am I doing wrong?



--
Sávio  Lucena
Tel - (71) 9159-6978

Natarajan P

unread,
Oct 3, 2015, 9:42:48 AM10/3/15
to sails.js, pnatar...@gmail.com
Hi Savio,

Thanks for the update!

Yeah, I've gone through the documentation and it's clearly mentioned that by 'Alter', there may be data loss.
What should I do exactly now? In my latest release, I've added/removed more columns in the DB and If I set to 'Safe'
then the changes in the schema will not take effect in existing records. Is there any other way that I can do?

Thanks again!
Reply all
Reply to author
Forward
0 new messages