Skip to content

Commit c90cdc2

Browse files
mig: add organization features table (#775)
1 parent 6f5ddb8 commit c90cdc2

File tree

4 files changed

+45
-1
lines changed

4 files changed

+45
-1
lines changed

server/database/schema.sql

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -920,3 +920,22 @@ CREATE TABLE IF NOT EXISTS oauth_proxy_client_info (
920920

921921
CONSTRAINT oauth_proxy_client_info_pkey PRIMARY KEY (client_id)
922922
);
923+
924+
-- Table storing organization feature flags with soft deletes for disabled features
925+
CREATE TABLE IF NOT EXISTS organization_features (
926+
id BIGINT NOT NULL GENERATED BY DEFAULT AS IDENTITY,
927+
928+
organization_id TEXT NOT NULL,
929+
feature_name TEXT NOT NULL CHECK (feature_name <> '' AND CHAR_LENGTH(feature_name) <= 60),
930+
931+
created_at timestamptz NOT NULL DEFAULT clock_timestamp(),
932+
updated_at timestamptz NOT NULL DEFAULT clock_timestamp(),
933+
deleted_at timestamptz,
934+
deleted boolean NOT NULL GENERATED ALWAYS AS (deleted_at IS NOT NULL) stored,
935+
936+
CONSTRAINT organization_features_pkey PRIMARY KEY (id)
937+
);
938+
939+
CREATE UNIQUE INDEX IF NOT EXISTS organization_features_organization_id_feature_name_key
940+
ON organization_features (organization_id, feature_name)
941+
WHERE deleted IS FALSE;

server/internal/database/models.go

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
-- Create "organization_features" table
2+
CREATE TABLE "organization_features" (
3+
"id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY,
4+
"organization_id" text NOT NULL,
5+
"feature_name" text NOT NULL,
6+
"created_at" timestamptz NOT NULL DEFAULT clock_timestamp(),
7+
"updated_at" timestamptz NOT NULL DEFAULT clock_timestamp(),
8+
"deleted_at" timestamptz NULL,
9+
"deleted" boolean NOT NULL GENERATED ALWAYS AS (deleted_at IS NOT NULL) STORED,
10+
PRIMARY KEY ("id"),
11+
CONSTRAINT "organization_features_feature_name_check" CHECK ((feature_name <> ''::text) AND (char_length(feature_name) <= 60))
12+
);
13+
-- Create index "organization_features_organization_id_feature_name_key" to table: "organization_features"
14+
CREATE UNIQUE INDEX "organization_features_organization_id_feature_name_key" ON "organization_features" ("organization_id", "feature_name") WHERE (deleted IS FALSE);

server/migrations/atlas.sum

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
h1:QjGbwRxAeg8p694zCtDZaELMdzW8xGA8wxKMbPmW5Us=
1+
h1:ZyHM0gFiyq2OI01kLiietbApvPxDijo126vjSA9h9+Y=
22
20250502122425_initial-tables.sql h1:Hu3O60/bB4fjZpUay8FzyOjw6vngp087zU+U/wVKn7k=
33
20250502130852_initial-indexes.sql h1:oYbnwi9y9PPTqu7uVbSPSALhCY8XF3rv03nDfG4b7mo=
44
20250502154250_relax-http-security-fields.sql h1:0+OYIDq7IHmx7CP5BChVwfpF2rOSrRDxnqawXio2EVo=
@@ -63,3 +63,4 @@ h1:QjGbwRxAeg8p694zCtDZaELMdzW8xGA8wxKMbPmW5Us=
6363
20251020180734_prompt_templates_tool_urns.sql h1:ESuIMO0ROfJmpfvBatZMPx+6fmn2RAlQV7LWi/zJhFw=
6464
20251022000919_disabled-org.sql h1:IKFwsEKFnL0wOpwi8IQKchiV7WwzsLzrF8fqh+BwlNc=
6565
20251023235208_add_meta_tags_to_datamodel.sql h1:pQtvf+I0G7Y66RxxsHLyR0HzbsfNSeF0UpqgsIeRl5k=
66+
20251105184547_add-organization-features-table.sql h1:1OTlrIlL1jagd9BRvB1hO3B7c+1XRMvHhw1GSGKPPWA=

0 commit comments

Comments
 (0)