Skip to content

Commit

Permalink
flyway#1649 flyway:clean fails on db2 when trying to drop versioning …
Browse files Browse the repository at this point in the history
…on tables which is accessed by a MQT

Make an explicit drop of all MQTs if there are tables with versioning
  • Loading branch information
msallstr committed May 27, 2017
1 parent d6e0cf9 commit 6c739a3
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,15 @@ protected void doClean() throws SQLException {

if (dbSupport.getDb2MajorVersion() >= 10) {
// drop versioned table link -> not supported for DB2 9.x
for (String dropVersioningStatement : generateDropVersioningStatement()) {
List<String> dropVersioningStatements = generateDropVersioningStatement();
if (!dropVersioningStatements.isEmpty()) {
// Do a explicit drop of MQTs in order to be able to drop the Versioning
for (String dropTableStatement : generateDropStatements("S", "TABLE")) {
jdbcTemplate.execute(dropTableStatement);
}
}

for (String dropVersioningStatement : dropVersioningStatements) {
jdbcTemplate.execute(dropVersioningStatement);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,16 @@
create table EMPLOYEE ( "ID" integer not null, "NAME" varchar(100) );
alter table EMPLOYEE add primary KEY ("ID");

-- Issue #
ALTER TABLE EMPLOYEE ADD COLUMN SYS_START TIMESTAMP(12) NOT NULL GENERATED AS ROW BEGIN IMPLICITLY HIDDEN;
ALTER TABLE EMPLOYEE ADD COLUMN SYS_END TIMESTAMP(12) NOT NULL GENERATED AS ROW END IMPLICITLY HIDDEN;
ALTER TABLE EMPLOYEE ADD COLUMN TRANS_ID TIMESTAMP(12) GENERATED AS TRANSACTION START ID IMPLICITLY HIDDEN;
ALTER TABLE EMPLOYEE ADD PERIOD SYSTEM_TIME (sys_start, sys_end);

CREATE TABLE EMPLOYEE_HIST LIKE EMPLOYEE;

ALTER TABLE EMPLOYEE ADD VERSIONING USE HISTORY TABLE EMPLOYEE_HIST;

create table ADDRESS ( "ID" integer not null, "EMPL_ID" integer not null, "STREET" VARCHAR(250) );
alter TABLE ADDRESS add PRIMARY KEY ("ID");
alter table ADDRESS add CONSTRAINT "EMPL" FOREIGN KEY("ID") REFERENCES "EMPLOYEE" ("ID");
Expand Down

0 comments on commit 6c739a3

Please sign in to comment.