Issue Bug Rejected

#56271SqlSchemaMigrationService getUpdateSuggestions creates invalid MySql statements

Christian Zenker 02/25/14, 15:08 updated 03/14/15, 20:15

Description

Consider an extension changes its database definition from

CREATE TABLE tx_foobar_table (
  old_uid int(11) NOT NULL DEFAULT '0',
  PRIMARY KEY (old_uid)
)
CREATE TABLE tx_foobar_table (
  uid int(11) NOT NULL DEFAULT '0' auto_increment,
  PRIMARY KEY (uid)
)
ALTER TABLE tx_realurl_redirects ADD uid int(11) NOT NULL auto_increment;
ALTER TABLE tx_realurl_redirects DROP PRIMARY KEY;
ALTER TABLE tx_realurl_redirects ADD PRIMARY KEY (uid);

The problem here is that the column definition includes the auto_increment where MySQL requires a column with auto_increment to be the Primary Key.

There is already a fix in the source code to circumvent this for newly created primary keys, but not if a primary key is changed.

Reviews 1