Skip to content

Commit

Permalink
Update Schema to retrieve EXECUTION_CONTEXT.
Browse files Browse the repository at this point in the history
  • Loading branch information
Corneil du Plessis committed Dec 13, 2023
1 parent 9f9fdc2 commit ae76c43
Show file tree
Hide file tree
Showing 19 changed files with 154 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*
* Copyright 2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.cloud.dataflow.server.db.migration;

import org.springframework.cloud.dataflow.common.flyway.AbstractMigration;
import org.springframework.cloud.dataflow.common.flyway.SqlCommand;

import java.util.Arrays;
import java.util.List;

public abstract class AbstractAggregateContextViewMigration extends AbstractMigration {
public AbstractAggregateContextViewMigration() {
super(null);
}

public final static String CREATE_AGGREGATE_JOB_EXECUTION_CONTEXT_VIEW = "CREATE VIEW AGGREGATE_JOB_EXECUTION_CONTEXT AS\n" +
" SELECT JOB_EXECUTION_ID, SHORT_CONTEXT, SERIALIZED_CONTEXT, 'boot2' AS SCHEMA_TARGET FROM BATCH_JOB_EXECUTION_CONTEXT\n" +
"UNION ALL\n" +
" SELECT JOB_EXECUTION_ID, SHORT_CONTEXT, SERIALIZED_CONTEXT, 'boot3' AS SCHEMA_TARGET FROM BOOT3_BATCH_JOB_EXECUTION_CONTEXT";

public final static String CREATE_AGGREGATE_STEP_EXECUTION_CONTEXT_VIEW = "CREATE VIEW AGGREGATE_STEP_EXECUTION_CONTEXT AS\n" +
" SELECT STEP_EXECUTION_ID, SHORT_CONTEXT, SERIALIZED_CONTEXT, 'boot2' AS SCHEMA_TARGET FROM BATCH_STEP_EXECUTION_CONTEXT\n" +
"UNION ALL\n" +
" SELECT STEP_EXECUTION_ID, SHORT_CONTEXT, SERIALIZED_CONTEXT, 'boot3' AS SCHEMA_TARGET FROM BOOT3_BATCH_STEP_EXECUTION_CONTEXT";

@Override
public List<SqlCommand> getCommands() {
return Arrays.asList(
SqlCommand.from(CREATE_AGGREGATE_JOB_EXECUTION_CONTEXT_VIEW),
SqlCommand.from(CREATE_AGGREGATE_STEP_EXECUTION_CONTEXT_VIEW)
);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package org.springframework.cloud.dataflow.server.db.migration.db2;

import org.springframework.cloud.dataflow.server.db.migration.AbstractAggregateContextViewMigration;

public class V10__AggregateContextView extends AbstractAggregateContextViewMigration {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package org.springframework.cloud.dataflow.server.db.migration.mariadb;

import org.springframework.cloud.dataflow.server.db.migration.AbstractAggregateContextViewMigration;

public class V11__AggregateContextView extends AbstractAggregateContextViewMigration {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package org.springframework.cloud.dataflow.server.db.migration.mysql;

import org.springframework.cloud.dataflow.server.db.migration.AbstractAggregateContextViewMigration;

public class V11__AggregateContextView extends AbstractAggregateContextViewMigration {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package org.springframework.cloud.dataflow.server.db.migration.oracle;

import org.springframework.cloud.dataflow.server.db.migration.AbstractAggregateContextViewMigration;

public class V11__AggregateContextView extends AbstractAggregateContextViewMigration {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package org.springframework.cloud.dataflow.server.db.migration.postgresql;

import org.springframework.cloud.dataflow.server.db.migration.AbstractAggregateContextViewMigration;

public class V12__AggregateContextView extends AbstractAggregateContextViewMigration {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package org.springframework.cloud.dataflow.server.db.migration.sqlserver;

import org.springframework.cloud.dataflow.server.db.migration.AbstractAggregateContextViewMigration;

public class V10__AggregateContextView extends AbstractAggregateContextViewMigration {
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@ spring:
- classpath*:/schemas/db2/V6-dataflow.sql
- classpath*:/schemas/db2/V7-dataflow.sql
- classpath*:/schemas/db2/V8-dataflow.sql
- classpath*:/schemas/db2/V9-dataflow.sql
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,7 @@ spring:
- classpath*:/schemas/mariadb/V5-dataflow.sql
- classpath*:/schemas/mariadb/V6-dataflow.sql
- classpath*:/schemas/mariadb/V7-dataflow.sql
- classpath*:/schemas/mariadb/V8-dataflow.sql
- classpath*:/schemas/mariadb/V9-dataflow.sql
- classpath*:/schemas/mariadb/V8-dataflow.sql
- classpath*:/schemas/mariadb/V10-dataflow.sql
- classpath*:/schemas/mariadb/V11-dataflow.sql
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@ spring:
- classpath*:/schemas/oracle/V6-dataflow.sql
- classpath*:/schemas/oracle/V7-dataflow.sql
- classpath*:/schemas/oracle/V8-dataflow.sql
- classpath*:/schemas/oracle/V9-dataflow.sql
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,5 @@ spring:
- classpath*:/schemas/postgresql/V6-dataflow.sql
- classpath*:/schemas/postgresql/V7-dataflow.sql
- classpath*:/schemas/postgresql/V8-dataflow.sql
- classpath*:/schemas/postgresql/V9-dataflow.sql
- classpath*:/schemas/postgresql/V9-dataflow.sql
- classpath*:/schemas/postgresql/V10-dataflow.sql
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ spring:
- classpath*:/schemas/sqlserver/V6-dataflow.sql
- classpath*:/schemas/sqlserver/V7-dataflow.sql
- classpath*:/schemas/sqlserver/V8-dataflow.sql
- classpath*:/schemas/sqlserver/V9-dataflow.sql
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,16 @@ CREATE VIEW AGGREGATE_STEP_EXECUTION AS
UNION ALL
SELECT STEP_EXECUTION_ID, VERSION, STEP_NAME, JOB_EXECUTION_ID, START_TIME, END_TIME, STATUS, COMMIT_COUNT, READ_COUNT, FILTER_COUNT, WRITE_COUNT, READ_SKIP_COUNT, WRITE_SKIP_COUNT, PROCESS_SKIP_COUNT, ROLLBACK_COUNT, EXIT_CODE, EXIT_MESSAGE, LAST_UPDATED, 'boot3' AS SCHEMA_TARGET FROM BOOT3_BATCH_STEP_EXECUTION;

CREATE VIEW AGGREGATE_JOB_EXECUTION_CONTEXT AS
SELECT JOB_EXECUTION_ID, SHORT_CONTEXT, SERIALIZED_CONTEXT, 'boot2' AS SCHEMA_TARGET FROM BATCH_JOB_EXECUTION_CONTEXT
UNION ALL
SELECT JOB_EXECUTION_ID, SHORT_CONTEXT, SERIALIZED_CONTEXT, 'boot3' AS SCHEMA_TARGET FROM BOOT3_BATCH_JOB_EXECUTION_CONTEXT;

CREATE VIEW AGGREGATE_STEP_EXECUTION_CONTEXT AS
SELECT STEP_EXECUTION_ID, SHORT_CONTEXT, SERIALIZED_CONTEXT, 'boot2' AS SCHEMA_TARGET FROM BATCH_STEP_EXECUTION_CONTEXT
UNION ALL
SELECT STEP_EXECUTION_ID, SHORT_CONTEXT, SERIALIZED_CONTEXT, 'boot3' AS SCHEMA_TARGET FROM BOOT3_BATCH_STEP_EXECUTION_CONTEXT;

ALTER TABLE task_execution_metadata RENAME TO task_execution_metadata_lc;
ALTER TABLE task_execution_metadata_lc RENAME TO TASK_EXECUTION_METADATA;
CREATE SEQUENCE task_execution_metadata_seq_lc;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
CREATE VIEW AGGREGATE_JOB_EXECUTION_CONTEXT AS
SELECT JOB_EXECUTION_ID, SHORT_CONTEXT, SERIALIZED_CONTEXT, 'boot2' AS SCHEMA_TARGET FROM BATCH_JOB_EXECUTION_CONTEXT
UNION ALL
SELECT JOB_EXECUTION_ID, SHORT_CONTEXT, SERIALIZED_CONTEXT, 'boot3' AS SCHEMA_TARGET FROM BOOT3_BATCH_JOB_EXECUTION_CONTEXT;

CREATE VIEW AGGREGATE_STEP_EXECUTION_CONTEXT AS
SELECT STEP_EXECUTION_ID, SHORT_CONTEXT, SERIALIZED_CONTEXT, 'boot2' AS SCHEMA_TARGET FROM BATCH_STEP_EXECUTION_CONTEXT
UNION ALL
SELECT STEP_EXECUTION_ID, SHORT_CONTEXT, SERIALIZED_CONTEXT, 'boot3' AS SCHEMA_TARGET FROM BOOT3_BATCH_STEP_EXECUTION_CONTEXT;
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
CREATE VIEW AGGREGATE_JOB_EXECUTION_CONTEXT AS
SELECT JOB_EXECUTION_ID, SHORT_CONTEXT, SERIALIZED_CONTEXT, 'boot2' AS SCHEMA_TARGET FROM BATCH_JOB_EXECUTION_CONTEXT
UNION ALL
SELECT JOB_EXECUTION_ID, SHORT_CONTEXT, SERIALIZED_CONTEXT, 'boot3' AS SCHEMA_TARGET FROM BOOT3_BATCH_JOB_EXECUTION_CONTEXT;

CREATE VIEW AGGREGATE_STEP_EXECUTION_CONTEXT AS
SELECT STEP_EXECUTION_ID, SHORT_CONTEXT, SERIALIZED_CONTEXT, 'boot2' AS SCHEMA_TARGET FROM BATCH_STEP_EXECUTION_CONTEXT
UNION ALL
SELECT STEP_EXECUTION_ID, SHORT_CONTEXT, SERIALIZED_CONTEXT, 'boot3' AS SCHEMA_TARGET FROM BOOT3_BATCH_STEP_EXECUTION_CONTEXT;
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
CREATE VIEW AGGREGATE_JOB_EXECUTION_CONTEXT AS
SELECT JOB_EXECUTION_ID, SHORT_CONTEXT, SERIALIZED_CONTEXT, 'boot2' AS SCHEMA_TARGET FROM BATCH_JOB_EXECUTION_CONTEXT
UNION ALL
SELECT JOB_EXECUTION_ID, SHORT_CONTEXT, SERIALIZED_CONTEXT, 'boot3' AS SCHEMA_TARGET FROM BOOT3_BATCH_JOB_EXECUTION_CONTEXT;

CREATE VIEW AGGREGATE_STEP_EXECUTION_CONTEXT AS
SELECT STEP_EXECUTION_ID, SHORT_CONTEXT, SERIALIZED_CONTEXT, 'boot2' AS SCHEMA_TARGET FROM BATCH_STEP_EXECUTION_CONTEXT
UNION ALL
SELECT STEP_EXECUTION_ID, SHORT_CONTEXT, SERIALIZED_CONTEXT, 'boot3' AS SCHEMA_TARGET FROM BOOT3_BATCH_STEP_EXECUTION_CONTEXT;
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
CREATE VIEW AGGREGATE_JOB_EXECUTION_CONTEXT AS
SELECT JOB_EXECUTION_ID, SHORT_CONTEXT, SERIALIZED_CONTEXT, 'boot2' AS SCHEMA_TARGET FROM BATCH_JOB_EXECUTION_CONTEXT
UNION ALL
SELECT JOB_EXECUTION_ID, SHORT_CONTEXT, SERIALIZED_CONTEXT, 'boot3' AS SCHEMA_TARGET FROM BOOT3_BATCH_JOB_EXECUTION_CONTEXT;

CREATE VIEW AGGREGATE_STEP_EXECUTION_CONTEXT AS
SELECT STEP_EXECUTION_ID, SHORT_CONTEXT, SERIALIZED_CONTEXT, 'boot2' AS SCHEMA_TARGET FROM BATCH_STEP_EXECUTION_CONTEXT
UNION ALL
SELECT STEP_EXECUTION_ID, SHORT_CONTEXT, SERIALIZED_CONTEXT, 'boot3' AS SCHEMA_TARGET FROM BOOT3_BATCH_STEP_EXECUTION_CONTEXT;
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
CREATE VIEW AGGREGATE_JOB_EXECUTION_CONTEXT AS
SELECT JOB_EXECUTION_ID, SHORT_CONTEXT, SERIALIZED_CONTEXT, 'boot2' AS SCHEMA_TARGET FROM BATCH_JOB_EXECUTION_CONTEXT
UNION ALL
SELECT JOB_EXECUTION_ID, SHORT_CONTEXT, SERIALIZED_CONTEXT, 'boot3' AS SCHEMA_TARGET FROM BOOT3_BATCH_JOB_EXECUTION_CONTEXT;

CREATE VIEW AGGREGATE_STEP_EXECUTION_CONTEXT AS
SELECT STEP_EXECUTION_ID, SHORT_CONTEXT, SERIALIZED_CONTEXT, 'boot2' AS SCHEMA_TARGET FROM BATCH_STEP_EXECUTION_CONTEXT
UNION ALL
SELECT STEP_EXECUTION_ID, SHORT_CONTEXT, SERIALIZED_CONTEXT, 'boot3' AS SCHEMA_TARGET FROM BOOT3_BATCH_STEP_EXECUTION_CONTEXT;
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
CREATE VIEW AGGREGATE_JOB_EXECUTION_CONTEXT AS
SELECT JOB_EXECUTION_ID, SHORT_CONTEXT, SERIALIZED_CONTEXT, 'boot2' AS SCHEMA_TARGET FROM BATCH_JOB_EXECUTION_CONTEXT
UNION ALL
SELECT JOB_EXECUTION_ID, SHORT_CONTEXT, SERIALIZED_CONTEXT, 'boot3' AS SCHEMA_TARGET FROM BOOT3_BATCH_JOB_EXECUTION_CONTEXT;

CREATE VIEW AGGREGATE_STEP_EXECUTION_CONTEXT AS
SELECT STEP_EXECUTION_ID, SHORT_CONTEXT, SERIALIZED_CONTEXT, 'boot2' AS SCHEMA_TARGET FROM BATCH_STEP_EXECUTION_CONTEXT
UNION ALL
SELECT STEP_EXECUTION_ID, SHORT_CONTEXT, SERIALIZED_CONTEXT, 'boot3' AS SCHEMA_TARGET FROM BOOT3_BATCH_STEP_EXECUTION_CONTEXT;

0 comments on commit ae76c43

Please sign in to comment.