This repository has been archived by the owner on Aug 16, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Replace connected agent status w/ agent connection (#212)
- Loading branch information
1 parent
477d78d
commit c1a7058
Showing
16 changed files
with
346 additions
and
259 deletions.
There are no files selected for viewing
21 changes: 21 additions & 0 deletions
21
migrations/2020-12-29-232109_create_agent_connection/down.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
-- Put back `agent_stream` table. | ||
CREATE TABLE agent_stream ( | ||
id UUID DEFAULT gen_random_uuid(), | ||
sent_by UUID NOT NULL, | ||
label TEXT NOT NULL, | ||
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(), | ||
|
||
FOREIGN KEY (sent_by) REFERENCES agent (id) ON DELETE CASCADE, | ||
PRIMARY KEY (id) | ||
); | ||
|
||
-- Put back `connected` status. | ||
ALTER TYPE agent_status RENAME TO agent_status_old; | ||
CREATE TYPE agent_status AS ENUM ('in_progress', 'ready', 'connected'); | ||
ALTER TABLE agent ALTER COLUMN status DROP DEFAULT; | ||
ALTER TABLE agent ALTER COLUMN status TYPE agent_status USING status::text::agent_status; | ||
ALTER TABLE agent ALTER COLUMN status SET DEFAULT 'in_progress'; | ||
DROP TYPE agent_status_old; | ||
|
||
-- Drop new `agent_connection table`. | ||
DROP TABLE agent_connection; |
21 changes: 21 additions & 0 deletions
21
migrations/2020-12-29-232109_create_agent_connection/up.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
-- Create `agent_connection`. | ||
CREATE TABLE agent_connection ( | ||
agent_id UUID NOT NULL, | ||
handle_id BIGINT NOT NULL, | ||
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(), | ||
|
||
FOREIGN KEY (agent_id) REFERENCES agent (id) ON DELETE CASCADE, | ||
PRIMARY KEY (agent_id) | ||
); | ||
|
||
-- Remove `connected` status since it's now indicated by `agent_connection` row presence. | ||
UPDATE agent SET status = 'ready' WHERE status = 'connected'; | ||
ALTER TYPE agent_status RENAME TO agent_status_old; | ||
CREATE TYPE agent_status AS ENUM ('in_progress', 'ready'); | ||
ALTER TABLE agent ALTER COLUMN status DROP DEFAULT; | ||
ALTER TABLE agent ALTER COLUMN status TYPE agent_status USING status::text::agent_status; | ||
ALTER TABLE agent ALTER COLUMN status SET DEFAULT 'in_progress'; | ||
DROP TYPE agent_status_old; | ||
|
||
-- Unused table. | ||
DROP TABLE agent_stream; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.