openreplay/scripts/helm/db/init_dbs/postgresql/1.5.99/1.5.99.sql
Taha Yassine Kraiem 3281c4ecac feat(api): definition of metric_type
feat(db): definition of metric_type
2022-02-24 20:32:07 +01:00

26 lines
No EOL
694 B
PL/PgSQL

BEGIN;
CREATE OR REPLACE FUNCTION openreplay_version()
RETURNS text AS
$$
SELECT 'v1.5.X'
$$ LANGUAGE sql IMMUTABLE;
DO
$$
BEGIN
IF NOT EXISTS(SELECT *
FROM pg_type typ
INNER JOIN pg_namespace nsp
ON nsp.oid = typ.typnamespace
WHERE nsp.nspname = current_schema()
AND typ.typname = 'metric_type') THEN
CREATE TYPE metric_type AS ENUM ('timeseries','table');
END IF;
END;
$$
LANGUAGE plpgsql;
ALTER TABLE metrics
ADD COLUMN IF NOT EXISTS
metric_type metric_type NOT NULL DEFAULT 'timeseries';
COMMIT;