Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit2417efc

Browse files
fix: unique per build not workspace
1 parent97e0d44 commit2417efc

File tree

2 files changed

+16
-16
lines changed

2 files changed

+16
-16
lines changed

‎coderd/database/dump.sql

Lines changed: 8 additions & 8 deletions
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.

‎coderd/database/migrations/000330_workspace_agent_name_unique_trigger.up.sql

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,29 @@
11
CREATE OR REPLACEFUNCTIONcheck_workspace_agent_name_unique()
22
RETURNS TRIGGERAS $$
33
DECLARE
4-
workspace_id_var uuid;
4+
workspace_build_id uuid;
55
existing_countinteger;
66
BEGIN
7-
-- Get theworkspace_id for this agent by following the relationship chain:
8-
-- workspace_agents -> workspace_resources -> provisioner_jobs -> workspace_builds -> workspaces
9-
SELECTwb.workspace_id INTOworkspace_id_var
7+
-- Get theworkspace_build.id for this agent by following the relationship chain:
8+
-- workspace_agents -> workspace_resources -> provisioner_jobs -> workspace_builds
9+
SELECTwb.id INTOworkspace_build_id
1010
FROM workspace_resources wr
1111
JOIN provisioner_jobs pjONwr.job_id=pj.id
1212
JOIN workspace_builds wbONpj.id=wb.job_id
1313
WHEREwr.id=NEW.resource_id;
1414

15-
-- If we couldn't find aworkspace_id, allow the insert (might be a template import or other edge case)
16-
IFworkspace_id_var ISNULL THEN
15+
-- If we couldn't find aworkspace_build_id, allow the insert (might be a template import or other edge case)
16+
IFworkspace_build_id ISNULL THEN
1717
RETURN NEW;
1818
END IF;
1919

20-
-- Check if there's already an agent with this namein this workspace
20+
-- Check if there's already an agent with this namefor this workspace build
2121
SELECTCOUNT(*) INTO existing_count
2222
FROM workspace_agents wa
2323
JOIN workspace_resources wrONwa.resource_id=wr.id
2424
JOIN provisioner_jobs pjONwr.job_id=pj.id
2525
JOIN workspace_builds wbONpj.id=wb.job_id
26-
WHEREwb.workspace_id=workspace_id_var
26+
WHEREwb.id=workspace_build_id
2727
ANDwa.name=NEW.name
2828
ANDwa.id!=NEW.id;-- Exclude the current agent (for updates)
2929

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp