[autotest] Make explicit that lock_reason of AbstractHostModel can be NULL.
lock_reason of AbstractHostModel didn't specify null property explicitly.
The effect of it is MySQL has NULL property for lock_reason column, but
Sqlite doesn't have NULL property for the column.
simple_heartbeat_client.py uses in-memory sqlite, and it produces error
like below.
django.db.utils.IntegrityError: NOT NULL constraint failed: afe_hosts.lock_reason
This means a host entry got from prod database has NULL lock_reason,
and it violates integrity for sqlite DB.
We should make it explicit that lock_reason column can be NULL.
BUG=None
TEST=Run simple_heartbeat_client.py in local machine.
Change-Id: Ic2bdb35cff17cf8c1789db78c7166a404610827b
Reviewed-on: https://chromium-review.googlesource.com/304577
Commit-Ready: Mungyung Ryu <mkryu@google.com>
Tested-by: Mungyung Ryu <mkryu@google.com>
Reviewed-by: Matthew Sartori <msartori@chromium.org>
Reviewed-by: Dan Shi <dshi@chromium.org>
diff --git a/frontend/afe/rdb_model_extensions.py b/frontend/afe/rdb_model_extensions.py
index 519ec7b..3ede922 100644
--- a/frontend/afe/rdb_model_extensions.py
+++ b/frontend/afe/rdb_model_extensions.py
@@ -179,6 +179,7 @@
protection: indicates what can be done to this host during repair
lock_time: DateTime at which the host was locked
dirty: true if the host has been used without being rebooted
+ lock_reason: The reason for locking the host.
"""
Status = host_states.Status
hostname = dbmodels.CharField(max_length=255, unique=True)
@@ -196,10 +197,9 @@
default=host_protections.default)
lock_time = dbmodels.DateTimeField(null=True, blank=True, editable=False)
dirty = dbmodels.BooleanField(default=True, editable=settings.FULL_ADMIN)
- lock_reason = dbmodels.CharField(max_length=255, blank=True, default='')
+ lock_reason = dbmodels.CharField(null=True, max_length=255, blank=True,
+ default='')
class Meta:
abstract = True
-
-