From 27bb11e009294e34b7f86e6e172fea1fd2bcc808 Mon Sep 17 00:00:00 2001 From: Taha Yassine Kraiem Date: Wed, 2 Mar 2022 20:15:40 +0100 Subject: [PATCH] feat(DB): add metric_value and metric_format to custom_metrics --- .../db/init_dbs/postgresql/1.5.99/1.5.99.sql | 10 +++++--- .../db/init_dbs/postgresql/init_schema.sql | 24 ++++++++++--------- .../db/init_dbs/postgresql/1.5.99/1.5.99.sql | 10 +++++--- .../db/init_dbs/postgresql/init_schema.sql | 24 ++++++++++--------- 4 files changed, 40 insertions(+), 28 deletions(-) diff --git a/ee/scripts/helm/db/init_dbs/postgresql/1.5.99/1.5.99.sql b/ee/scripts/helm/db/init_dbs/postgresql/1.5.99/1.5.99.sql index e89a97f47..88e1aab74 100644 --- a/ee/scripts/helm/db/init_dbs/postgresql/1.5.99/1.5.99.sql +++ b/ee/scripts/helm/db/init_dbs/postgresql/1.5.99/1.5.99.sql @@ -41,10 +41,14 @@ LANGUAGE plpgsql; ALTER TABLE metrics ADD COLUMN IF NOT EXISTS - metric_type metric_type NOT NULL DEFAULT 'timeseries', + metric_type metric_type NOT NULL DEFAULT 'timeseries', ADD COLUMN IF NOT EXISTS - view_type metric_view_type NOT NULL DEFAULT 'lineChart', + view_type metric_view_type NOT NULL DEFAULT 'lineChart', ADD COLUMN IF NOT EXISTS - metric_of text NOT NULL DEFAULT 'sessionCount'; + metric_of text NOT NULL DEFAULT 'sessionCount', + ADD COLUMN IF NOT EXISTS + metric_value text[] NOT NULL DEFAULT '{}'::text[], + ADD COLUMN IF NOT EXISTS + metric_format text; COMMIT; \ No newline at end of file diff --git a/ee/scripts/helm/db/init_dbs/postgresql/init_schema.sql b/ee/scripts/helm/db/init_dbs/postgresql/init_schema.sql index 2cca09903..1f0f4d6f1 100644 --- a/ee/scripts/helm/db/init_dbs/postgresql/init_schema.sql +++ b/ee/scripts/helm/db/init_dbs/postgresql/init_schema.sql @@ -774,17 +774,19 @@ $$ CREATE TYPE metric_view_type AS ENUM ('lineChart','progress','table','pieChart'); CREATE TABLE IF NOT EXISTS metrics ( - metric_id integer generated BY DEFAULT AS IDENTITY PRIMARY KEY, - project_id integer NOT NULL REFERENCES projects (project_id) ON DELETE CASCADE, - user_id integer REFERENCES users (user_id) ON DELETE SET NULL, - name text NOT NULL, - is_public boolean NOT NULL DEFAULT FALSE, - active boolean NOT NULL DEFAULT TRUE, - created_at timestamp DEFAULT timezone('utc'::text, now()) not null, - deleted_at timestamp, - metric_type metric_type NOT NULL DEFAULT 'timeseries', - view_type metric_view_type NOT NULL DEFAULT 'lineChart', - metric_of text NOT NULL DEFAULT 'sessionCount' + metric_id integer generated BY DEFAULT AS IDENTITY PRIMARY KEY, + project_id integer NOT NULL REFERENCES projects (project_id) ON DELETE CASCADE, + user_id integer REFERENCES users (user_id) ON DELETE SET NULL, + name text NOT NULL, + is_public boolean NOT NULL DEFAULT FALSE, + active boolean NOT NULL DEFAULT TRUE, + created_at timestamp DEFAULT timezone('utc'::text, now()) not null, + deleted_at timestamp, + metric_type metric_type NOT NULL DEFAULT 'timeseries', + view_type metric_view_type NOT NULL DEFAULT 'lineChart', + metric_of text NOT NULL DEFAULT 'sessionCount', + metric_value text[] NOT NULL DEFAULT '{}'::text[], + metric_format text ); CREATE INDEX IF NOT EXISTS metrics_user_id_is_public_idx ON public.metrics (user_id, is_public); CREATE TABLE IF NOT EXISTS metric_series diff --git a/scripts/helm/db/init_dbs/postgresql/1.5.99/1.5.99.sql b/scripts/helm/db/init_dbs/postgresql/1.5.99/1.5.99.sql index 704e08ab5..b471511f4 100644 --- a/scripts/helm/db/init_dbs/postgresql/1.5.99/1.5.99.sql +++ b/scripts/helm/db/init_dbs/postgresql/1.5.99/1.5.99.sql @@ -40,10 +40,14 @@ LANGUAGE plpgsql; ALTER TABLE metrics ADD COLUMN IF NOT EXISTS - metric_type metric_type NOT NULL DEFAULT 'timeseries', + metric_type metric_type NOT NULL DEFAULT 'timeseries', ADD COLUMN IF NOT EXISTS - view_type metric_view_type NOT NULL DEFAULT 'lineChart', + view_type metric_view_type NOT NULL DEFAULT 'lineChart', ADD COLUMN IF NOT EXISTS - metric_of text NOT NULL DEFAULT 'sessionCount'; + metric_of text NOT NULL DEFAULT 'sessionCount', + ADD COLUMN IF NOT EXISTS + metric_value text[] NOT NULL DEFAULT '{}'::text[], + ADD COLUMN IF NOT EXISTS + metric_format text; COMMIT; \ No newline at end of file diff --git a/scripts/helm/db/init_dbs/postgresql/init_schema.sql b/scripts/helm/db/init_dbs/postgresql/init_schema.sql index 51fa20242..232596696 100644 --- a/scripts/helm/db/init_dbs/postgresql/init_schema.sql +++ b/scripts/helm/db/init_dbs/postgresql/init_schema.sql @@ -904,17 +904,19 @@ $$ CREATE TYPE metric_view_type AS ENUM ('lineChart','progress','table','pieChart'); CREATE TABLE metrics ( - metric_id integer generated BY DEFAULT AS IDENTITY PRIMARY KEY, - project_id integer NOT NULL REFERENCES projects (project_id) ON DELETE CASCADE, - user_id integer REFERENCES users (user_id) ON DELETE SET NULL, - name text NOT NULL, - is_public boolean NOT NULL DEFAULT FALSE, - active boolean NOT NULL DEFAULT TRUE, - created_at timestamp default timezone('utc'::text, now()) not null, - deleted_at timestamp, - metric_type metric_type NOT NULL DEFAULT 'timeseries', - view_type metric_view_type NOT NULL DEFAULT 'lineChart', - metric_of text NOT NULL DEFAULT 'sessionCount' + metric_id integer generated BY DEFAULT AS IDENTITY PRIMARY KEY, + project_id integer NOT NULL REFERENCES projects (project_id) ON DELETE CASCADE, + user_id integer REFERENCES users (user_id) ON DELETE SET NULL, + name text NOT NULL, + is_public boolean NOT NULL DEFAULT FALSE, + active boolean NOT NULL DEFAULT TRUE, + created_at timestamp default timezone('utc'::text, now()) not null, + deleted_at timestamp, + metric_type metric_type NOT NULL DEFAULT 'timeseries', + view_type metric_view_type NOT NULL DEFAULT 'lineChart', + metric_of text NOT NULL DEFAULT 'sessionCount', + metric_value text[] NOT NULL DEFAULT '{}'::text[], + metric_format text ); CREATE INDEX metrics_user_id_is_public_idx ON public.metrics (user_id, is_public); CREATE TABLE metric_series