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-13 19:20:12 +0100
commitd2cbc43175eeb4a770f7dae2e984df3f994dcfb8 (patch)
tree92c96e8fe050106ddf9779ffde0021210952ef06
parent0cc8dff0f435df5d445dd6253a5d1dbfd8d159d1 (diff)
downloadlorry-controller-d2cbc43175eeb4a770f7dae2e984df3f994dcfb8.tar.gz
statedb: add columns for last failure information
-rw-r--r--lorrycontroller/migrations/0002-add-last_run-status-columns-to-lorries.py20
-rw-r--r--lorrycontroller/statedb.py11
2 files changed, 28 insertions, 3 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..8c62a31 100644
--- a/lorrycontroller/statedb.py
+++ b/lorrycontroller/statedb.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2014-2016 Codethink Limited
+# Copyright (C) 2014-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
@@ -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 = list(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)