[autotest] Temporarily disable the foreign key check when setup database
Recently mysql-server package has been upgraded from 5.5 to 5.6. The
foreign key checking is more strict in 5.6. As of 5.6.7, the server
prohibits changes to foreign key columns with the potential to cause
loss of referential integrity. In autotest database setup, it fails when
altering foreign key column. Temporarily disable the foreign key check
when we need to alter foreign key columns.
BUG=chromium:588954
TEST=Test on a testing instance to run the database setup script.
Change-Id: Iab9a0af9de2b1c2da18bd57c6e4710a106c8c96f
Reviewed-on: https://chromium-review.googlesource.com/329130
Commit-Ready: Shuqian Zhao <shuqianz@chromium.org>
Tested-by: Shuqian Zhao <shuqianz@chromium.org>
Reviewed-by: Dan Shi <dshi@google.com>
diff --git a/frontend/migrations/058_drone_management.py b/frontend/migrations/058_drone_management.py
index 183e921..5c19f99 100644
--- a/frontend/migrations/058_drone_management.py
+++ b/frontend/migrations/058_drone_management.py
@@ -58,8 +58,12 @@
SELECT id FROM afe_users WHERE login = 'autotest_system')
WHERE requested_by_id IS NULL;
+SET foreign_key_checks = 0;
+
ALTER TABLE afe_special_tasks
MODIFY COLUMN requested_by_id INT NOT NULL;
+
+SET foreign_key_checks = 1;
"""