-
Notifications
You must be signed in to change notification settings - Fork 607
feat: db change and new workspace slug #3849
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
c07bc33
0560ccc
b255d98
f4eb278
506e25a
c676bce
bb7900d
f6b2383
1b4f0c5
2984797
60dc06e
c87e538
f1191b8
b87eba9
64122d8
2170a12
14a6e61
6cf2e6d
af74624
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -179,6 +179,7 @@ CREATE TABLE `workspaces` ( | |
| `id` varchar(256) NOT NULL, | ||
| `org_id` varchar(256) NOT NULL, | ||
| `name` varchar(256) NOT NULL, | ||
| `slug` varchar(64), | ||
| `partition_id` varchar(256), | ||
|
Comment on lines
+182
to
183
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧹 Nitpick (assertive) Plan a follow-up to make slug required and canonicalized. Slug is nullable; if every workspace should have a URL slug, backfill existing rows, then add NOT NULL and enforce lowercase at the API boundary. I can draft the migration plan if helpful. 🤖 Prompt for AI Agents |
||
| `plan` enum('free','pro','enterprise') DEFAULT 'free', | ||
| `tier` varchar(256) DEFAULT 'Free', | ||
|
|
@@ -193,7 +194,8 @@ CREATE TABLE `workspaces` ( | |
| `updated_at_m` bigint, | ||
| `deleted_at_m` bigint, | ||
| CONSTRAINT `workspaces_id` PRIMARY KEY(`id`), | ||
| CONSTRAINT `workspaces_org_id_unique` UNIQUE(`org_id`) | ||
| CONSTRAINT `workspaces_org_id_unique` UNIQUE(`org_id`), | ||
| CONSTRAINT `workspaces_slug_unique` UNIQUE(`slug`) | ||
| ); | ||
|
|
||
| CREATE TABLE `key_migration_errors` ( | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -179,6 +179,7 @@ CREATE TABLE `workspaces` ( | |
| `id` varchar(256) NOT NULL, | ||
| `org_id` varchar(256) NOT NULL, | ||
| `name` varchar(256) NOT NULL, | ||
| `slug` varchar(64), | ||
| `partition_id` varchar(256), | ||
|
Comment on lines
+182
to
183
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧹 Nitpick (assertive) Case handling and URL safety. If slugs appear in URLs, enforce lowercase and character set in the API layer; DB collation might already be case-insensitive, but explicit normalization avoids surprises. |
||
| `plan` enum('free','pro','enterprise') DEFAULT 'free', | ||
| `tier` varchar(256) DEFAULT 'Free', | ||
|
|
@@ -193,7 +194,8 @@ CREATE TABLE `workspaces` ( | |
| `updated_at_m` bigint, | ||
| `deleted_at_m` bigint, | ||
| CONSTRAINT `workspaces_id` PRIMARY KEY(`id`), | ||
| CONSTRAINT `workspaces_org_id_unique` UNIQUE(`org_id`) | ||
| CONSTRAINT `workspaces_org_id_unique` UNIQUE(`org_id`), | ||
| CONSTRAINT `workspaces_slug_unique` UNIQUE(`slug`) | ||
| ); | ||
| --> statement-breakpoint | ||
| CREATE TABLE `key_migration_errors` ( | ||
|
|
@@ -408,4 +410,4 @@ CREATE INDEX `status_idx` ON `deployments` (`status`);--> statement-breakpoint | |
| CREATE INDEX `domain_idx` ON `acme_users` (`workspace_id`);--> statement-breakpoint | ||
| CREATE INDEX `workspace_idx` ON `domains` (`workspace_id`);--> statement-breakpoint | ||
| CREATE INDEX `project_idx` ON `domains` (`project_id`);--> statement-breakpoint | ||
| CREATE INDEX `workspace_idx` ON `acme_challenges` (`workspace_id`); | ||
| CREATE INDEX `workspace_idx` ON `acme_challenges` (`workspace_id`); | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,7 @@ | ||
| { | ||
| "version": "5", | ||
| "dialect": "mysql", | ||
| "id": "1c1b2291-b582-4d8f-9bd7-a76d34a8af62", | ||
| "id": "feb5640a-c169-40c0-a711-90db24af469e", | ||
| "prevId": "00000000-0000-0000-0000-000000000000", | ||
| "tables": { | ||
| "apis": { | ||
|
|
@@ -1127,6 +1127,13 @@ | |
| "notNull": true, | ||
| "autoincrement": false | ||
| }, | ||
| "slug": { | ||
| "name": "slug", | ||
| "type": "varchar(64)", | ||
| "primaryKey": false, | ||
| "notNull": false, | ||
| "autoincrement": false | ||
| }, | ||
| "partition_id": { | ||
| "name": "partition_id", | ||
| "type": "varchar(256)", | ||
|
|
@@ -1236,6 +1243,10 @@ | |
| "workspaces_org_id_unique": { | ||
| "name": "workspaces_org_id_unique", | ||
| "columns": ["org_id"] | ||
| }, | ||
| "workspaces_slug_unique": { | ||
| "name": "workspaces_slug_unique", | ||
| "columns": ["slug"] | ||
| } | ||
|
Comment on lines
1243
to
1250
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧹 Nitpick (assertive) Unique constraint captured; consider eventual NOT NULL. Keep as-is now; after backfill, flip slug to notNull in schema + follow-up migration. 🤖 Prompt for AI Agents |
||
| } | ||
| }, | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,8 +5,8 @@ | |
| { | ||
| "idx": 0, | ||
| "version": "5", | ||
| "when": 1756627798938, | ||
| "tag": "0000_useful_nextwave", | ||
| "when": 1756630515466, | ||
| "tag": "0000_dazzling_colonel_america", | ||
| "breakpoints": true | ||
|
Comment on lines
+8
to
10
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧹 Nitpick (assertive) Journal tag updated—ensure migration is wired into deploy process. Confirm a PlanetScale preview branch is created and the migration is applied before deploying code that writes/reads slug. 🤖 Prompt for AI Agents |
||
| } | ||
| ] | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -19,6 +19,9 @@ export const workspaces = mysqlTable("workspaces", { | |
| orgId: varchar("org_id", { length: 256 }).notNull().unique(), | ||
| name: varchar("name", { length: 256 }).notNull(), | ||
|
|
||
| // slug is used for the workspace URL | ||
| slug: varchar("slug", { length: 64 }).unique(), | ||
|
|
||
|
Comment on lines
+22
to
+24
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💡 Verification agent 🧩 Analysis chainVerify runtime validation at the API boundary. Ensure createWorkspace Zod schema enforces: lowercase, [a-z0-9-], no leading/trailing hyphen, max 64. Run to confirm: 🏁 Script executed: #!/bin/bash
rg -nP -C2 --type tsx --type ts '\bslug\b' apps/dashboard/lib/trpc/routers/workspace/create.ts apps/dashboard/app/new/hooks/use-workspace-step.tsx
rg -nP -C2 --type ts 'z\.object\([^)]*slug[^)]*\)' apps/dashboard/lib/trpc/routers/workspace/create.ts
rg -nP -C2 --type ts '(toLowerCase|slugify)' apps/dashboard/lib/trpc/routers/workspace/create.ts apps/dashboard/app/new/hooks/use-workspace-step.tsxLength of output: 2026 Add slug validation in createWorkspace schema slug: z
.string()
.regex(/^[a-z0-9]+(?:-[a-z0-9]+)*$/, "invalid slug")
.max(64),🤖 Prompt for AI Agents |
||
| // Deployment platform - which partition this workspace deploys to | ||
| partitionId: varchar("partition_id", { length: 256 }), | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.