Reputation: 265
I'm running liquibase against a PostgreSQL 9.6 DB and have a dropDefaultValue change to a NON-NULLABLE column.
- dropDefaultValue:
columnDataType: VARCHAR(255)
columnName: bar
tableName: foo
I expected this to result in a DROP DEFAULT
instruction (as suggested in the docs - https://www.liquibase.org/documentation/changes/drop_default_value.html) but instead I see:
ALTER TABLE public.foo ALTER COLUMN bar SET DEFAULT NULL
With the net effect that the column still has a default value (of NULL) rather than no default at all. Is this to be expected?
Upvotes: 0
Views: 1854
Reputation: 246393
My experiments show that the pg_attrdef
row vanishes if I run
ALTER TABLE ... ALTER ... SET DEFAULT NULL;
But maybe there are ways to enter a NULL row.
However that may be, it is fine, and Liquibase isn't doing anything wrong. NULL is the “default DEFAULT
value”.
A column can be defined as NOT NULL
and still have a NULL default value — the only consequence is that you can never use the default value for that column.
Upvotes: 2