q2a/question2answer — pull request #8 by edwardyu (2013-06-23 16:47:14+00:00)
Title: Fixed database upgrading bug

When upgrading to 1.6 beta 2, this database error occurs:

Question2Answer was unable to perform the installation query below. Please check the user in the config file has CREATE and ALTER permissions:

CREATE TABLE qa_userlevels (userid INT UNSIGNED NOT NULL, entitytype CHAR(1) CHARACTER SET ascii NOT NULL, entityid INT UNSIGNED NOT NULL, level TINYINT UNSIGNED, UNIQUE userid (userid, entitytype, entityid), KEY entitytype (entitytype, entityid), CONSTRAINT qa_userlevels_ibfk_1 FOREIGN KEY (userid) REFERENCES qa_users(userid) ON DELETE CASCADE) ENGINE=InnoDB CHARSET=utf8

Error 1005: Can't create table 'qa.qa_userlevels' (errno: 150)

This fix sets foreign_key_checks to 0 before upgrading and resets it back to 1 afterwards.