change(api): db changes in init

This commit is contained in:
Shekar Siri 2023-07-10 12:34:26 +02:00
parent be55064786
commit 206d56e041

View file

@ -978,13 +978,13 @@ $$
CREATE INDEX projects_stats_project_id_idx ON public.projects_stats (project_id);
CREATE TABLE public.feature_flags
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,
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,
@ -995,9 +995,12 @@ $$
deleted_at timestamp without time zone NULL DEFAULT NULL
);
CREATE INDEX idx_feature_flags_project_id ON public.feature_flags (project_id);
CREATE INDEX IF NOT EXISTS idx_feature_flags_project_id ON public.feature_flags (project_id);
CREATE TABLE public.feature_flags_conditions
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,
@ -1006,6 +1009,16 @@ $$
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
);
CREATE TABLE IF NOT EXISTS public.sessions_feature_flags
(
session_id bigint NOT NULL REFERENCES sessions (session_id) ON DELETE CASCADE,