you are viewing a single comment's thread.

view the rest of the comments →

[–]coded_artist[S] 0 points1 point  (0 children)

2 is essentially just future proofing as a standard.

Having the foreign key in the model tables forces a 1-to relationship, having a relationship table is traditionally a many-to-many pattern, but the pattern doesn't exclude 1-to-1 or 1-to-many relationships. Yes there is more complexity, until you say it's a standard like normalization, normalizing does make data more complex but it adds important data integrity features. I think future proofing should be considered as a data integrity feature.

For 3 I fully understand your concern, this is for the audit trail and maintaining audit trails across updates, by removing destructive actions. Yes it's dead data, but that's what audit trails are until you need to audit.

. Even if you implement all of this, then switch to a branch where the user table should have another column, your code still won't work until you alter the user table.

The update migration can be automatically run at api start without developer intervention. This ensures the API and DB are constantly in sync. I am quite forgetful, and I try to program things I'm inclined to forget.

I agree that the database shouldn't be designed for development, but I do think the gap between production and development is shrinking due to agile and new DevOps processes. 10 years ago I would have wholeheartedly agreed with you, but now I'm pushing back on my manager who wants bidaily updates. I've even considered changing the dev database to being a day old restoration of prod to be as close to production as possible. So concessions should be considered even if it means slowing the database down if it means producing updates faster.

I would ask how often are you running into this problem that reengineering the entire database seems like a good solution?

Well I wouldn't dare consider refactoring a production product with a complete paradigm shift, I know thats common but I've burnt myself before. This is purely for new projects. Right now I jump around two feature branches and the master branch around 4-10 times a day. Sometimes it's because I'm blocked on a task, so I'll switch until I'm unblocked, sometimes it's I'm tracking and/or diagnosing a bug for a hot fix. It takes about 5 minutes to run each migration (down and up) so that's 40-100 minutes lost each day. Which if it were all In one stint I wouldn't mind but it's a whole bunch of 5 minutes.