PG::NotNullViolation error on id column in PostgreSQL
Par PAB le dimanche 17 septembre 2017, 03:30 - Lien permanent
Faced with this error:
PG::NotNullViolation: ERROR: null value in column "id" violates not-null constraint
it took me some time to realize that my id column was not a serial but a plain integer...
To fix this, just execute:
ALTER TABLE my_table DROP COLUMN id; ALTER TABLE my_table ADD COLUMN id SERIAL PRIMARY KEY;