view schema/updates/0000/01.add_schema_version.sql @ 4004:79adff625ed8

Let psql treat each schema update script as a file No more semicolon required at the end of each script and psql meta-commands such as \ir can be used, which is especially useful to avoid duplicating DDL in update scripts.
author Tom Gottfried <tom@intevation.de>
date Thu, 18 Jul 2019 19:46:19 +0200
parents 7b7c324b318f
children
line wrap: on
line source

CREATE TABLE gemma_schema_version (
    version int PRIMARY KEY,
    update_date timestamp with time zone NOT NULL DEFAULT CURRENT_TIMESTAMP
);

CREATE OR REPLACE FUNCTION get_schema_version() RETURNS int
    LANGUAGE plpgsql
    AS $$
    BEGIN
        RETURN ( SELECT max(version) FROM gemma_schema_version );
    END;
$$;