Skip to content

Commit 041630c

Browse files
committed
chore: update delete org trigger name
1 parent ae2bf08 commit 041630c

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

coderd/database/migrations/000296_organization_soft_delete.up.sql

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ CREATE UNIQUE INDEX IF NOT EXISTS idx_organization_name_lower ON organizations U
99
ALTER TABLE ONLY organizations
1010
DROP CONSTRAINT IF EXISTS organizations_name;
1111

12-
CREATE FUNCTION protect_provisioned_organizations()
12+
CREATE FUNCTION protect_deleted_organizations()
1313
RETURNS TRIGGER AS
1414
$$
1515
DECLARE
@@ -56,6 +56,7 @@ BEGIN
5656
-- * the organization has 1 or more templates
5757
-- * the organization has 1 or more groups other than "Everyone" group
5858
-- * the organization has 1 or more members other than the organization owner
59+
-- * the organization has 1 or more provisioner keys
5960

6061
IF (workspace_count + template_count + provisioner_keys_count) > 0 THEN
6162
RAISE EXCEPTION 'cannot delete organization: organization has % workspaces, % templates, and % provisioner keys that must be deleted first', workspace_count, template_count, provisioner_keys_count;
@@ -77,7 +78,7 @@ END;
7778
$$ LANGUAGE plpgsql;
7879

7980
-- Trigger to protect organizations from being soft deleted with existing resources
80-
CREATE TRIGGER protect_provisioned_organizations
81+
CREATE TRIGGER protect_deleted_organizations
8182
BEFORE UPDATE ON organizations
8283
FOR EACH ROW
8384
WHEN (NEW.deleted = true AND OLD.deleted = false)

0 commit comments

Comments
 (0)