question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error when creating a table: conflicting NULL/NOT NULL declarations for column "id" of table

See original GitHub issue

Bug report

Describe the bug

When trying to create a new table (with default settings, besides the required name field) with an id primary key, the following 400 response is returned:

{"error":{"code":400,"message":"conflicting NULL/NOT NULL declarations for column \"id\" of table \"companies\""}}

The table is still created, despite the error thrown. So I tried to just add the id column manually, but the same error is returned.

I also started a completely fresh project and tried it and the same error arose.

To Reproduce

  1. Create a new Supabase project
  2. Go to Table Editor
  3. Click New Table
  4. Enter a name in the Name field
  5. Leave all other settings as is
  6. Click Save

Expected behavior

It should create a table with no errors.

Screenshots

Screenshot 2021-07-03 at 18 02 02 Screenshot 2021-07-03 at 18 03 15

System information

  • OS: macOS 11.4
  • Browser: Brave

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:8
  • Comments:5

github_iconTop GitHub Comments

4reactions
a21ycommented, Jul 6, 2021

If anyone else is stumbling on this while it’s still an issue, the workaround is you can just use the SQL editor to create or update your tables. Go the SQL tab, and open the Welcome tab under Getting Started. Choose the Create Table under Scripts to get a starter script (pasted below). The line you’re looking for in this case is id bigint GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,

CREATE TABLE table_name (
  id bigint GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,
  inserted_at timestamp with time zone DEFAULT timezone('utc'::text, now()) NOT NULL,
  updated_at timestamp with time zone DEFAULT timezone('utc'::text, now()) NOT NULL,
  data jsonb,
  name text
);
2reactions
a21ycommented, Jul 14, 2021

Just tested this myself and looks like it is fixed. Closing.

Read more comments on GitHub >

github_iconTop Results From Across the Web

sql - conflicting NULL/NOT NULL declarations for column ...
PSQLException : ERROR: conflicting NULL/NOT NULL declarations for column "nullid" of table "t_1". Stack: Java+Heroku+Tomcat9+PostGreSQL 9.5.
Read more >
BUG #16913: GENERATED AS IDENTITY column nullability is ...
ERROR : conflicting NULL/NOT NULL declarations for column "id" of table > "foo". > Is this intended? GENERATED BY DEFAULT does create a...
Read more >
PostgreSQL Not-Null Constraint
We will introduce you to the NULL concept and how to use PostgreSQL not-null constraint to make sure that the values in columns...
Read more >
Name of not null constraint is missing in error message
Define two NOT NULL column constraints on the table distributors, one of which is explicitly given a name: CREATE TABLE distributors ( did ......
Read more >
"conflicting NULL/NOT NULL declarations" from sqlite3 to ...
I'm running into the following error while trying to migrate the schema: ... conflicting NULL/NOT NULL declarations for column "id" of table ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found