propelorm/Propel — pull request #590 by MArcJ (2013-02-02 03:29:10+00:00)
Title: [MySQL] Fix `Primary Key` part in `getAddTableDDL` with having multiple pks and not the first is autoIncremeneted

MySQL throws

'Incorrect table definition; there can be only one auto column and it must be defined as a key'

if the primary key consists of multiple columns and if the first is not the autoIncrement one. So
this PR moves the autoIncrement column to the first position if its not already.

Example:

SQLSTATE[42000]: Syntax error or access violation: 1075 Incorrect table definition;
there can be only one auto column and it must be defined as a key in SQL:
CREATE TABLE `kryn_publication_news_version`
(
`id` INTEGER NOT NULL,
`title` VARCHAR(255),
`category_id` INTEGER,
`files` TEXT,
`lang` VARCHAR(3),
`intro` TEXT,
`content` TEXT,
`releaseat` BIGINT,
`releasedate` BIGINT,
`deactivate` TINYINT(1),
`deactivatecomments` TINYINT(1),
`commentscount` INTEGER,
`tags` VARCHAR(255),
`introimage` VARCHAR(255),
`introimage2` VARCHAR(255),
`created` VARCHAR(255),
`modified` VARCHAR(255),
`workspace_id` INTEGER NOT NULL,
`workspace_action` INTEGER,
`workspace_action_date` INTEGER,
`workspace_action_user` INTEGER,
`workspace_rev` INTEGER NOT NULL AUTO_INCREMENT,
PRIMARY KEY (`id`,`workspace_id`,`workspace_rev`),
CONSTRAINT `kryn_publication_news_version_FK_1`
FOREIGN KEY (`id`,`workspace_id`)
REFERENCES `kryn_publication_news` (`id`,`workspace_id`)
) ENGINE=InnoDB

Seen on `MySQL 5.5.29 OSX`.

Added also a test for it.