I have defined a serial PRIMARY KEY
, like this:
CREATE TABLE auth_event(
id serial PRIMARY KEY,
time_stamp TIMESTAMP,
client_ip VARCHAR(512),
user_id INTEGER REFERENCES auth_user (id) ON DELETE CASCADE,
origin VARCHAR(512),
description TEXT
);
The dump that I am importing has explicit values for the serial field, like this:
INSERT INTO "auth_event" VALUES(6,'2012-12-03 21:50:49','127.0.0.1',181,'auth','User 181 Logged-in');
INSERT INTO "auth_event" VALUES(7,'2012-12-04 07:37:43','127.0.0.1',181,'auth','User 181 Logged-in');
INSERT INTO "auth_event" VALUES(8,'2012-12-05 11:42:28','127.0.0.1',181,'auth','User 181 Logged-in');
INSERT INTO "auth_event" VALUES(9,'2012-12-07 08:01:59','127.0.0.1',181,'auth','User 181 Logged-in');
INSERT INTO "auth_event" VALUES(10,'2012-12-07 16:32:58','127.0.0.1',181,'auth','User 181 Logged-in');
INSERT INTO "auth_event" VALUES(11,'2012-12-11 15:41:24','127.0.0.1',181,'auth','User 181 Logged-in');
INSERT INTO "auth_event" VALUES(12,'2012-12-11 22:55:08','127.0.0.1',181,'auth','User 181 Logged-in');
That means, according to this that the sequence value (the one related to auth_event.id
) will not get updated.
And now comes my problem: the framework that I am using is not giving values to the serial field. That means that postgres is using the default value, and since it has not been updated, a collission occurs.
How can I update the sequence value related to auth_event.id
after importing?