view schema/updates/1433/01.add_state.sql @ 5560:f2204f91d286

Join the log lines of imports to the log exports to recover data from them. Used in SR export to extract information that where in the meta json but now are only found in the log.
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Wed, 09 Feb 2022 18:34:40 +0100
parents 38491057807b
children
line wrap: on
line source

-- DROP and re-CREATE type because adding a value isn't possible in transaction
-- https://www.postgresql.org/docs/11/sql-altertype.html#id-1.9.3.42.7

ALTER TABLE import.imports
    ALTER COLUMN state DROP DEFAULT,
    ALTER COLUMN state TYPE varchar;

DROP TYPE import_state;

CREATE TYPE import_state AS ENUM (
    'queued',
    'running',
    'failed', 'unchanged', 'pending',
    'accepted', 'declined', 'reviewed'
);

ALTER TABLE import.imports
    ALTER COLUMN state TYPE import_state USING CAST(state AS import_state),
    ALTER COLUMN state SET DEFAULT 'queued';