-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #53 from tchapgouv/add-crisp-conversation-segments
add database for crisp conversation segments
- Loading branch information
Showing
2 changed files
with
36 additions
and
0 deletions.
There are no files selected for viewing
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,31 @@ | ||
|
||
|
||
/* Crisp conversation segments | ||
*/ | ||
CREATE TABLE IF NOT EXISTS crisp_conversation_segments ( | ||
session_id VARCHAR NOT NULL, | ||
state VARCHAR NOT NULL, | ||
segment VARCHAR, | ||
created_at timestamp NOT NULL, | ||
updated_at timestamp NOT NULL | ||
); | ||
|
||
CREATE INDEX IF NOT EXISTS crisp_conversation_segments_idx ON crisp_conversation_segments (session_id); | ||
CREATE INDEX IF NOT EXISTS crisp_conversation_segment_idx ON crisp_conversation_segments (segment); | ||
CREATE INDEX IF NOT EXISTS crisp_conversation_state_idx ON crisp_conversation_segments (state); | ||
CREATE INDEX IF NOT EXISTS crisp_created_at_idx ON crisp_conversation_segments (created_at); | ||
|
||
/* Insert data from the csv file into the DB. */ | ||
/* If data is already present, update the content field */ | ||
|
||
CREATE TEMPORARY TABLE crisp_conversation_segments_temp (session_id VARCHAR, state VARCHAR, segment VARCHAR, created_at timestamp, updated_at timestamp); | ||
|
||
-- CSV file has fields in this order : | ||
-- If it changes, change this line or it will break. | ||
\copy crisp_conversation_segments_temp(session_id, state, segment, created_at, updated_at) FROM '/app/crisp_conversation_segments.csv' DELIMITER ',' CSV HEADER; | ||
|
||
|
||
INSERT INTO crisp_conversation_segments (session_id, state, segment, created_at, updated_at) | ||
SELECT * | ||
FROM crisp_conversation_segments_temp | ||
ON CONFLICT DO NOTHING |
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