From edfbc14a6a662b52eb6f1d9287f5c348d84461d7 Mon Sep 17 00:00:00 2001
From: Martin Mares <mj@ucw.cz>
Date: Sat, 16 Jan 2021 15:01:52 +0100
Subject: [PATCH] =?UTF-8?q?DB:=20Job=20m=C3=A1=20sloupe=C4=8Dek=20"result"?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 db/db.ddl               | 6 ++++--
 db/upgrade-20210116.sql | 3 +++
 mo/db.py                | 1 +
 3 files changed, 8 insertions(+), 2 deletions(-)
 create mode 100644 db/upgrade-20210116.sql

diff --git a/db/db.ddl b/db/db.ddl
index 52b984df..e4bb437a 100644
--- a/db/db.ddl
+++ b/db/db.ddl
@@ -262,10 +262,12 @@ CREATE TABLE jobs (
 	created_at	timestamp with time zone	NOT NULL DEFAULT CURRENT_TIMESTAMP,	-- kdy byl založen
 	finished_at	timestamp with time zone	DEFAULT NULL,				-- kdy doběhl
 	expires_at	timestamp with time zone	DEFAULT NULL,				-- kdy bude automaticky smazán
-	description	text		NOT NULL DEFAULT '',
+	description	text		NOT NULL DEFAULT '',					-- popis jobu
+	result		text		NOT NULL DEFAULT '',					-- jednořádková zpráva o výsledku
+	-- Vstupní parametry a výsledky jobu
 	in_json		jsonb		DEFAULT NULL,
 	out_json	jsonb		DEFAULT NULL,
-	-- Soubory jsou součástí úlohy a po jejím ukončení budou smazány
+	-- Soubory jsou součástí úlohy a po její expiraci budou smazány
 	in_file		varchar(255)	DEFAULT NULL,
 	out_file	varchar(255)	DEFAULT NULL
 );
diff --git a/db/upgrade-20210116.sql b/db/upgrade-20210116.sql
new file mode 100644
index 00000000..4c4ab81e
--- /dev/null
+++ b/db/upgrade-20210116.sql
@@ -0,0 +1,3 @@
+SET ROLE 'mo_osmo';
+
+ALTER TABLE jobs ADD COLUMN result text NOT NULL DEFAULT '';
diff --git a/mo/db.py b/mo/db.py
index cd9d0a39..2ec74c78 100644
--- a/mo/db.py
+++ b/mo/db.py
@@ -496,6 +496,7 @@ class Job(Base):
     state = Column(Enum(JobState, name='job_state'), nullable=False)
     user_id = Column(Integer, ForeignKey('users.user_id'), nullable=False)
     description = Column(Text, nullable=False, server_default=text("''::text"))
+    result = Column(Text, nullable=False, server_default=text("''::text"))
     created_at = Column(DateTime(True), nullable=False, server_default=text("CURRENT_TIMESTAMP"))
     finished_at = Column(DateTime(True))
     expires_at = Column(DateTime(True))
-- 
GitLab