I'm very new to mongoose and mongo, but proficient in relational sql databases. I have a project that is very well suited to a nosql document model, so I'm using mongo(ose).
How do I handle changes to a document's schema over time?
In my SQL RDB lingo, I'm referring to things like adding required columns (keys) to tables (collections), possibly migrating a data type or required constraint, etc. The process usually involves lengthy migrations, temporary tables, lots of sql scripts, application code changes, etc. In node/mongo/mongoose, it appears that I jest need to open my model.js file, edit the scheme definition, make any app changes to support the new schema, and poof, the mongodb collection magically changes to support my new schema/ What happens to all the documents that used the old schema? How are they accessible now when keys have potentially moved, been renamed, deleted, etc? I've been all over the Group and StackExchange and there are lots of questions, but no answers. Mongoose is supposed to handle exaclty this problem with SQL/RDBMSs, but I can't find out how it happens or what the process is.
Is it magic, and everything "just works"?
How do I know which schema a document was created with?
What happens when a constraint is added to a key that wasn't there or is now invalid on older documents?
I'm in a cold sweat over this.