Really struggling to create a table with simple sql on my postgres database cant understand the error im getting. pic attached.
CREATE TABLE IF NOT EXISTS public.charters (
id integer NOT NULL DEFAULT nextval('charters_id_seq'::regclass),
length numeric,
beam numeric,
height numeric,
passengers integer,
berths integer,
description text,
"year" integer,
power integer,
price numeric,
model character varying,
skipper boolean,
fuel_included boolean,
gps boolean,
shower boolean,
main_img character varying,
title character varying,
created_at timestamp(6) without time zone NOT NULL,
updated_at timestamp(6) without time zone NOT NULL,
"location" character varying,
PRIMARY KEY(id)
);
2
Answers
Did you create a sequence charters_id_seq? Looks like the database can’t find it. Using an IDENTITY might be easier, you don’t have to create the sequence yourself:
You will have to create a sequence
charters_id_seq
:Exemple :
Then :
To associate the sequence to the specific table column, such that if that column (or its whole table) is dropped, the sequence will be automatically dropped as well, then use this :
This will avoid permissions issues as well