Drupal 5 to 6 duplicate entry problem

I moved one of my last sites over here to my new hosting environment. This is probably my oldest. It's been around since some time in the Drupal 4 series, at least 3 years.

When I moved it here I upgraded it to Drupal 6 from 5.7. This created some problems that resulted in not being able to make comments as well as other issues that boiled down to minor problems with the database causing big problems.

Here is an example error message we received from the watchdog module. The comment module provided something similar.

user warning: Duplicate entry '0' for key 1 query: INSERT INTO watchdog (uid, type, message, variables, severity, link, location, referer, hostname, timestamp) VALUES (24, 'user', 'Session opened for %name.', 'a:1:{s:5:\"%name\";s:2:\"Ed\";}', 5, '', 'http://site.com/node/353?destination=node%2F353', 'http://site.com/node/353', '70.137.0.115', 1215526129) in /home/user/public_html/modules/dblog/dblog.module on line 144.

It turned out that these database tables simply didn't have auto_increment set. In Drupal 6, the developers changed the way they handle the incrementing of the record IDs. They are using the database feature to handle it now instead of doing it themselves in the code.

The resolution to this was a couple of simple SQL commands to turn on auto_increment where it was needed. Here they are.

alter table comments modify cid int(10) auto_increment;
alter table watchdog modify wid int(5) auto_increment;