3 ms·
I wish relational databases would offer One Simple Trick that I think would improve migrations immensely: Every table should—by default—be a view of the actual
by daenz 4y ago
I wish relational databases would offer One Simple Trick that I think would improve migrations immensely:
Every table should—by default—be a view of the actual underlying table. In other words, a table is a shim for the real table. This way, when it's time to perform migrations, the shim to the underlying table could change independently of the actual migration, since the interface to the table would be preserved for all applications.
I know there are overhead concerns for this shim-view idea, but I'm sure many of them can be cleverly elided under many conditions.
- bob1029 4y agoThis is a conversation our team had for a while. We are still on the fence about it because the physical schema is very stable at this point. There haven't been any major issues with migrations in years. But, this is one of those things like planting a tree. If the entire business depends directly on the physical tables, getting a major change in could instantly become a nightmare.
- fabianlindfors 4y agoThis is precisely what I did for my automated zero-downtime migration tool and it works pretty well: https://github.com/fabianlindfors/reshape https://github.com/fabianlindfors/reshape. At least for Postgres, simple views like these have almost no overhead as queries are simply rewritten for the underlying table.
- daenz 4y agoVery cool project! Thanks for sharing