diff --git a/src/main/resources/db/migration/V7_0__NewDatabaseStructure.sql b/src/main/resources/db/migration/V7_0__NewDatabaseStructure.sql index 6f0380aee596bad76cb9a4ce6cf1f35eefcaf9bf..6a3beee937f221082909af5ee3778e40575240a9 100644 --- a/src/main/resources/db/migration/V7_0__NewDatabaseStructure.sql +++ b/src/main/resources/db/migration/V7_0__NewDatabaseStructure.sql @@ -1,3 +1,8 @@ +UPDATE experiment +SET algorithms = + ( + SELECT SUBSTR(algorithms, 2, LENGTH(algorithms) - 2) + ); UPDATE experiment SET workflowstatus = 'error' @@ -21,12 +26,10 @@ DROP COLUMN hasservererror, DROP COLUMN validations, DROP COLUMN model_slug; -ALTER TABLE experiment RENAME algorithms TO algorithm; -UPDATE experiment SET algorithm = (algorithm::json ->> 0); -UPDATE experiment SET algorithmId = (algorithm::json ->> 'name'); -ALTER TABLE experiment ADD COLUMN algorithmId text; -UPDATE experiment SET result = result::json #>>'{0,result}' WHERE (algorithm::json->>'type') <> 'workflow'; - +ALTER TABLE experiment +RENAME algorithms TO algorithm; +ALTER TABLE experiment +ALTER COLUMN algorithm TYPE json USING algorithm::json; ALTER TABLE experiment RENAME createdby_username TO created_by_username; ALTER TABLE experiment @@ -36,6 +39,14 @@ RENAME resultsviewed TO viewed; ALTER TABLE experiment RENAME workflowstatus TO status; +ALTER TABLE experiment +ADD COLUMN algorithmId text; + +UPDATE experiment +SET algorithmId = (algorithm ->> 'name'); + +ALTER TABLE experiment +ALTER COLUMN algorithm TYPE text; ALTER TABLE experiment ADD COLUMN updated timestamp without time zone; @@ -70,4 +81,4 @@ DROP TABLE "query"; DROP TABLE "dataset"; DROP TABLE "config"; DROP TABLE "vote", "app"; -DROP TABLE "user_roles", "user_languages"; +DROP TABLE "user_roles", "user_languages"; \ No newline at end of file diff --git a/src/main/resources/db/migration/V7_1__NewExperimentResultFormat.sql b/src/main/resources/db/migration/V7_1__NewExperimentResultFormat.sql new file mode 100644 index 0000000000000000000000000000000000000000..d124f94583046e2ddbab071fb38ca48e1c71f03e --- /dev/null +++ b/src/main/resources/db/migration/V7_1__NewExperimentResultFormat.sql @@ -0,0 +1 @@ +UPDATE experiment SET result = result::json #>>'{0,result}' WHERE (algorithm::json->>'type') <> 'workflow'; \ No newline at end of file