1

I'm fairly new to Postgresql and it's really weird for me that It can't keep track of auto increment fields.

I have these tables I'm using for my django app

Article
Article_Category
Category

Everything was working fine until today. The Article table suddenly forgot what was the last Article_id and started creating id's back to 1.

DigitalDouble
  • 1,747
  • 14
  • 26
  • 1
    Something reset the sequence. Do you have `log_statement = all` set in your PostgreSQL server? Did you run any tests that might've "helpfully" reset it? – Craig Ringer Jun 10 '14 at 04:11
  • 1
    Note that PostgreSQL handles sequences independent of the tables they're used in. – Ignacio Vazquez-Abrams Jun 10 '14 at 04:12
  • 2
    Did you recreate your tables? What did you do today? – mu is too short Jun 10 '14 at 04:50
  • Craig, I checked my settings and log_statement is commented. Ignacio, Sorry but what do you mean by handles sequence independent of tables? mu, Nope. It's hosted on a Linode server and the last time I remembered doing is rebooting Linode. But I never touched the database prior to this. – DigitalDouble Jun 10 '14 at 07:01
  • You can check your sequences' current states with f.ex. `SELECT * FROM "Article_Article_id_seq";`. You should read the manual about PostgreSQL's sequences/serials: http://www.postgresql.org/docs/current/static/datatype-numeric.html#DATATYPE-SERIAL . Also django has a specific tool handling this situation: http://stackoverflow.com/questions/14589634/how-to-reset-the-sequence-for-ids-on-postgresql-tables . Without more information, we can just wild guess what can cause this. – pozs Jun 10 '14 at 07:49
  • pozs, I'll take a look at those links. Thank You! – DigitalDouble Jun 10 '14 at 09:16

0 Answers0