<blockquote>
  <p>there's a sequence being created for entrydrafts but not for drafts.</p>
</blockquote>

<p>That's your issue.</p>

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

<p><a href="https://i.sstatic.net/v7Uf5.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/v7Uf5.png" alt="enter image description here"></a></p>

CC BY-SA 4.0
2019-08-28T23:47:01.027Z
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
CC BY-SA 4.0
2019-08-27T22:27:25.070Z
2019-08-27T22:27:25.070Z
Brad Bell
<p>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:</p>

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

<p>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:</p>

<pre><code>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)).
</code></pre>

<p>Similar to the above, just a new table this time. </p>

<p>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. </p>

<p>Any thoughts on what could be causing this?</p>

CC BY-SA 4.0
2019-08-20T23:03:48.170Z
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
CC BY-SA 4.0
2019-08-21T13:45:51.717Z
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
<postgresql>
Integrity constraint violation - Not null violation
# Integrity constraint violation - Not null violation

(Asked by: username_0 on 2019-08-20)

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?

**Tags:** postgresql

> **Comments:**
> **username_1**: 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?  
> **username_0**: 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.  

---

## 1 answers

### Answer by username_1 on 2019-08-27. Score: 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](https://i.sstatic.net/v7Uf5.png)](https://i.sstatic.net/v7Uf5.png)

> **Comments:**
> **username_0**: 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!  

---

