I am searching a method to automate schema migration for such databases like MongoDB or CouchDB.
Ideally, this instument ought to be designed in python, but every other language is alright.
Among the supposed advantages of these databases is they are schemaless, and for that reason have no need for schema migration tools. Rather, you are writing your computer data handling code to handle the number of data saved within the db.
Since a nosql database can contain immeasureable data you can't migrate it within the regular rdbms sence. Really you cannot get it done for rdbms too the moment your computer data passes some size threshold. It's not practical to create your website lower for any day to include a area for an existing table, and thus with rdbms you finish up doing ugly patches like adding new tables only for the area and doing joins to get at the information. In nosql world that you can do a number of things.
- As others recommended you are able to write your code to ensure that it'll handle different 'versions' from the possible schema. normally, this is simpler it looks. Many different types of schema changes are trivial to code around. for instance if you wish to give a new area towards the schema, you simply combine it with brand new records and it'll be empty around the all old records (you won't get "area does not exist" errors or anything ). should you prefer a 'default' value for that area within the old records it's too trivially completed in code.
- An alternative choice and really the only real sane option moving forward with non-trivial schema changes like area renames and structural changes would be to store schema_version in every record, and also to have code emigrate data from the version to another on READ. i.e. in case your current schema version is 10 and also you read an archive in the database using the version of seven, your db layer should call migrate_8, migrate_9, and migrate_10. By doing this the information that's utilized is going to be progressively migrated towards the latest version. and when it's not utilized, then who cares which version could it be)
In case your data are sufficiently large, you'll most likely discover that you cannot EVER migrate the information, or that it's not advantageous to do this. Which means that whenever you perform a schema change, the code must continue being backwards suitable for that old formats forever.
Obviously in case your data "age" and finally expire anyway, this could do schema migration for you personally - simply alter the format for recently added data, then watch for all data within the old format to run out - after that you can retire the backward-compatibility code.
Whenever a project has an excuse for a schema migration of a NoSQL database makes me think that you're still thinking inside a Relational database manner, but utilizing a NoSQL database.
If anybody will begin working with NoSQL databases, you have to understand that the majority of the 'rules' for any RDBMS (i.e. MySQL) will need to go the window too. Such things as strict schemas, normalization, using many associations between objects. NoSQL is available to resolve issues that have no need for all of the extra 'features' supplied by a RDBMS.
I'd urge you to definitely write your code in a fashion that does not expect or require a hard schema for the NoSQL database - you need to support a classic schema and convert a document record quickly whenever you access if if you want more schema fields on that record.
Please bear in mind that NoSQL storage is most effective whenever you think and design in a different way in comparison to when utilizing a RDBMS