Skip to: site menu | section menu | main content
When you change a database so that the tables have a prefix, you end up getting a 'duplicate key' error when creating new nodes or other itmes.
This is because Drupal maintains a 'sequences' table that stores the autoincrement values for various tables. This table has a structure of:
| name | id |
|---|---|
| files_fid | 114 |
| files_fid | 55 |
| menu_mid | 120 |
| vocabulary_vid | 42 |
| term_data_tid | 38 |
| users_uid | 6 |
| node_nid | 44 |
| node_revisions_vid | 44 |
Note how the 'files_fid' with the previous key value is now replaces with the same name with the prefix prepended.
To fix, make sure the highest value of the key is set in the table name with the prefix. Delete the non-prefixed names when you are finished.
Probably, the best prevention is to edit the table as soon as the new database with prefixed table names is loaded. Just rename each entry to have the prefix.