From d44876382dd10e8265ab1d2e7c7b8baf45f2b93b Mon Sep 17 00:00:00 2001 From: Kyle Carberry Date: Sun, 24 Apr 2022 22:24:02 -0500 Subject: [PATCH] fix: Remove unique index on auth tokens (#1120) If a workspace is started multiple times, resources may not be invalidated. This means an auth token can be reused for a workspace. coderd closes old agent connections, so this is expected behavior, and the agent will reconnect properly. --- coderd/database/dump.sql | 3 --- coderd/database/migrations/000004_jobs.up.sql | 2 +- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/coderd/database/dump.sql b/coderd/database/dump.sql index fa89fa876b..fbc137f122 100644 --- a/coderd/database/dump.sql +++ b/coderd/database/dump.sql @@ -338,9 +338,6 @@ ALTER TABLE ONLY templates ALTER TABLE ONLY users ADD CONSTRAINT users_pkey PRIMARY KEY (id); -ALTER TABLE ONLY workspace_agents - ADD CONSTRAINT workspace_agents_auth_token_key UNIQUE (auth_token); - ALTER TABLE ONLY workspace_agents ADD CONSTRAINT workspace_agents_pkey PRIMARY KEY (id); diff --git a/coderd/database/migrations/000004_jobs.up.sql b/coderd/database/migrations/000004_jobs.up.sql index bc1679ea4b..d1c6633f09 100644 --- a/coderd/database/migrations/000004_jobs.up.sql +++ b/coderd/database/migrations/000004_jobs.up.sql @@ -80,7 +80,7 @@ CREATE TABLE workspace_agents ( last_connected_at timestamptz, disconnected_at timestamptz, resource_id uuid NOT NULL REFERENCES workspace_resources (id) ON DELETE CASCADE, - auth_token uuid NOT NULL UNIQUE, + auth_token uuid NOT NULL, auth_instance_id varchar(64), architecture varchar(64) NOT NULL, environment_variables jsonb,