1

Looking for some help here - I'm working on a site that is using a PostgreSQL db and am running into an issue. When saving a large Matrix field with multiple block types I was receiving the following error:

Integrity constraint violation
SQLSTATE[23502]: Not null violation: 7 ERROR: null value in column "id" violates not-null constraint

At first, I thought there was something corrupted with the Matrix so I nuked it and rebuilt it - everything seemed to be working fine until I created a new channel section - when I tried to create an entry there, I got the following error:

Integrity constraint violation
SQLSTATE[23502]: Not null violation: 7 ERROR: null value in column "id" violates not-null constraint
The SQL being executed was: INSERT INTO "drafts" ("sourceId", "creatorId", "name", "notes") VALUES (NULL, 5772, 'First draft', NULL)).

Similar to the above, just a new table this time.

Everything I am reading points to an auto-increment issue, though in both cases there does seem to be the appropriate sequence in the db. I've barely used PostgreSQL and never with Craft, though I'm not 100% certain it has to do with the db.

Any thoughts on what could be causing this?

2
  • It definitely seems like that table is missing the sequence that creates the integers for the id column. If you do a database dump, do you see them in the output?
    – Brad Bell
    Aug 20 '19 at 23:03
  • Brad, there's a sequence being created for entrydrafts but not for drafts. Also, while I'm not sure it matters, there are a few entries in the drafts table with NULL sourceId values.
    – Sara King
    Aug 21 '19 at 13:45
0

there's a sequence being created for entrydrafts but not for drafts.

That's your issue.

I did a fresh Craft 3.3. install on PostgreSQL and there should be a drafts_id_seq sequence created for the drafts table that you're missing.

enter image description here

1
  • Thanks, Brad. I ended up nuking the entire environment and starting over. I had imported a database from a server running PostgreSQL 11 into a vagrant box running 9.6 - after importing into a new box running the same version everything seems to have sorted itself out. Thanks!
    – Sara King
    Aug 28 '19 at 23:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.