From 0b95d26b402979347f8f259555bc08734f017b72 Mon Sep 17 00:00:00 2001 From: Kraiem Taha Yassine Date: Tue, 11 Jul 2023 17:46:00 +0200 Subject: [PATCH] Api v1.14.0 (#1407) * fix(DB): fixed feature-flag's payload type --- api/chalicelib/core/feature_flags.py | 5 +++-- ee/scripts/schema/db/init_dbs/postgresql/1.14.0/1.14.0.sql | 2 +- ee/scripts/schema/db/init_dbs/postgresql/init_schema.sql | 2 +- scripts/schema/db/init_dbs/postgresql/1.14.0/1.14.0.sql | 6 +++--- scripts/schema/db/init_dbs/postgresql/init_schema.sql | 2 +- 5 files changed, 9 insertions(+), 8 deletions(-) diff --git a/api/chalicelib/core/feature_flags.py b/api/chalicelib/core/feature_flags.py index bcefcb92a..099eb2f9e 100644 --- a/api/chalicelib/core/feature_flags.py +++ b/api/chalicelib/core/feature_flags.py @@ -327,10 +327,10 @@ def update_feature_flag(project_id: int, feature_flag_id: int, ) params = { + **feature_flag.dict(), "updated_by": user_id, "feature_flag_id": feature_flag_id, "project_id": project_id, - **feature_flag.dict(), "payload": json.dumps(feature_flag.payload), } @@ -455,7 +455,8 @@ def create_variants(feature_flag_id: int, variants: List[schemas.FeatureFlagVari """ with pg_client.PostgresClient() as cur: - params = [(feature_flag_id, v.value, v.description, json.dumps(v.payload), v.rollout_percentage) for v in variants] + params = [(feature_flag_id, v.value, v.description, json.dumps(v.payload), v.rollout_percentage) for v in + variants] query = cur.mogrify(sql, params) cur.execute(query) rows = cur.fetchall() diff --git a/ee/scripts/schema/db/init_dbs/postgresql/1.14.0/1.14.0.sql b/ee/scripts/schema/db/init_dbs/postgresql/1.14.0/1.14.0.sql index 527f8bfd1..76f42aa88 100644 --- a/ee/scripts/schema/db/init_dbs/postgresql/1.14.0/1.14.0.sql +++ b/ee/scripts/schema/db/init_dbs/postgresql/1.14.0/1.14.0.sql @@ -25,7 +25,7 @@ CREATE TABLE IF NOT EXISTS public.feature_flags project_id integer NOT NULL REFERENCES projects (project_id) ON DELETE CASCADE, flag_key text NOT NULL, description text DEFAULT NULL, - payload text DEFAULT NULL, + payload jsonb DEFAULT NULL, flag_type text NOT NULL, is_persist boolean NOT NULL DEFAULT FALSE, is_active boolean NOT NULL DEFAULT FALSE, 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 d516c35f5..dffbd81f4 100644 --- a/ee/scripts/schema/db/init_dbs/postgresql/init_schema.sql +++ b/ee/scripts/schema/db/init_dbs/postgresql/init_schema.sql @@ -903,7 +903,7 @@ $$ project_id integer NOT NULL REFERENCES projects (project_id) ON DELETE CASCADE, flag_key text NOT NULL, description text DEFAULT NULL, - payload text DEFAULT NULL, + payload jsonb DEFAULT NULL, flag_type text NOT NULL, is_persist boolean NOT NULL DEFAULT FALSE, is_active boolean NOT NULL DEFAULT FALSE, diff --git a/scripts/schema/db/init_dbs/postgresql/1.14.0/1.14.0.sql b/scripts/schema/db/init_dbs/postgresql/1.14.0/1.14.0.sql index a31b340ff..7dba13f6a 100644 --- a/scripts/schema/db/init_dbs/postgresql/1.14.0/1.14.0.sql +++ b/scripts/schema/db/init_dbs/postgresql/1.14.0/1.14.0.sql @@ -24,8 +24,8 @@ 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, + description text DEFAULT NULL, + payload jsonb DEFAULT NULL, flag_type text NOT NULL, is_persist boolean NOT NULL DEFAULT FALSE, is_active boolean NOT NULL DEFAULT FALSE, @@ -55,7 +55,7 @@ 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, + description text DEFAULT NULL, payload jsonb DEFAULT NULL, rollout_percentage integer DEFAULT 0 ); diff --git a/scripts/schema/db/init_dbs/postgresql/init_schema.sql b/scripts/schema/db/init_dbs/postgresql/init_schema.sql index 152603612..234826973 100644 --- a/scripts/schema/db/init_dbs/postgresql/init_schema.sql +++ b/scripts/schema/db/init_dbs/postgresql/init_schema.sql @@ -983,7 +983,7 @@ $$ project_id integer NOT NULL REFERENCES projects (project_id) ON DELETE CASCADE, flag_key text NOT NULL, description text DEFAULT NULL, - payload text DEFAULT NULL, + payload jsonb DEFAULT NULL, flag_type text NOT NULL, is_persist boolean NOT NULL DEFAULT FALSE, is_active boolean NOT NULL DEFAULT FALSE,