Open simonw opened 1 year ago
I’m not sure that is OK. Strictly speaking, an ALTER TABLE
should run the equivalent action of an UPDATE
trigger adding the default value of the column to every single row of the table.
Maybe have that as an option on the ALTER TABLE
function generator? Let the user decide if they want that specific traceability in their history?
https://social.lol/@rameez/110205766086091801
One way of handling ALTERed tables would be to split _mask into individual columns (_name_changed, _age_changed, etc.) instead and storing 0/1 in them.
I have a side project I started a few years ago using shadow tables, and I've been trying to figure this out, too, because I want users to have the flexibility to modify their database, but I don't want them to lose data with a bad change accidentally. A couple of options I've considered are:
I am tempted to say that alter table isn't supported at all.
But actually, I just realized that the _mask column can stay useful provided you only ever add new columns to the table, and you add them at the end.
You would need to update the triggers. All previous history records would assume a column storing null which I think is OK.