Skip to content

Commit

Permalink
Upgrade database model
Browse files Browse the repository at this point in the history
  • Loading branch information
Clara Wiatrowski committed Jun 30, 2022
1 parent b228e20 commit 909341d
Show file tree
Hide file tree
Showing 7 changed files with 94 additions and 6 deletions.
6 changes: 4 additions & 2 deletions deploy/deploy-core/scripts/derby/createfullhddb.sql
Expand Up @@ -90,9 +90,9 @@ insert into schemaversions (tablename, version )
insert into schemaversions (tablename, version )
values ( 'global_crawler_trap_expressions', 1);
insert into schemaversions ( tablename, version )
values ( 'runningjobshistory', 2);
values ( 'runningjobshistory', 3);
insert into schemaversions ( tablename, version )
values ( 'runningjobsmonitor', 2);
values ( 'runningjobsmonitor', 3);
insert into schemaversions ( tablename, version )
values ( 'frontierreportmonitor', 1);

Expand Down Expand Up @@ -540,6 +540,7 @@ CREATE TABLE runningJobsHistory (
activeToeCount integer NOT NULL,
status int NOT NULL,
tstamp timestamp NOT NULL,
totalbyteswritten bigint NOT NULL DEFAULT 0,
PRIMARY KEY (jobId, harvestName, elapsedSeconds, tstamp)
);

Expand Down Expand Up @@ -569,6 +570,7 @@ CREATE TABLE runningJobsMonitor (
activeToeCount integer NOT NULL,
status integer NOT NULL,
tstamp timestamp NOT NULL,
totalbyteswritten bigint NOT NULL DEFAULT 0,
PRIMARY KEY (jobId, harvestName)
);

Expand Down
6 changes: 4 additions & 2 deletions deploy/deploy-core/scripts/mysql/createfullhddb.mysql
Expand Up @@ -76,9 +76,9 @@ insert into schemaversions (tablename, version )
insert into schemaversions (tablename, version )
values ( 'global_crawler_trap_expressions', 1);
INSERT INTO schemaversions ( tablename, version )
VALUES ( 'runningjobshistory', 2);
VALUES ( 'runningjobshistory', 3);
INSERT INTO schemaversions ( tablename, version )
VALUES ( 'runningjobsmonitor', 2);
VALUES ( 'runningjobsmonitor', 3);
INSERT INTO schemaversions ( tablename, version )
VALUES ( 'frontierreportmonitor', 1);

Expand Down Expand Up @@ -358,6 +358,7 @@ CREATE TABLE runningJobsHistory (
activeToeCount integer NOT NULL,
status integer NOT NULL,
tstamp timestamp NOT NULL,
totalbyteswritten bigint NOT NULL DEFAULT 0,
PRIMARY KEY (jobId, harvestName, elapsedSeconds, tstamp)
);

Expand Down Expand Up @@ -389,6 +390,7 @@ CREATE TABLE runningJobsMonitor (
activeToeCount integer NOT NULL,
status integer NOT NULL,
tstamp timestamp NOT NULL,
totalbyteswritten bigint NOT NULL DEFAULT 0,
PRIMARY KEY (jobId, harvestName)
);

Expand Down
Expand Up @@ -88,9 +88,9 @@ INSERT INTO schemaversions (tablename, version )
INSERT INTO schemaversions (tablename, version )
VALUES ( 'global_crawler_trap_expressions', 1);
INSERT INTO schemaversions ( tablename, version )
VALUES ( 'runningjobshistory', 2);
VALUES ( 'runningjobshistory', 3);
INSERT INTO schemaversions ( tablename, version )
VALUES ( 'runningjobsmonitor', 2);
VALUES ( 'runningjobsmonitor', 3);
INSERT INTO schemaversions ( tablename, version )
VALUES ( 'frontierreportmonitor', 1);
INSERT INTO schemaversions ( tablename, version )
Expand Down Expand Up @@ -472,6 +472,7 @@ CREATE TABLE runningJobsHistory (
processedDocsPerSec numeric NOT NULL,
activeToeCount integer NOT NULL,
status integer NOT NULL,
totalbyteswritten bigint NOT NULL DEFAULT 0,
tstamp timestamp NOT NULL,
CONSTRAINT pkRunningJobsHistory PRIMARY KEY (jobId, harvestName, elapsedSeconds, tstamp)
);
Expand Down Expand Up @@ -503,6 +504,7 @@ CREATE TABLE runningJobsMonitor (
processedDocsPerSec numeric NOT NULL,
activeToeCount integer NOT NULL,
status integer NOT NULL,
totalbyteswritten bigint NOT NULL DEFAULT 0,
tstamp timestamp NOT NULL,
CONSTRAINT pkRunningJobsMonitor PRIMARY KEY (jobId, harvestName)
);
Expand Down
Expand Up @@ -282,6 +282,10 @@ private void upgradeRunningjobsmonitor(int currentVersion, int toVersion) {
migrateRunningJobsMonitorTableV1ToV2();
currentVersion = 2;
}
if (currentVersion == 2 && toVersion >= 3) {
migrateRunningJobsMonitorTableV2ToV3();
currentVersion = 3;
}
if (currentVersion > HarvesterDatabaseTables.RUNNINGJOBSMONITOR.getRequiredVersion()) {
throw new NotImplementedException("No method exists for migrating table '"
+ HarvesterDatabaseTables.RUNNINGJOBSMONITOR.getTablename() + "' from version " + currentVersion
Expand All @@ -304,6 +308,11 @@ private void upgradeRunningjobshistoryTable(int currentVersion, int toVersion) {
migrateRunningJobsHistoryTableV1ToV2();
currentVersion = 2;
}
if (currentVersion == 2 && toVersion >= 3) {
migrateRunningJobsHistoryTableV2ToV3();
currentVersion = 3;
}

// insert new migrations here
if (currentVersion > HarvesterDatabaseTables.RUNNINGJOBSHISTORY.getRequiredVersion()) {
throw new NotImplementedException("No method exists for migrating table '"
Expand Down Expand Up @@ -507,6 +516,18 @@ private void upgradeHarvestchannelTable(int currentVersion, int toVersion) {

protected abstract void createHarvestChannelTable();

/**
* Migrates the 'runningjobshistory' table from version 2 to version 3. This consists of adding the new column
* 'totalbyteswritten'.
*/
protected abstract void migrateRunningJobsHistoryTableV2ToV3();

/**
* Migrates the 'runningjobsmonitor' table from version 2 to version 3. This consists of adding the new column
* 'totalbyteswritten'.
*/
protected abstract void migrateRunningJobsMonitorTableV2ToV3();

/**
* Migrates the 'jobs' table from version 3 to version 4 consisting of a change of the field forcemaxbytes from int
* to bigint and setting its default to -1. Furthermore the default value for field num_configs is set to 0.
Expand Down
Expand Up @@ -219,6 +219,27 @@ public void createRunningJobsMonitorTable() {
}
}

/**
* Migrates the 'runningjobshistory' table from version 2 to version 3. This consists of adding the new column
* 'totalbyteswritten'.
*/
@Override
protected void migrateRunningJobsHistoryTableV2ToV3() {
String[] sqlStatements = {"ALTER TABLE runningjobshistory ADD COLUMN totalbyteswritten BIGINT NOT NULL DEFAULT 0"};
HarvestDBConnection.updateTable("runningjobshistory", 3, sqlStatements);
}

/**
* Migrates the 'runningjobsmonitor' table from version 2 to version 3. This consists of adding the new column
* 'totalbyteswritten'.
*/
@Override
protected void migrateRunningJobsMonitorTableV2ToV3() {
String[] sqlStatements = {"ALTER TABLE runningjobsmonitor ADD COLUMN totalbyteswritten BIGINT NOT NULL DEFAULT 0"};
HarvestDBConnection.updateTable("runningjobsmonitor", 3, sqlStatements);
}


// Below DB changes introduced with development release 3.15
// with changes to tables 'runningjobshistory', 'runningjobsmonitor',
// 'configurations', 'fullharvests', and 'jobs'.
Expand Down
Expand Up @@ -235,6 +235,26 @@ public void createRunningJobsMonitorTable() {
}
}

/**
* Migrates the 'runningjobshistory' table from version 2 to version 3. This consists of adding the new column
* 'totalbyteswritten'.
*/
@Override
protected void migrateRunningJobsHistoryTableV2ToV3() {
String[] sqlStatements = {"ALTER TABLE runningjobshistory ADD COLUMN totalbyteswritten BIGINT NOT NULL DEFAULT 0"};
HarvestDBConnection.updateTable("runningjobshistory", 3, sqlStatements);
}

/**
* Migrates the 'runningjobsmonitor' table from version 2 to version 3. This consists of adding the new column
* 'totalbyteswritten'.
*/
@Override
protected void migrateRunningJobsMonitorTableV2ToV3() {
String[] sqlStatements = {"ALTER TABLE runningjobsmonitor ADD COLUMN totalbyteswritten BIGINT NOT NULL DEFAULT 0"};
HarvestDBConnection.updateTable("runningjobsmonitor", 3, sqlStatements);
}

// Below DB changes introduced with development release 3.15
// with changes to tables 'runningjobshistory', 'runningjobsmonitor',
// 'configurations', 'fullharvests', and 'jobs'.
Expand Down
Expand Up @@ -176,6 +176,26 @@ public void createRunningJobsMonitorTable() {
HarvestDBConnection.updateTable("runningjobsmonitor", 1);
}

/**
* Migrates the 'runningjobshistory' table from version 2 to version 3. This consists of adding the new column
* 'totalbyteswritten'.
*/
@Override
protected void migrateRunningJobsHistoryTableV2ToV3() {
String[] sqlStatements = {"ALTER TABLE runningjobshistory ADD COLUMN totalbyteswritten BIGINT NOT NULL DEFAULT 0"};
HarvestDBConnection.updateTable("runningjobshistory", 3, sqlStatements);
}

/**
* Migrates the 'runningjobsmonitor' table from version 2 to version 3. This consists of adding the new column
* 'totalbyteswritten'.
*/
@Override
protected void migrateRunningJobsMonitorTableV2ToV3() {
String[] sqlStatements = {"ALTER TABLE runningjobsmonitor ADD COLUMN totalbyteswritten BIGINT NOT NULL DEFAULT 0"};
HarvestDBConnection.updateTable("runningjobsmonitor", 3, sqlStatements);
}

// Below DB changes introduced with development release 3.15
// with changes to tables 'runningjobshistory', 'runningjobsmonitor',
// 'configurations', 'fullharvests', and 'jobs'.
Expand Down

0 comments on commit 909341d

Please sign in to comment.