mirror of
https://github.com/coder/coder.git
synced 2026-06-05 14:08:20 +00:00
2bf2f88b09
The first organization created is now marked as "default". This is to allow "single org" behavior as we move to a multi org codebase. It is intentional that the user cannot change the default org at this stage. Only 1 default org can exist, and it is always the first org. Closes: https://github.com/coder/coder/issues/11961
46 lines
719 B
SQL
46 lines
719 B
SQL
-- name: GetOrganizations :many
|
|
SELECT
|
|
*
|
|
FROM
|
|
organizations;
|
|
|
|
-- name: GetOrganizationByID :one
|
|
SELECT
|
|
*
|
|
FROM
|
|
organizations
|
|
WHERE
|
|
id = $1;
|
|
|
|
-- name: GetOrganizationByName :one
|
|
SELECT
|
|
*
|
|
FROM
|
|
organizations
|
|
WHERE
|
|
LOWER("name") = LOWER(@name)
|
|
LIMIT
|
|
1;
|
|
|
|
-- name: GetOrganizationsByUserID :many
|
|
SELECT
|
|
*
|
|
FROM
|
|
organizations
|
|
WHERE
|
|
id = (
|
|
SELECT
|
|
organization_id
|
|
FROM
|
|
organization_members
|
|
WHERE
|
|
user_id = $1
|
|
);
|
|
|
|
-- name: InsertOrganization :one
|
|
INSERT INTO
|
|
organizations (id, "name", description, created_at, updated_at, is_default)
|
|
VALUES
|
|
-- If no organizations exist, and this is the first, make it the default.
|
|
($1, $2, $3, $4, $5, (SELECT TRUE FROM organizations LIMIT 1) IS NULL) RETURNING *;
|