Spaces:
Sleeping
Sleeping
Commit Β·
e32f628
1
Parent(s): a8e67fc
Fix rbac_migration: upsert default team before channel FK insert
Browse files
supabase/rbac_migration.sql
CHANGED
|
@@ -51,12 +51,14 @@ alter table teams add column if not exists workspace_id uuid references workspac
|
|
| 51 |
alter table teams add column if not exists name text;
|
| 52 |
alter table teams add column if not exists slug text;
|
| 53 |
|
| 54 |
-
--
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
|
|
|
|
|
|
| 60 |
|
| 61 |
|
| 62 |
-- ββ User β Team memberships ββββββββββββββββββββββββββββββββββ
|
|
|
|
| 51 |
alter table teams add column if not exists name text;
|
| 52 |
alter table teams add column if not exists slug text;
|
| 53 |
|
| 54 |
+
-- Ensure the default team row exists, then backfill the new columns.
|
| 55 |
+
-- Insert is a no-op if team_id='default' already exists.
|
| 56 |
+
insert into teams (team_id, workspace_id, name, slug)
|
| 57 |
+
values ('default', '00000000-0000-0000-0000-000000000001', 'Engineering', 'engineering')
|
| 58 |
+
on conflict (team_id) do update
|
| 59 |
+
set workspace_id = excluded.workspace_id,
|
| 60 |
+
name = excluded.name,
|
| 61 |
+
slug = excluded.slug;
|
| 62 |
|
| 63 |
|
| 64 |
-- ββ User β Team memberships ββββββββββββββββββββββββββββββββββ
|