From adfe76e6011f4b474428001a76bf7f221c00077f Mon Sep 17 00:00:00 2001 From: Andreas Thomas Date: Sat, 14 Oct 2023 10:36:25 +0200 Subject: [PATCH] fix: workspace default features (#399) --- apps/agent/pkg/database/schema.sql | 2 +- internal/db/src/schema/workspaces.ts | 16 ++++++++++------ 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/apps/agent/pkg/database/schema.sql b/apps/agent/pkg/database/schema.sql index 46a2a1f755..d34916b8e2 100644 --- a/apps/agent/pkg/database/schema.sql +++ b/apps/agent/pkg/database/schema.sql @@ -13,4 +13,4 @@ CREATE TABLE `vercel_bindings` (`id` varchar(256) NOT NULL, `integration_id` var -- Create "vercel_integrations" table CREATE TABLE `vercel_integrations` (`id` varchar(256) NOT NULL, `workspace_id` varchar(256) NOT NULL, `team_id` varchar(256) NULL, `access_token` varchar(256) NOT NULL, PRIMARY KEY (`id`)) CHARSET utf8mb4 COLLATE utf8mb4_0900_ai_ci; -- Create "workspaces" table -CREATE TABLE `workspaces` (`id` varchar(256) NOT NULL, `name` varchar(256) NOT NULL, `slug` varchar(256) NULL, `tenant_id` varchar(256) NOT NULL, `stripe_customer_id` varchar(256) NULL, `stripe_subscription_id` varchar(256) NULL, `plan` enum('free','pro','enterprise') NULL DEFAULT "free", `quota_max_active_keys` int NULL, `usage_active_keys` int NULL, `quota_max_verifications` int NULL, `usage_verifications` int NULL, `last_usage_update` datetime(3) NULL, `billing_period_start` datetime(3) NULL, `billing_period_end` datetime(3) NULL, `trial_ends` datetime(3) NULL, `features` json NULL, `beta_features` json NULL, PRIMARY KEY (`id`), UNIQUE INDEX `slug_idx` (`slug`), UNIQUE INDEX `tenant_id_idx` (`tenant_id`)) CHARSET utf8mb4 COLLATE utf8mb4_0900_ai_ci; +CREATE TABLE `workspaces` (`id` varchar(256) NOT NULL, `name` varchar(256) NOT NULL, `slug` varchar(256) NULL, `tenant_id` varchar(256) NOT NULL, `stripe_customer_id` varchar(256) NULL, `stripe_subscription_id` varchar(256) NULL, `plan` enum('free','pro','enterprise') NULL DEFAULT "free", `quota_max_active_keys` int NULL, `usage_active_keys` int NULL, `quota_max_verifications` int NULL, `usage_verifications` int NULL, `last_usage_update` datetime(3) NULL, `billing_period_start` datetime(3) NULL, `billing_period_end` datetime(3) NULL, `trial_ends` datetime(3) NULL, `features` json NOT NULL, `beta_features` json NOT NULL, PRIMARY KEY (`id`), UNIQUE INDEX `slug_idx` (`slug`), UNIQUE INDEX `tenant_id_idx` (`tenant_id`)) CHARSET utf8mb4 COLLATE utf8mb4_0900_ai_ci; diff --git a/internal/db/src/schema/workspaces.ts b/internal/db/src/schema/workspaces.ts index 1e2ee66f24..3c7e77d57a 100644 --- a/internal/db/src/schema/workspaces.ts +++ b/internal/db/src/schema/workspaces.ts @@ -49,12 +49,16 @@ export const workspaces = mysqlTable( * * betaFeatures may be toggled by the user for early access */ - betaFeatures: json("beta_features").$type<{ - auditLog?: boolean; - }>(), - features: json("features").$type<{ - auditLog?: boolean; - }>(), + betaFeatures: json("beta_features") + .$type<{ + auditLog?: boolean; + }>() + .notNull(), + features: json("features") + .$type<{ + auditLog?: boolean; + }>() + .notNull(), }, (table) => ({ tenantIdIdx: uniqueIndex("tenant_id_idx").on(table.tenantId),