Skip to content

Commit

Permalink
migrations: add a UNIQUE constraint on address for instance_ip_addresses
Browse files Browse the repository at this point in the history
This will prevent duplicate IPs from being added to
instance_ip_addresses, which has been happening due to race conditions
during upserts.
  • Loading branch information
ScottGarman committed Aug 31, 2023
1 parent 150dc90 commit 625cfe5
Showing 1 changed file with 13 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
-- +goose Up
-- +goose StatementBegin

ALTER TABLE instance_ip_addresses ADD CONSTRAINT unique_address UNIQUE (address);

-- +goose StatementEnd

-- +goose Down
-- +goose StatementBegin

DROP CONSTRAINT unique_address ON instance_ip_addresses;

-- +goose StatementEnd

0 comments on commit 625cfe5

Please sign in to comment.