From c88cd42b39a84d16a056f2b668fd1949c893c4e0 Mon Sep 17 00:00:00 2001 From: Magnus Hagander Date: Tue, 4 Dec 2018 20:53:33 +0100 Subject: [PATCH] Add migration for confreg_status_strings This table is used for status reports (since that data is otherwise in the code and not the db), it should be managed by the code and not by manually putting data in an undocumented table... --- .../confreg/migrations/0037_status_strings.py | 24 +++++++++++++++++++ postgresqleu/confreg/models.py | 3 +++ 2 files changed, 27 insertions(+) create mode 100644 postgresqleu/confreg/migrations/0037_status_strings.py diff --git a/postgresqleu/confreg/migrations/0037_status_strings.py b/postgresqleu/confreg/migrations/0037_status_strings.py new file mode 100644 index 0000000..16614c5 --- /dev/null +++ b/postgresqleu/confreg/migrations/0037_status_strings.py @@ -0,0 +1,24 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.11.10 on 2018-12-04 20:45 +from __future__ import unicode_literals + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('confreg', '0036_htmlicon'), + ] + + operations = [ + migrations.RunSQL("CREATE TABLE IF NOT EXISTS confreg_status_strings(id int not null primary key, statustext text not null, statusgroup text)"), + migrations.RunSQL("""WITH t(id, statustext, statusgroup) AS (VALUES + (0, 'Submitted', NULL), + (1, 'Approved', 'Approved+Pending'), + (2, 'Rejected', NULL), + (3, 'Pending', 'Approved+Pending'), + (4, 'Reserve', NULL)) + INSERT INTO confreg_status_strings (id, statustext, statusgroup) + SELECT id, statustext, statusgroup FROM t ON CONFLICT (id) DO UPDATE SET statustext=excluded.statustext, statusgroup=excluded.statusgroup""") + ] diff --git a/postgresqleu/confreg/models.py b/postgresqleu/confreg/models.py index 8bbc59f..4ed15bd 100644 --- a/postgresqleu/confreg/models.py +++ b/postgresqleu/confreg/models.py @@ -33,6 +33,9 @@ SKILL_CHOICES = ( (2, "Advanced"), ) +# NOTE! The contents of these arrays must also be matched with the +# database table confreg_status_strings. This one is managed by +# manually creating a separate migration in case the contents change. STATUS_CHOICES = ( (0, "Submitted"), (1, "Approved"), -- 2.39.5