[autotest] Add migrations for hqe index table

BUG=chromium:704997
TEST=Applied patches locally, tested that event works.

Change-Id: I836c63db94956fa56beb79f0480cbfbc568258ce
Reviewed-on: https://chromium-review.googlesource.com/505175
Commit-Ready: Paul Hobbs <phobbs@google.com>
Tested-by: Paul Hobbs <phobbs@google.com>
Reviewed-by: Aviv Keshet <akeshet@chromium.org>
diff --git a/frontend/migrations/114_add_hqe_start_times.py b/frontend/migrations/114_add_hqe_start_times.py
new file mode 100644
index 0000000..7fce3ff
--- /dev/null
+++ b/frontend/migrations/114_add_hqe_start_times.py
@@ -0,0 +1,13 @@
+UP_SQL = """
+CREATE TABLE afe_host_queue_entry_start_times (
+    id INT NOT NULL AUTO_INCREMENT,
+    insert_time TIMESTAMP NOT NULL,
+    highest_hqe_id INT NOT NULL,
+    PRIMARY KEY (id),
+    INDEX afe_hqe_insert_times_index (insert_time)
+);
+"""
+
+DOWN_SQL = """
+DROP TABLE afe_host_queue_entry_start_times;
+"""
diff --git a/frontend/migrations/115_add_hqe_index_updating_event.py b/frontend/migrations/115_add_hqe_index_updating_event.py
new file mode 100644
index 0000000..653bbaf
--- /dev/null
+++ b/frontend/migrations/115_add_hqe_index_updating_event.py
@@ -0,0 +1,11 @@
+UP_SQL = """
+CREATE EVENT afe_add_entry_to_hqe_start_times
+ON SCHEDULE EVERY 10 MINUTE DO
+INSERT INTO afe_host_queue_entry_start_times (insert_time, highest_hqe_id)
+SELECT NOW(), MAX(afe_host_queue_entries.id)
+FROM afe_host_queue_entries;
+"""
+
+DOWN_SQL = """
+DROP EVENT afe_add_entry_to_hqe_start_times;
+"""