mirror of
https://github.com/coder/coder.git
synced 2025-07-06 15:41:45 +00: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.
|
16
coderd/database/migrations/000198_ensure_default_org.up.sql
Normal file
16
coderd/database/migrations/000198_ensure_default_org.up.sql
Normal file
@ -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