Hi,
I am attempting to migrate an old Omeka instance on 2.8 to a new version. I have the new code in place, but when I attempt to login to the web client to upgrade the database, I receive the following error:
Zend_Db_Statement_Mysqli_Exception
Mysqli statement execute error : Field 'id' doesn't have a default value
Hmm, that’s an odd error. It looks like something’s odd about your installation’s “options” table, from what I can see from that error message.
If you’re comfortable trying, you could connect to your database and run
SHOW CREATE TABLE omeka_options;
(with omeka_ replaced by your configured prefix in db.ini if you’ve set one other than the default of omeka_). That should reveal if there’s something wrong with that table.
mysql> show create table omeka_options;
±--------------±---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Table | Create Table |
±--------------±---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| omeka_options | CREATE TABLE omeka_options ( id int unsigned NOT NULL, name varchar(200) CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci NOT NULL, value text CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci |
±--------------±---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)
Your options table is missing the AUTO_INCREMENT setting on the id column. That’s not something Omeka’s own upgrade or other systems would do… maybe it was done by a manual change to the database at some point, or other process?
You’re also missing the indexes that should be on this table; there should be lines showing indexes on the id and name columns. Here’s what it should look like:
CREATE TABLE `omeka_options` (
`id` int unsigned NOT NULL AUTO_INCREMENT,
`name` varchar(200) CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci NOT NULL,
`value` text CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci,
PRIMARY KEY (`id`),
UNIQUE KEY `name` (`name`)
) ENGINE=InnoDB AUTO_INCREMENT=4657 DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci
That AUTO_INCREMENT=4657 part is unique to the table I dumped to get that output, but the rest should be what yours should look like: the AUTO_INCREMENT on the id line, the PRIMARY KEY and UNIQUE KEY lines. It’s possible to make these changes to bring the table back into the expected format, but I’d be a little concerned that this isn’t the only table that’s “wrong.”
I did the export in phpmyadmin of the old database. I wonder if I did the export via command line if it would make any difference? What do you think? I don’t think I saw any errors when importing it.
Hmm, I wouldn’t typically expect to see a problem like this from exporting through phpmyadmin. If you do have exports or older backups, they should contain a CREATE TABLE statement for the omeka_options table and you could see if they have the same problem or not.
You could also check other tables in the same way with SHOW CREATE TABLE to see if this is more widespread or not.
I fixed this by doing a command line export/import of the database and dropping all of the old tables and data. I suspect either my export in phpmyadmin timed out or there was a setting in phpmyadmin that capped files at 2 gigs. The entire database turned out to be 4.5 gigs so it was missing a lot of data.