Skip to content

Commit

Permalink
#374 - Extend API to save and load cohort and dataselection
Browse files Browse the repository at this point in the history
- convert saved queries and templates to dataqueries in db migration
  • Loading branch information
michael-82 committed Feb 27, 2025
1 parent 77d40ab commit 4d8cc94
Showing 1 changed file with 26 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
-- Not sure if we can just drop the old tables for templates and saved queries or if we have to migrate them first
-- drop table query_template;
-- drop table saved_query;

CREATE TABLE dataquery
(
id SERIAL PRIMARY KEY,
Expand All @@ -11,4 +7,29 @@ CREATE TABLE dataquery
crtdl TEXT,
last_modified TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
result_size INTEGER
);
);

insert into dataquery (created_by, label, comment, crtdl, last_modified, result_size)
select q.created_by,
sq.label,
sq.comment,
CONCAT('{"version":null,"display":"","cohortDefinition":', qc.query_content, ',"dataExtraction":null}'),
q.created_at,
sq.result_size
from saved_query sq
left join query q on sq.query_id = q.id
left join query_content qc on q.query_content_id = qc.id ;

insert into dataquery (created_by, label, comment, crtdl, last_modified)
select q.created_by,
qt.label,
qt.comment,
CONCAT('{"version":null,"display":"","cohortDefinition":', qc.query_content, ',"dataExtraction":null}'),
q.created_at
from query_template qt
left join query q on qt.query_id = q.id
left join query_content qc on q.query_content_id = qc.id ;

-- Not sure if we should already delete those tables or wait for the next release to check if everything was converted as expected
-- drop table query_template;
-- drop table saved_query;

0 comments on commit 4d8cc94

Please sign in to comment.