From 9fe46d40bca30fd750e37806ccca5858fdf5e94c Mon Sep 17 00:00:00 2001 From: jdfox Date: Wed, 9 Dec 2020 15:19:58 +0000 Subject: [PATCH] Event status update existing (#223) * update existing events with correct status * changelog master * r14 * simplify query * rm from changelog master * [ci skip] auto patch increment skip-checks: true Co-authored-by: ras-rm-bot <65395820+ras-rm-bot@users.noreply.github.com> --- src/main/resources/database/changelog-master.yml | 2 +- .../database/changes/release-14/changelog.yml | 11 +++++++++++ .../release-14/update_existing_events_status.sql | 11 +++++++++++ 3 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 src/main/resources/database/changes/release-14/changelog.yml create mode 100644 src/main/resources/database/changes/release-14/update_existing_events_status.sql diff --git a/src/main/resources/database/changelog-master.yml b/src/main/resources/database/changelog-master.yml index 54259a2fc..7f17c066d 100644 --- a/src/main/resources/database/changelog-master.yml +++ b/src/main/resources/database/changelog-master.yml @@ -45,7 +45,7 @@ databaseChangeLog: - include: file: database/changes/release-13/changelog.yml - + # When adding new groups of migrations to this file the numbers are arbitrary, please follow the following format for # all migrations after this point, using the the format "release-$NEXT_NUMBER". Incrementing $NEXT_NUMBER each # time. diff --git a/src/main/resources/database/changes/release-14/changelog.yml b/src/main/resources/database/changes/release-14/changelog.yml new file mode 100644 index 000000000..c934f7eec --- /dev/null +++ b/src/main/resources/database/changes/release-14/changelog.yml @@ -0,0 +1,11 @@ +databaseChangeLog: + + - changeSet: + id: 14.1 + author: Jon Fox + changes: + - sqlFile: + comment: update existing events with correct status + path: update_existing_events_status.sql + relativeToChangelogFile: true + splitStatements: false diff --git a/src/main/resources/database/changes/release-14/update_existing_events_status.sql b/src/main/resources/database/changes/release-14/update_existing_events_status.sql new file mode 100644 index 000000000..410f1d639 --- /dev/null +++ b/src/main/resources/database/changes/release-14/update_existing_events_status.sql @@ -0,0 +1,11 @@ +UPDATE collectionexercise.event AS e +SET status = 'SCHEDULED' +WHERE e.status = 'NOT_SET' + AND e.timestamp >= now() + AND e.timestamp IS NOT NULL; + +UPDATE collectionexercise.event AS e +SET status = 'PROCESSED' +WHERE e.status = 'NOT_SET' + AND e.timestamp < now() + AND e.timestamp IS NOT NULL;