-
Notifications
You must be signed in to change notification settings - Fork 899
feat: add single tailnet support to pgcoord #9351
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
a20d318
efa2071
2976c00
a7b39df
618b0e0
f50f929
3a5bb76
3ddc783
c84626a
a0cb904
dcb007d
bdd7ef1
751b22f
3af1af1
7762a73
08501e6
eb681ff
390e837
a1c3acf
8256670
a75f6f1
d143d2d
036094f
e8a2b01
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
BEGIN; | ||
|
||
-- ALTER TABLE | ||
-- tailnet_clients | ||
-- ADD COLUMN | ||
-- agent_id uuid; | ||
|
||
UPDATE | ||
tailnet_clients | ||
SET | ||
-- grab just the first agent_id, or default to an empty UUID. | ||
agent_id = COALESCE(agent_ids[0], '00000000-0000-0000-0000-000000000000'::uuid); | ||
|
||
ALTER TABLE | ||
tailnet_clients | ||
DROP COLUMN | ||
agent_ids; | ||
|
||
COMMIT; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
BEGIN; | ||
|
||
ALTER TABLE | ||
tailnet_clients | ||
ADD COLUMN | ||
agent_ids uuid[]; | ||
|
||
UPDATE | ||
tailnet_clients | ||
SET | ||
agent_ids = ARRAY[agent_id]::uuid[]; | ||
|
||
ALTER TABLE | ||
tailnet_clients | ||
ALTER COLUMN | ||
agent_ids SET NOT NULL; | ||
|
||
|
||
CREATE INDEX idx_tailnet_clients_agent_ids ON tailnet_clients USING GIN (agent_ids); | ||
|
||
CREATE OR REPLACE FUNCTION tailnet_notify_client_change() RETURNS trigger | ||
LANGUAGE plpgsql | ||
AS $$ | ||
BEGIN | ||
-- check new first to get the updated agent ids. | ||
IF (NEW IS NOT NULL) THEN | ||
PERFORM pg_notify('tailnet_client_update', NEW.id || ',' || array_to_string(NEW.agent_ids, ',')); | ||
RETURN NULL; | ||
END IF; | ||
IF (OLD IS NOT NULL) THEN | ||
PERFORM pg_notify('tailnet_client_update', OLD.id || ',' || array_to_string(OLD.agent_ids, ',')); | ||
RETURN NULL; | ||
END IF; | ||
END; | ||
$$; | ||
|
||
ALTER TABLE | ||
tailnet_clients | ||
DROP COLUMN | ||
agent_id; | ||
|
||
COMMIT; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if this is required, how were our tests working before?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is only if you specify a database URL to run tests against. I needed to run a standalone postgres to see the logs and previously it wouldn't run the migrations. I can prob remove this, I'm not sure if it has any greater effects.