mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
chore: ensure default org always exists (#12412)
* chore: ensure default org always exists First user just joins the org created by the migration
This commit is contained in:
@@ -0,0 +1 @@
|
||||
-- There is no down. If the org is created, just let it be. Deleting an org feels dangerous in a migration.
|
||||
@@ -0,0 +1,16 @@
|
||||
-- This ensures a default organization always exists.
|
||||
INSERT INTO
|
||||
organizations(id, name, description, created_at, updated_at, is_default)
|
||||
SELECT
|
||||
-- Avoid calling it "default" as we are reserving that word as a keyword to fetch
|
||||
-- the default org regardless of the name.
|
||||
gen_random_uuid(),
|
||||
'first-organization',
|
||||
'Builtin default organization.',
|
||||
now(),
|
||||
now(),
|
||||
true
|
||||
WHERE
|
||||
-- Only insert if no organizations exist.
|
||||
NOT EXISTS (SELECT * FROM organizations);
|
||||
|
||||
Reference in New Issue
Block a user