ALTER TABLE recipes
ALTER COLUMN favourite TYPE BOOLEAN
ALTER COLUMN favourite SET NOT NULL
It changes both the type and the nullability of the column. Unfortunately, in postgres, even if the type isn't changing (e.g. it was already a boolean), Postgres initiates a full table scan to ensure that everything is okay. This results in taking out an ACCESS EXCLUSIVE lock on the table for the duration. Unfortunately, to avoid this, we need to do another execute statement to ensure that just the
turns into the following SQL:
It changes both the type and the nullability of the column. Unfortunately, in postgres, even if the type isn't changing (e.g. it was already a boolean), Postgres initiates a full table scan to ensure that everything is okay. This results in taking out an ACCESS EXCLUSIVE lock on the table for the duration. Unfortunately, to avoid this, we need to do another
execute
statement to ensure that just theis being run without the