3 ms·
> You can't add constraint which conflict with old data Of course you can. For example, constraints inside triggers. A simple insert trigger will only apply on
by always_good 9y ago
> You can't add constraint which conflict with old data
Of course you can. For example, constraints inside triggers. A simple insert trigger will only apply on records going forward.
Also, the reason why you bother with "additional" constraints by implementing them on the database is because the database is typically the thing that can enforce them. Unless you go out of your way to roll your own single-write via queue or something.
I'm not sure I agree with your take-away since you can just drop constraints. Easy come, easy go. Meanwhile bad data is easy come and potentially a nightmare to fix.
- Demiurge 9y ago>Of course you can. For example, constraints inside triggers. A simple insert trigger will only apply on records going forward. Or you can just expand the constraint to superset of two, or figure out how the old data needs to be treated by new system and migrate it. There are many right options if you actually care about data integrity that are not as easy as not caring. Doesn't make it good general advice not to care.