diff options
author | jadmanski <jadmanski@592f7852-d20e-0410-864c-8624ca9c26a4> | 2009-04-21 17:57:40 +0000 |
---|---|---|
committer | jadmanski <jadmanski@592f7852-d20e-0410-864c-8624ca9c26a4> | 2009-04-21 17:57:40 +0000 |
commit | 86ba3b0091f3dd1157754bc8e628895d54389f3d (patch) | |
tree | 1f7d56213bffdbbdad967a8d7eed4ff4b881b30a /tko/migrations | |
parent | ea7cab69a9b12ce7d4c81c624406b48ec4ec705f (diff) |
Fix a bug in the parser when dealing with test labels. The final
reparse drops the existing test entries and replaces them with new
ones, so that leaves behind a bunch of orphaned labels in the
database and basically kills all the lables you've added. So instead
we add some code to move the existing labels over the new entries that
replace them (making a best effort to match up "new" and "old"
entries).
Add foreign keys to the test_labels_tests table. This also
requires compacting test_labels_tests into an unsigned int(10), since
that's what the tests.test_idx field is.
Risk: Low
Visibility: Fix up the parser's handling of test labels, and add
foreign keys that should've been there from the start (but were
dropped because of MyISAM vs InnoDB issues).
Signed-off-by: John Admanski <jadmanski@google.com>
git-svn-id: svn://test.kernel.org/autotest/trunk@3022 592f7852-d20e-0410-864c-8624ca9c26a4
Diffstat (limited to 'tko/migrations')
-rw-r--r-- | tko/migrations/025_add_test_label_foreign_keys.py | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/tko/migrations/025_add_test_label_foreign_keys.py b/tko/migrations/025_add_test_label_foreign_keys.py new file mode 100644 index 00000000..56072226 --- /dev/null +++ b/tko/migrations/025_add_test_label_foreign_keys.py @@ -0,0 +1,24 @@ +ADD_FOREIGN_KEYS = """ +ALTER TABLE test_labels_tests MODIFY COLUMN test_id int(10) unsigned NOT NULL; + +DELETE FROM test_labels_tests + WHERE test_id NOT IN (SELECT test_idx FROM tests); + +ALTER TABLE test_labels_tests ADD CONSTRAINT tests_labels_tests_ibfk_1 + FOREIGN KEY (testlabel_id) REFERENCES test_labels (id); + +ALTER TABLE test_labels_tests ADD CONSTRAINT tests_labels_tests_ibfk_2 + FOREIGN KEY (test_id) REFERENCES tests (test_idx); +""" + +DROP_FOREIGN_KEYS = """ +ALTER TABLE test_labels_tests DROP FOREIGN KEY tests_labels_tests_ibfk_1; +ALTER TABLE test_labels_tests DROP FOREIGN KEY tests_labels_tests_ibfk_2; +ALTER TABLE test_labels_tests MODIFY COLUMN test_id int(11) NOT NULL; +""" + +def migrate_up(mgr): + mgr.execute_script(ADD_FOREIGN_KEYS) + +def migrate_down(mgr): + mgr.execute_script(DROP_FOREIGN_KEYS) |