2 ms·
On postges < 10, adding a new not null column is a pain. A hacky way to get around this is: - add the column which allows null values - backfill in batches -
by yeswecatan 5y ago
On postges < 10, adding a new not null column is a pain. A hacky way to get around this is:
- add the column which allows null values
- backfill in batches
- use triggers to auto-populate for new inserts
- add a check constraint
- and now the hack: set the column to not null using pg_attribute.attnotnull