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

Commit28942f0

Browse files
committed
send events on ownership transfer
1 parent823e87a commit28942f0

File tree

3 files changed

+15
-10
lines changed

3 files changed

+15
-10
lines changed

‎coderd/database/dump.sql

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

‎coderd/database/migrations/000260_workspace_updates.down.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ DROP TRIGGER IF EXISTS new_workspace_notify ON workspaces;
44
DROPFUNCTION IF EXISTS new_workspace_notify;
55

66
DROPTRIGGER IF EXISTS new_agent_notifyON workspace_agents;
7-
DROPFUNCTION new_agent_notify;
7+
DROPFUNCTIONIF EXISTSnew_agent_notify;

‎coderd/database/migrations/000260_workspace_updates.up.sql

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,18 @@ CREATE FUNCTION new_workspace_notify() RETURNS trigger
88
AS $$
99
DECLARE
1010
BEGIN
11-
-- Write to the notification channel `new_workspace:owner_id`
12-
-- with the workspace id as the payload.
13-
PERFORM pg_notify('new_workspace:'||NEW.owner_id,NEW.id::text);
11+
-- Notify for new workspaces & ownership transfers
12+
IF TG_OP='INSERT'OR (TG_OP='UPDATE'ANDNEW.owner_id<>OLD.owner_id) THEN
13+
-- Write to the notification channel `new_workspace:owner_id`
14+
-- with the workspace id as the payload.
15+
PERFORM pg_notify('new_workspace:'||NEW.owner_id,NEW.id::text);
16+
END IF;
1417
RETURN NEW;
1518
END;
1619
$$;
1720

1821
CREATETRIGGERnew_workspace_notify
19-
AFTER INSERTON workspaces
22+
AFTER INSERTORUPDATEON workspaces
2023
FOR EACH ROW
2124
EXECUTE FUNCTION new_workspace_notify();
2225

@@ -68,4 +71,3 @@ CREATE TRIGGER new_agent_notify
6871
AFTER INSERTON workspace_agents
6972
FOR EACH ROW
7073
EXECUTE FUNCTION new_agent_notify();
71-

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp