[autotest] Remove synch_id from database

BUG=chromium:687781
TEST=Run migrate.py sync back and forth

Change-Id: Ieed2052c9aa6958cf3fb6081ee310499c233d112
Reviewed-on: https://chromium-review.googlesource.com/449972
Reviewed-by: Allen Li <ayatane@chromium.org>
Commit-Queue: Allen Li <ayatane@chromium.org>
Tested-by: Allen Li <ayatane@chromium.org>
diff --git a/frontend/afe/doctests/001_rpc_test.txt b/frontend/afe/doctests/001_rpc_test.txt
index 89e29d6..c944353 100644
--- a/frontend/afe/doctests/001_rpc_test.txt
+++ b/frontend/afe/doctests/001_rpc_test.txt
@@ -109,7 +109,6 @@
 >>> data == [{'id': 1,
 ...           'hostname': 'ipaj1',
 ...           'locked': 1,
-...           'synch_id': None,
 ...           'status': 'Ready',
 ...           'labels': [],
 ...           'atomic_group': None,
@@ -470,7 +469,6 @@
 ...           'invalid': 0,
 ...           'locked': 0,
 ...           'status': 'Ready',
-...           'synch_id': None,
 ...           'protection': 'No protection',
 ...           'locked_by': None,
 ...           'lock_time': None,
diff --git a/frontend/afe/models_test.py b/frontend/afe/models_test.py
index 62f2423..d5ad198 100755
--- a/frontend/afe/models_test.py
+++ b/frontend/afe/models_test.py
@@ -4,9 +4,12 @@
 import unittest
 
 import common
+from autotest_lib.client.common_lib import control_data
+from autotest_lib.client.common_lib import global_config
 from autotest_lib.frontend import setup_django_environment
 from autotest_lib.frontend.afe import frontend_test_utils
-from autotest_lib.frontend.afe import models, model_logic
+from autotest_lib.frontend.afe import model_logic
+from autotest_lib.frontend.afe import models
 
 
 class AclGroupTest(unittest.TestCase,
@@ -356,8 +359,7 @@
                            'locked': False,
                            'protection': 0,
                            'shard': {'hostname': '1', 'id': 1},
-                           'status': 'Ready',
-                           'synch_id': None}],
+                           'status': 'Ready'}],
                 'jobs': [{'control_file': 'some control file\n\n\n',
                           'control_type': 2,
                           'created_on': '2014-09-04T13:09:35',
diff --git a/frontend/afe/rdb_model_extensions.py b/frontend/afe/rdb_model_extensions.py
index 12ba892..4444122 100644
--- a/frontend/afe/rdb_model_extensions.py
+++ b/frontend/afe/rdb_model_extensions.py
@@ -184,9 +184,6 @@
     hostname = dbmodels.CharField(max_length=255, unique=True)
     locked = dbmodels.BooleanField(default=False)
     leased = dbmodels.BooleanField(default=True)
-    # TODO(ayatane): This is needed until synch_id is removed from Host._fields
-    synch_id = dbmodels.IntegerField(blank=True, null=True,
-                                     editable=settings.FULL_ADMIN)
     status = dbmodels.CharField(max_length=255, default=Status.READY,
                                 choices=Status.choices(),
                                 editable=settings.FULL_ADMIN)
diff --git a/frontend/migrations/112_remove_synch_id.py b/frontend/migrations/112_remove_synch_id.py
new file mode 100644
index 0000000..8dc5e18
--- /dev/null
+++ b/frontend/migrations/112_remove_synch_id.py
@@ -0,0 +1,7 @@
+UP_SQL = """
+ALTER TABLE `afe_hosts` DROP COLUMN `synch_id`;
+"""
+
+DOWN_SQL = """
+ALTER TABLE `afe_hosts` ADD `synch_id` int(11) default NULL;
+"""
diff --git a/scheduler/scheduler_models.py b/scheduler/scheduler_models.py
index 60436b8..80c8a47 100644
--- a/scheduler/scheduler_models.py
+++ b/scheduler/scheduler_models.py
@@ -390,8 +390,7 @@
 
 class Host(DBObject):
     _table_name = 'afe_hosts'
-    # TODO(ayatane): synch_id is not used, remove after fixing DB.
-    _fields = ('id', 'hostname', 'locked', 'synch_id', 'status',
+    _fields = ('id', 'hostname', 'locked', 'status',
                'invalid', 'protection', 'locked_by_id', 'lock_time', 'dirty',
                'leased', 'shard_id', 'lock_reason')