Skip to content

Commit 87af79e

Browse files
committed
fix: update indexes and unique constraint
1 parent 46ad566 commit 87af79e

File tree

6 files changed

+26
-10
lines changed

6 files changed

+26
-10
lines changed

coderd/database/dump.sql

Lines changed: 2 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,10 @@
11
ALTER TABLE organizations DROP COLUMN deleted;
2+
3+
DROP INDEX IF EXISTS idx_organization_name;
4+
DROP INDEX IF EXISTS idx_organization_name_lower;
5+
6+
CREATE UNIQUE INDEX IF NOT EXISTS idx_organization_name ON organizations USING btree (name);
7+
CREATE UNIQUE INDEX IF NOT EXISTS idx_organization_name_lower ON organizations USING btree (lower(name));
8+
9+
ALTER TABLE ONLY organizations
10+
ADD CONSTRAINT organizations_name UNIQUE (name);
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,12 @@
11
ALTER TABLE organizations ADD COLUMN deleted boolean DEFAULT FALSE NOT NULL;
2+
3+
DROP INDEX IF EXISTS idx_organization_name;
4+
DROP INDEX IF EXISTS idx_organization_name_lower;
5+
6+
CREATE UNIQUE INDEX IF NOT EXISTS idx_organization_name ON organizations USING btree (name)
7+
where deleted = false;
8+
CREATE UNIQUE INDEX IF NOT EXISTS idx_organization_name_lower ON organizations USING btree (lower(name))
9+
where deleted = false;
10+
11+
ALTER TABLE ONLY organizations
12+
DROP CONSTRAINT IF EXISTS organizations_name;

coderd/database/queries.sql.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

coderd/database/queries/organizations.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ INSERT INTO
7171
organizations (id, "name", display_name, description, icon, created_at, updated_at, is_default)
7272
VALUES
7373
-- If no organizations exist, and this is the first, make it the default.
74-
(@id, @name, @display_name, @description, @icon, @created_at, @updated_at, (SELECT TRUE FROM organizations WHERE deleted = false LIMIT 1) IS NULL) RETURNING *;
74+
(@id, @name, @display_name, @description, @icon, @created_at, @updated_at, (SELECT TRUE FROM organizations LIMIT 1) IS NULL) RETURNING *;
7575

7676
-- name: UpdateOrganization :one
7777
UPDATE

coderd/database/unique_constraint.go

Lines changed: 2 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy