Backward-Incompatible Operationsīackward-incompatible operations are the reason why I wrote this article. #DBSCHEMA MONGODB DESIGN UPDATE#Your only option is to remove the constraint and to roll-out the update quickly. You also can’t keep the constraint because some write operations of the new version will fail. You can’t remove the constraint because some reading use cases of the old version will break. If that breaks any old code, you’re in trouble, and I don’t know any good way to solve it. During the rolling update, instances of the new version of the application might write some records that do not comply with the no-longer-existing constraint. The old version of your application can still write to the database in the same way as it did before.īut you need to check if there are any old use case implementations that would break if any database record doesn’t fulfill the constraint. The removal of the constraint itself is a backward-compatible operation. No application is using that column anymore so there is also no application that could be affected by its removal. Removing a database column that is neither accessed by the old nor the new version of your application is also a backward-compatible operation. Remove a column that’s not used by the old and the new version of your application The good news is that you can execute all 3 statements within the same migration step. Run a database script to fill that field in all existing records.Add the column without a default value and update all application instances.If you don’t want to define a default value, you need to execute 3 statements to add the column with the constraint: #DBSCHEMA MONGODB DESIGN HOW TO#You can easily fix that by providing a default value please check your database documentation on how to do that. That’s not the case for columns with a not null constraint because it will contain null values for all existing records. In that case, your operation is backward compatible, and you can simply add the column. You don’t need to worry if you add a database column without a not null constraint. It can be a little bit harder to add a new column. You might need to clean up your data and add the missing records to the new table after all application instances have been migrated. These old instances, obviously, don’t write any data to the new tables. Just keep in mind that while you’re performing the rolling update, some users might trigger write operations on old application instances. Add a table or a viewĪdding new tables or views doesn’t affect the old instances of your application. That means that you can execute them during a migration step and don’t need to split them into multiple operations. Backward-Compatible Operationsīackward-compatible operations are all operations that change your database in a way that it can be used by the old and the new version of your application. Let’s take a closer look at the backward-compatible operations first. These operations require a multi-step process that enables you to perform the migration without breaking your system. But not all operations, e.g., renaming or removing a column, are backward compatible. That means that all migrations need to be backward-compatible as long as you’re running at least one instance of the old version of your application. You no longer need to just adapt the database in the way it’s required by your application you also need to do it in a way that the old and the new version of your application can work with the database. The rolling update adds a few requirements to your database migration. The Kubernetes documentation contains a nice, visual description of the rolling update concept. While doing that, you run the old and the new version of your application in parallel. But the idea is always the same: You have a bunch of instances of a subsystem and you shutdown, update, and restart one instance after the other. The implementation of a rolling update depends on your technology stack. It enables you to perform a rolling update. The redundancy of the application plays a critical role during the migration. In this article, I want to focus on database schema migration for high-available systems. The good news is that there are several great tools and libraries available that help you solve these challenges. I will not dive any deeper into topics like monitoring, tracing, load balancing, and fault tolerance. If you don’t have any experience with high-available systems, you should read about all of them. It makes sure that your system is still up and running even if an instance of one of your subsystems isn’t available.īut they also create new challenges.It increases the number of parallel requests that your system can handle.The redundancy of all subsystems provides a lot of benefits.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |