-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix error message and use a more fitting error code
- Loading branch information
1 parent
52fb676
commit 24bf3ed
Showing
2 changed files
with
18 additions
and
0 deletions.
There are no files selected for viewing
13 changes: 13 additions & 0 deletions
13
internal/database/migrations/0014_raise_unique_constraint_error.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
-- +goose Up | ||
|
||
-- +goose StatementBegin | ||
CREATE OR REPLACE FUNCTION unique_team_slug() RETURNS trigger AS $unique_team_slug$ | ||
BEGIN | ||
IF (SELECT slug from team_slugs WHERE slug = NEW.slug) IS NOT NULL THEN | ||
RAISE 'Team slug is not available: %', NEW.slug | ||
USING ERRCODE = 'unique_violation'; | ||
END IF; | ||
RETURN NEW; | ||
END; | ||
$unique_team_slug$ LANGUAGE plpgsql; | ||
-- +goose StatementEnd |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters