Skip to content

Commit

Permalink
fixing flyway (#152)
Browse files Browse the repository at this point in the history
  • Loading branch information
ndc-dxc authored Nov 29, 2024
1 parent 278652c commit 5349855
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 15 deletions.
17 changes: 2 additions & 15 deletions src/main/resources/db/migration/V9__semantic_content_stats.sql
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,9 @@ create table SEMANTIC_CONTENT_STATS
RESOURCE_URI VARCHAR(255) NOT NULL,
RESOURCE_TYPE VARCHAR(64) NOT NULL,
RIGHT_HOLDER VARCHAR(64) NOT NULL,
ISSUED_ON TIMESTAMP,
MODIFIED_ON TIMESTAMP,
ISSUED_ON TIMESTAMP NOT NULL,
MODIFIED_ON TIMESTAMP NOT NULL,
HAS_ERRORS BOOLEAN NOT NULL,
HAS_WARNINGS BOOLEAN NOT NULL,
STATUS TEXT NOT NULL
) ENGINE = InnoDB;

CREATE VIEW LATEST_HARVESTER_RUN_BY_YEAR AS
WITH LATEST_RUN_BY_YEAR AS (SELECT REPOSITORY_ID,
YEAR(STARTED) AS YEAR,
MAX(STARTED) AS LATEST_STARTED
FROM HARVESTER_RUN
GROUP BY REPOSITORY_ID, YEAR(STARTED))
SELECT HR.*
FROM HARVESTER_RUN HR
JOIN LATEST_RUN_BY_YEAR LRBY
ON HR.REPOSITORY_ID = LRBY.REPOSITORY_ID
AND YEAR(HR.STARTED) = LRBY.YEAR
AND HR.STARTED = LRBY.LATEST_STARTED;
18 changes: 18 additions & 0 deletions src/main/resources/db/migration/v10_latest_harvester_run_view.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
alter table SEMANTIC_CONTENT_STATS
modify ISSUED_ON timestamp null;

alter table SEMANTIC_CONTENT_STATS
modify MODIFIED_ON timestamp null;

CREATE VIEW LATEST_HARVESTER_RUN_BY_YEAR AS
WITH LATEST_RUN_BY_YEAR AS (SELECT REPOSITORY_ID,
YEAR(STARTED) AS YEAR,
MAX(STARTED) AS LATEST_STARTED
FROM HARVESTER_RUN
GROUP BY REPOSITORY_ID, YEAR(STARTED))
SELECT HR.*
FROM HARVESTER_RUN HR
JOIN LATEST_RUN_BY_YEAR LRBY
ON HR.REPOSITORY_ID = LRBY.REPOSITORY_ID
AND YEAR(HR.STARTED) = LRBY.YEAR
AND HR.STARTED = LRBY.LATEST_STARTED;

0 comments on commit 5349855

Please sign in to comment.