summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPedro Alvarez Piedehierro <palvarez89@gmail.com>2017-07-08 03:21:17 +0100
committerPedro Alvarez Piedehierro <palvarez89@gmail.com>2017-07-08 03:21:51 +0100
commitcfbd91e737198757c6b2fd876a248da7256bf86e (patch)
tree0389eea23f5049f0e51408d9abe60e76372834c9
parent4904757576053be163bc51cd8a2883ef6fea108a (diff)
downloadlorry-controller-cfbd91e737198757c6b2fd876a248da7256bf86e.tar.gz
statedb: add colums for last failure information
-rw-r--r--lorrycontroller/migrations/0002-add-last_run-status-columns-to-lorries.py20
-rw-r--r--lorrycontroller/statedb.py9
2 files changed, 27 insertions, 2 deletions
diff --git a/lorrycontroller/migrations/0002-add-last_run-status-columns-to-lorries.py b/lorrycontroller/migrations/0002-add-last_run-status-columns-to-lorries.py
new file mode 100644
index 0000000..ce30edf
--- /dev/null
+++ b/lorrycontroller/migrations/0002-add-last_run-status-columns-to-lorries.py
@@ -0,0 +1,20 @@
+# Copyright (C) 2017 Codethink Limited
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; version 2 of the License.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+
+import yoyo
+
+yoyo.step('ALTER TABLE lorries ADD COLUMN last_run_exit')
+yoyo.step('ALTER TABLE lorries ADD COLUMN last_run_error')
diff --git a/lorrycontroller/statedb.py b/lorrycontroller/statedb.py
index 1b885d9..923a0b8 100644
--- a/lorrycontroller/statedb.py
+++ b/lorrycontroller/statedb.py
@@ -57,7 +57,7 @@ class StateDB(object):
self._transaction_started = None
def _open(self):
- self.lorries_fields = [
+ self.initial_lorries_fields = [
('path', 'TEXT PRIMARY KEY'),
('text', 'TEXT'),
('from_trovehost', 'TEXT'),
@@ -68,6 +68,11 @@ class StateDB(object):
('lorry_timeout', 'INT'),
('disk_usage', 'INT'),
]
+ self.lorries_fields = self.initial_lorries_fields[:]
+ self.lorries_fields.extend([
+ ('last_run_exit', 'TEXT'),
+ ('last_run_error', 'TEXT'),
+ ])
self.lorries_booleans = [
]
@@ -118,7 +123,7 @@ class StateDB(object):
# Table for all the known lorries (the "run queue").
fields_sql = ', '.join(
- '%s %s' % (name, info) for name, info in self.lorries_fields
+ '%s %s' % (name, info) for name, info in self.initial_lorries_fields
)
c.execute('CREATE TABLE lorries (%s)' % fields_sql)