From b98b30725f1ef860319a3a4b1ea14941aa8cd9dd Mon Sep 17 00:00:00 2001 From: Kraiem Taha Yassine Date: Thu, 22 Jun 2023 11:57:01 +0100 Subject: [PATCH] refactored(chalice): removed feature-flags (#1357) (#1358) refactored(DB): removed feature-flags (cherry picked from commit d6990a841c89b41d10f7751b8771fe00fe084f04) --- api/routers/core.py | 2 +- .../db/init_dbs/postgresql/1.13.0/1.13.0.sql | 32 --------------- .../db/init_dbs/postgresql/init_schema.sql | 28 ------------- .../db/init_dbs/postgresql/1.13.0/1.13.0.sql | 41 ------------------- .../db/init_dbs/postgresql/init_schema.sql | 28 ------------- 5 files changed, 1 insertion(+), 130 deletions(-) diff --git a/api/routers/core.py b/api/routers/core.py index e71ad36f8..7209291a5 100644 --- a/api/routers/core.py +++ b/api/routers/core.py @@ -9,7 +9,7 @@ from chalicelib.core import log_tool_rollbar, sourcemaps, events, sessions_assig log_tool_stackdriver, reset_password, log_tool_cloudwatch, log_tool_sentry, log_tool_sumologic, log_tools, sessions, \ log_tool_newrelic, announcements, log_tool_bugsnag, weekly_report, integration_jira_cloud, integration_github, \ assist, mobile, tenants, boarding, notifications, webhook, users, \ - custom_metrics, saved_search, integrations_global, feature_flags + custom_metrics, saved_search, integrations_global from chalicelib.core.collaboration_msteams import MSTeams from chalicelib.core.collaboration_slack import Slack from or_dependencies import OR_context diff --git a/ee/scripts/schema/db/init_dbs/postgresql/1.13.0/1.13.0.sql b/ee/scripts/schema/db/init_dbs/postgresql/1.13.0/1.13.0.sql index 2012dbc34..ecddd067b 100644 --- a/ee/scripts/schema/db/init_dbs/postgresql/1.13.0/1.13.0.sql +++ b/ee/scripts/schema/db/init_dbs/postgresql/1.13.0/1.13.0.sql @@ -19,38 +19,6 @@ $fn_def$, :'next_version') -- -CREATE TABLE IF NOT EXISTS public.feature_flags -( - feature_flag_id integer generated BY DEFAULT AS IDENTITY PRIMARY KEY, - project_id integer NOT NULL REFERENCES projects (project_id) ON DELETE CASCADE, - name text NOT NULL, - flag_key text NOT NULL, - description text NOT NULL, - flag_type text NOT NULL, - is_persist boolean NOT NULL DEFAULT FALSE, - is_active boolean NOT NULL DEFAULT FALSE, - created_by integer REFERENCES users (user_id) ON DELETE SET NULL, - updated_by integer REFERENCES users (user_id) ON DELETE SET NULL, - created_at timestamp without time zone NOT NULL DEFAULT timezone('utc'::text, now()), - updated_at timestamp without time zone NOT NULL DEFAULT timezone('utc'::text, now()), - deleted_at timestamp without time zone NULL DEFAULT NULL -); - -CREATE INDEX IF NOT EXISTS idx_feature_flags_project_id ON public.feature_flags (project_id); - -CREATE TABLE IF NOT EXISTS public.feature_flags_conditions -( - condition_id integer generated BY DEFAULT AS IDENTITY PRIMARY KEY, - feature_flag_id integer NOT NULL REFERENCES feature_flags (feature_flag_id) ON DELETE CASCADE, - name text NOT NULL, - rollout_percentage integer NOT NULL, - filters jsonb NOT NULL DEFAULT '[]'::jsonb -); - -UPDATE public.roles -SET permissions = (SELECT array_agg(distinct e) FROM unnest(permissions || '{FEATURE_FLAGS}') AS e) -where not permissions @> '{FEATURE_FLAGS}'; - ALTER TABLE IF EXISTS public.frontend_signals ADD COLUMN IF NOT EXISTS session_id integer NULL REFERENCES sessions (session_id) ON DELETE SET NULL; diff --git a/ee/scripts/schema/db/init_dbs/postgresql/init_schema.sql b/ee/scripts/schema/db/init_dbs/postgresql/init_schema.sql index 33df04bea..f68281a12 100644 --- a/ee/scripts/schema/db/init_dbs/postgresql/init_schema.sql +++ b/ee/scripts/schema/db/init_dbs/postgresql/init_schema.sql @@ -895,34 +895,6 @@ $$ CREATE INDEX IF NOT EXISTS projects_stats_project_id_idx ON public.projects_stats (project_id); - CREATE TABLE IF NOT EXISTS public.feature_flags - ( - feature_flag_id integer generated BY DEFAULT AS IDENTITY PRIMARY KEY, - project_id integer NOT NULL REFERENCES projects (project_id) ON DELETE CASCADE, - name text NOT NULL, - flag_key text NOT NULL, - description text NOT NULL, - flag_type text NOT NULL, - is_persist boolean NOT NULL DEFAULT FALSE, - is_active boolean NOT NULL DEFAULT FALSE, - created_by integer REFERENCES users (user_id) ON DELETE SET NULL, - updated_by integer REFERENCES users (user_id) ON DELETE SET NULL, - created_at timestamp without time zone NOT NULL DEFAULT timezone('utc'::text, now()), - updated_at timestamp without time zone NOT NULL DEFAULT timezone('utc'::text, now()), - deleted_at timestamp without time zone NULL DEFAULT NULL - ); - - CREATE INDEX IF NOT EXISTS idx_feature_flags_project_id ON public.feature_flags (project_id); - - CREATE TABLE IF NOT EXISTS public.feature_flags_conditions - ( - condition_id integer generated BY DEFAULT AS IDENTITY PRIMARY KEY, - feature_flag_id integer NOT NULL REFERENCES feature_flags (feature_flag_id) ON DELETE CASCADE, - name text NOT NULL, - rollout_percentage integer NOT NULL, - filters jsonb NOT NULL DEFAULT '[]'::jsonb - ); - RAISE NOTICE 'Created missing public schema tables'; END IF; END; diff --git a/scripts/schema/db/init_dbs/postgresql/1.13.0/1.13.0.sql b/scripts/schema/db/init_dbs/postgresql/1.13.0/1.13.0.sql index aa194ee21..f1d0c63e6 100644 --- a/scripts/schema/db/init_dbs/postgresql/1.13.0/1.13.0.sql +++ b/scripts/schema/db/init_dbs/postgresql/1.13.0/1.13.0.sql @@ -19,47 +19,6 @@ $fn_def$, :'next_version') -- -CREATE TABLE IF NOT EXISTS public.feature_flags -( - feature_flag_id integer generated BY DEFAULT AS IDENTITY PRIMARY KEY, - project_id integer NOT NULL REFERENCES projects (project_id) ON DELETE CASCADE, - flag_key text NOT NULL, - description text DEFAULT NULL::text, - payload text DEFAULT NULL::text, - flag_type text NOT NULL, - is_persist boolean NOT NULL DEFAULT FALSE, - is_active boolean NOT NULL DEFAULT FALSE, - created_by integer REFERENCES users (user_id) ON DELETE SET NULL, - updated_by integer REFERENCES users (user_id) ON DELETE SET NULL, - created_at timestamp without time zone NOT NULL DEFAULT timezone('utc'::text, now()), - updated_at timestamp without time zone NOT NULL DEFAULT timezone('utc'::text, now()), - deleted_at timestamp without time zone NULL DEFAULT NULL -); - -CREATE INDEX IF NOT EXISTS idx_feature_flags_project_id ON public.feature_flags (project_id); - -ALTER TABLE feature_flags - ADD CONSTRAINT unique_project_flag_deleted UNIQUE (project_id, flag_key, deleted_at); - -CREATE TABLE IF NOT EXISTS public.feature_flags_conditions -( - condition_id integer generated BY DEFAULT AS IDENTITY PRIMARY KEY, - feature_flag_id integer NOT NULL REFERENCES feature_flags (feature_flag_id) ON DELETE CASCADE, - name text NOT NULL, - rollout_percentage integer NOT NULL, - filters jsonb NOT NULL DEFAULT '[]'::jsonb -); - -CREATE TABLE IF NOT EXISTS public.feature_flags_variants -( - variant_id integer generated BY DEFAULT AS IDENTITY PRIMARY KEY, - feature_flag_id integer NOT NULL REFERENCES feature_flags (feature_flag_id) ON DELETE CASCADE, - value text NOT NULL, - description text DEFAULT NULL::text, - payload jsonb DEFAULT NULL, - rollout_percentage integer DEFAULT 0 -); - ALTER TABLE IF EXISTS public.sessions ADD COLUMN IF NOT EXISTS user_city text, ADD COLUMN IF NOT EXISTS user_state text; diff --git a/scripts/schema/db/init_dbs/postgresql/init_schema.sql b/scripts/schema/db/init_dbs/postgresql/init_schema.sql index e9557d0ee..4b046890f 100644 --- a/scripts/schema/db/init_dbs/postgresql/init_schema.sql +++ b/scripts/schema/db/init_dbs/postgresql/init_schema.sql @@ -978,34 +978,6 @@ $$ CREATE INDEX projects_stats_project_id_idx ON public.projects_stats (project_id); - CREATE TABLE public.feature_flags - ( - feature_flag_id integer generated BY DEFAULT AS IDENTITY PRIMARY KEY, - project_id integer NOT NULL REFERENCES projects (project_id) ON DELETE CASCADE, - name text NOT NULL, - flag_key text NOT NULL, - description text NOT NULL, - flag_type text NOT NULL, - is_persist boolean NOT NULL DEFAULT FALSE, - is_active boolean NOT NULL DEFAULT FALSE, - created_by integer REFERENCES users (user_id) ON DELETE SET NULL, - updated_by integer REFERENCES users (user_id) ON DELETE SET NULL, - created_at timestamp without time zone NOT NULL DEFAULT timezone('utc'::text, now()), - updated_at timestamp without time zone NOT NULL DEFAULT timezone('utc'::text, now()), - deleted_at timestamp without time zone NULL DEFAULT NULL - ); - - CREATE INDEX idx_feature_flags_project_id ON public.feature_flags (project_id); - - CREATE TABLE public.feature_flags_conditions - ( - condition_id integer generated BY DEFAULT AS IDENTITY PRIMARY KEY, - feature_flag_id integer NOT NULL REFERENCES feature_flags (feature_flag_id) ON DELETE CASCADE, - name text NOT NULL, - rollout_percentage integer NOT NULL, - filters jsonb NOT NULL DEFAULT '[]'::jsonb - ); - raise notice 'DB created'; END IF; END;