Turned out to be the DEFAULT='0' issue with autoincrement fields in the CREATE TABLE statements.