It makes me sweat - I get an error of 150 when I try to create a table in mySQL. I browsed the forums to no avail. The statement uses foreign key constraints - both tables are InnoDB, all the corresponding columns have the same data type, and both tables have the same encoding and sorting. Here is the CREATE TABLE and the original CREATE TABLE statement for the referenced table. Any ideas?
New table:
CREATE TABLE `approval` (
`rev_id` int(10) UNSIGNED NOT NULL,
`rev_page` int(10) UNSIGNED NOT NULL,
`user_id` int(10) UNSIGNED NOT NULL,
`date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`rev_id`,`rev_page`,`user_id`),
KEY `FK_approval_user` (`user_id`),
CONSTRAINT `FK_approval_revision` FOREIGN KEY (`rev_id`, `rev_page`) REFERENCES `revision` (`rev_id`, `rev_page`),
CONSTRAINT `FK_approval_user` FOREIGN KEY (`user_id`) REFERENCES `user` (`user_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
Link:
CREATE TABLE `revision` (
`rev_id` int(10) unsigned NOT NULL auto_increment,
`rev_page` int(10) unsigned NOT NULL,
`rev_text_id` int(10) unsigned NOT NULL,
`rev_comment` tinyblob NOT NULL,
`rev_user` int(10) unsigned NOT NULL default '0',
`rev_user_text` varbinary(255) NOT NULL default '',
`rev_timestamp` binary(14) NOT NULL default '\0\0\0\0\0\0\0\0\0\0\0\0\0\0',
`rev_minor_edit` tinyint(3) unsigned NOT NULL default '0',
`rev_deleted` tinyint(3) unsigned NOT NULL default '0',
`rev_len` int(10) unsigned default NULL,
`rev_parent_id` int(10) unsigned default NULL,
PRIMARY KEY (`rev_id`),
UNIQUE KEY `rev_page_id` (`rev_page`,`rev_id`),
KEY `rev_timestamp` (`rev_timestamp`),
KEY `page_timestamp` (`rev_page`,`rev_timestamp`),
KEY `user_timestamp` (`rev_user`,`rev_timestamp`),
KEY `usertext_timestamp` (`rev_user_text`,`rev_timestamp`)
) ENGINE=InnoDB AUTO_INCREMENT=4904 DEFAULT CHARSET=binary MAX_ROWS=10000000 AVG_ROW_LENGTH=1024;