Please enable JavaScript.
Coggle requires JavaScript to display documents.
How to isolate DB logically (Solutions (0dt (Write into both tables, Read…
How to isolate DB logically
Requirements
Isolated set of tables
Minimum changes in the apps consume data
Zero-downtime migration
Initially
Monolith and a separate app reads from the tables directly, all the tables are in
public
schema
The extracting models/tables are isolated from the other models/tables
Provide example on some 2 tables: before refactoring/after refactoring
The other service is data sensitive: column drop/rename/new enum value add without simultaneous changes alignment is not possible
Solutions
PG schema as logical border
PG triggers for 0dt
0dt
Write into both tables
Read from the new tables
Stop write to the old tables
cleanup (triggers, the old tables)
PG views as API
Hack with schema.rb
Alternative approaches
Kafka
Multiple connections
Results
changes in the new tables break the
views
(API)
enum keys are specified explicitly
if a new enum key is added, a ticket gets created for the other team. so our team is not blocked by them. but there is a buffer time when the new key is not accessible
Cheap and easy, no need in additional engineers