Serendipity and PostgreSQL - Fixing auto-increment errors
If you – for whatever reason – move your Serendipity installation to another machine or database, you may encounter the following error:
Error: Entries were not successfully inserted!
The reason for this error is a wrong value for the entry counter in the „serendipity_entries” table.
You can verify this very easily. Just connect to the database via „psql -d DATABASENAME” and issue the command SELECT MAX(id) FROM serendipity_entries; and SELECT nextval('serendipity_entries_id_seq');:
demo=# SELECT MAX(id) FROM serendipity_entries; max ----- 281 (1 Zeile) demo=# SELECT nextval('serendipity_entries_id_seq'); nextval --------- 11 (1 Zeile)
As you can see, the counter value for the next entry (11) is way lower than the actual counter value for the latest entry (281).
So, in order to fix this, we just have to set the counter to a „valid” value SELECT setval('serendipity_entries_id_seq', (SELECT MAX(id) FROM serendipity_entries)+1);:
demo=# SELECT setval('serendipity_entries_id_seq', (SELECT MAX(id) FROM serendipity_entries)+1); setval -------- 282 (1 Zeile)
So the next entry will get the number 282 and everything will be fine.
Replace „serendipity” with the database prefix you set for your Serendipity installation.
Now, if I would have been able to see the actual database error and not the useless ” Entries were not successfully inserted” text, I would have been able to fix this a lot faster. :(
Tagged as: auto-increment, database, how-to, postgresql, s9, serendipity | Author: Martin Leyrer
[Sonntag, 20121125, 13:59 | permanent link | 0 Kommentar(e)
Comments are closed for this story.