Answer the question
In order to leave comments, you need to log in
Answer the question
In order to leave comments, you need to log in
Perhaps AR couldn't guess the name of the sequencer for the id field in the plate.
Try to re-create the table with serial pseudo-type:
CREATE TABLE foo
(
id serial NOT NULL,
...
);
Or like this (if you don't want to lose data in the table):
CREATE SEQUENCE foo_id_seq;
ALTER TABLE foo ALTER COLUMN id SET DEFAULT nextval('foo_id_seq'::regclass);
ALTER TABLE foo ALTER COLUMN id SET NOT NULL;
ALTER SEQUENCE foo_id_seq OWNED BY foo.id;
SELECT setval('foo_id_seq', MAX(id)) from foo;
After that, switching the sequencer in the trigger can be removed, since it will switch automatically when inserting records.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question