The above seems to be the crux of the problem, how did NULL get into the column data?
I agree. My queries are generated by Django (so I never write SQL myself), but:
- the column has always been NOT NULL for its entire lifetime
- we don't send *any* SQL commands to the replica yet, so that's not a factor (for now it's just a live backup)
- the publisher now has a NOT NULL constraint on that column. I never had to clear out null values to put it in place. I assume that if that column ever had a null value and I tried to run a DDL to add a null constraint, the DDL would have failed, right?
Something feels wrong here, the more I think about it.