Revert "Revert "[autotest] TKO parser mark original tests as invalid""
This reverts commit dbd9037df0cbe1232fcb016a2c261f5994ae03a2.
Commit this cl again. Once this cl lands, deploy the db changes together with
https://chrome-internal-review.googlesource.com/#/c/161494/
https://chrome-internal-review.googlesource.com/#/c/161426/
DEPLOY=apache, migrate, wmatrix db changes should be pushed together (see commit messeage)
Change-Id: I47916708e7b49bbc2064370262e3f9e231f08efe
Reviewed-on: https://chromium-review.googlesource.com/197306
Reviewed-by: Dan Shi <dshi@chromium.org>
Tested-by: Fang Deng <fdeng@chromium.org>
Commit-Queue: Fang Deng <fdeng@chromium.org>
diff --git a/frontend/migrations/086_add_invalidates_test_idx_to_tko_tests.py b/frontend/migrations/086_add_invalidates_test_idx_to_tko_tests.py
new file mode 100644
index 0000000..ffded8c
--- /dev/null
+++ b/frontend/migrations/086_add_invalidates_test_idx_to_tko_tests.py
@@ -0,0 +1,35 @@
+ADD_COLUMN = """
+ALTER TABLE tko_tests
+ADD COLUMN `invalidates_test_idx` int(10) unsigned DEFAULT NULL;
+"""
+ADD_INDEX = """ALTER TABLE tko_tests ADD INDEX(invalidates_test_idx);"""
+ADD_FOREIGN_KEY = """
+ALTER TABLE tko_tests
+ADD CONSTRAINT invalidates_test_idx_fk FOREIGN KEY
+(`invalidates_test_idx`) REFERENCES `tko_tests`(`test_idx`)
+ON DELETE NO ACTION;
+"""
+DROP_FOREIGN_KEY = """
+ALTER TABLE tko_tests DROP FOREIGN KEY `invalidates_test_idx_fk`;
+"""
+DROP_COLUMN = """ALTER TABLE tko_tests DROP `invalidates_test_idx`; """
+
+def migrate_up(manager):
+ """Pick up the changes.
+
+ @param manager: A MigrationManager object.
+
+ """
+ manager.execute(ADD_COLUMN)
+ manager.execute(ADD_INDEX)
+ manager.execute(ADD_FOREIGN_KEY)
+
+
+def migrate_down(manager):
+ """Drop the changes.
+
+ @param manager: A MigrationManager object.
+
+ """
+ manager.execute(DROP_FOREIGN_KEY)
+ manager.execute(DROP_COLUMN)
diff --git a/frontend/tko/models.py b/frontend/tko/models.py
index a9c6bf0..286279b 100644
--- a/frontend/tko/models.py
+++ b/frontend/tko/models.py
@@ -210,6 +210,10 @@
machine = dbmodels.ForeignKey(Machine, db_column='machine_idx')
finished_time = dbmodels.DateTimeField(null=True, blank=True)
started_time = dbmodels.DateTimeField(null=True, blank=True)
+ invalid = dbmodels.BooleanField(default=False)
+ invalidates_test = dbmodels.ForeignKey(
+ 'self', null=True, db_column='invalidates_test_idx',
+ related_name='invalidates_test_set')
objects = model_logic.ExtendedManager()