Skip to content

armgit / kaneo

Public Imported from GitHub
0

⚡ Project management that doesn't become the project. Boards, Gantt charts, and GitHub integration. Self-host it or use Kaneo Cloud.

feat(database): update workspace slug handling

Andrej Acevski1aab22fa564d
diff --git a/apps/api/drizzle/0007_careful_moira_mactaggert.sql b/apps/api/drizzle/0007_careful_moira_mactaggert.sql
index 17c75906b..baf489ece 100644
--- a/apps/api/drizzle/0007_careful_moira_mactaggert.sql
+++ b/apps/api/drizzle/0007_careful_moira_mactaggert.sql
@@ -25,6 +25,11 @@ END $$;
ALTER TABLE "account" ALTER COLUMN "updated_at" DROP DEFAULT;--> statement-breakpoint
ALTER TABLE "session" ALTER COLUMN "updated_at" DROP DEFAULT;--> statement-breakpoint
ALTER TABLE "user" ALTER COLUMN "is_anonymous" SET DEFAULT false;--> statement-breakpoint
+-- Update NULL slug values before setting NOT NULL constraint
+UPDATE "workspace"
+SET "slug" = LOWER(REGEXP_REPLACE(name, '[^a-zA-Z0-9]+', '-', 'g')) || '-' || SUBSTRING(id FROM 1 FOR 8)
+WHERE "slug" IS NULL;
+--> statement-breakpoint
ALTER TABLE "workspace" ALTER COLUMN "slug" SET NOT NULL;--> statement-breakpoint
ALTER TABLE "workspace" ALTER COLUMN "created_at" DROP DEFAULT;--> statement-breakpoint
ALTER TABLE "workspace_member" ALTER COLUMN "workspace_id" SET NOT NULL;--> statement-breakpoint