annotate schema/updates/1431/01.add_state.sql @ 5115:bb5459faadb7 queued-stage-done

Dont leave old jobs behind if retrying remove jobs.
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Wed, 25 Mar 2020 18:02:46 +0100
parents 13fff84c2b70
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
5106
13fff84c2b70 Fix database migration
Tom Gottfried <tom@intevation.de>
parents: 5097
diff changeset
1 -- DROP and re-CREATE type because adding a value isn't possible in transaction
13fff84c2b70 Fix database migration
Tom Gottfried <tom@intevation.de>
parents: 5097
diff changeset
2 -- https://www.postgresql.org/docs/11/sql-altertype.html#id-1.9.3.42.7
13fff84c2b70 Fix database migration
Tom Gottfried <tom@intevation.de>
parents: 5097
diff changeset
3
13fff84c2b70 Fix database migration
Tom Gottfried <tom@intevation.de>
parents: 5097
diff changeset
4 ALTER TABLE import.imports
13fff84c2b70 Fix database migration
Tom Gottfried <tom@intevation.de>
parents: 5097
diff changeset
5 ALTER COLUMN state DROP DEFAULT,
13fff84c2b70 Fix database migration
Tom Gottfried <tom@intevation.de>
parents: 5097
diff changeset
6 ALTER COLUMN state TYPE varchar;
13fff84c2b70 Fix database migration
Tom Gottfried <tom@intevation.de>
parents: 5097
diff changeset
7
13fff84c2b70 Fix database migration
Tom Gottfried <tom@intevation.de>
parents: 5097
diff changeset
8 DROP TYPE import_state;
13fff84c2b70 Fix database migration
Tom Gottfried <tom@intevation.de>
parents: 5097
diff changeset
9
13fff84c2b70 Fix database migration
Tom Gottfried <tom@intevation.de>
parents: 5097
diff changeset
10 CREATE TYPE import_state AS ENUM (
13fff84c2b70 Fix database migration
Tom Gottfried <tom@intevation.de>
parents: 5097
diff changeset
11 'queued',
13fff84c2b70 Fix database migration
Tom Gottfried <tom@intevation.de>
parents: 5097
diff changeset
12 'running',
13fff84c2b70 Fix database migration
Tom Gottfried <tom@intevation.de>
parents: 5097
diff changeset
13 'failed', 'unchanged', 'pending',
13fff84c2b70 Fix database migration
Tom Gottfried <tom@intevation.de>
parents: 5097
diff changeset
14 'accepted', 'declined', 'reviewed'
13fff84c2b70 Fix database migration
Tom Gottfried <tom@intevation.de>
parents: 5097
diff changeset
15 );
13fff84c2b70 Fix database migration
Tom Gottfried <tom@intevation.de>
parents: 5097
diff changeset
16
13fff84c2b70 Fix database migration
Tom Gottfried <tom@intevation.de>
parents: 5097
diff changeset
17 ALTER TABLE import.imports
13fff84c2b70 Fix database migration
Tom Gottfried <tom@intevation.de>
parents: 5097
diff changeset
18 ALTER COLUMN state TYPE import_state USING CAST(state AS import_state),
13fff84c2b70 Fix database migration
Tom Gottfried <tom@intevation.de>
parents: 5097
diff changeset
19 ALTER COLUMN state SET DEFAULT 'queued';