Skip to content

Commit

Permalink
Fixed #1085
Browse files Browse the repository at this point in the history
  • Loading branch information
Axel Fontaine committed Oct 27, 2015
1 parent 9d73922 commit f96a36b
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 0 deletions.
Expand Up @@ -63,6 +63,11 @@ protected void doDrop() throws SQLException {

@Override
protected void doClean() throws SQLException {
List<String> triggerNames = listObjectNames("TRIGGER", "");
for (String statement : generateDropStatements("TRIGGER", triggerNames, "")) {
jdbcTemplate.execute(statement);
}

for (String statement : generateDropStatementsForConstraints()) {
jdbcTemplate.execute(statement);
}
Expand Down
Expand Up @@ -64,4 +64,13 @@ public void bitdata() throws Exception {

assertEquals("1", flyway.info().current().getVersion().toString());
}

@Test
public void trigger() throws Exception {
flyway.setLocations("migration/dbsupport/derby/sql/trigger");
flyway.migrate();

// Fails if triggers aren't cleaned properly
flyway.clean();
}
}
@@ -0,0 +1,38 @@
--
-- Copyright 2010-2015 Axel Fontaine
--
-- 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
--
-- http://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.
--

CREATE TABLE TEST (
ID INTEGER NOT NULL,
NAME VARCHAR(128) NOT NULL,
PRIMARY KEY (ID)
);

CREATE TABLE TEST_REFERENCE (
REF_ID INTEGER NOT NULL,
TEST_ID INTEGER NOT NULL,
PRIMARY KEY (REF_ID),
CONSTRAINT FK_TEST_ID FOREIGN KEY (TEST_ID) REFERENCES TEST (ID)
);

CREATE TRIGGER TRG_Del_Test AFTER DELETE ON TEST_REFERENCE
REFERENCING OLD AS EXISTING
FOR EACH ROW MODE DB2SQL
DELETE FROM TEST
WHERE ID = EXISTING.TEST_ID
;

INSERT INTO TEST VALUES (1, 'Test trigger');
INSERT INTO TEST_REFERENCE VALUES (1, 1);

0 comments on commit f96a36b

Please sign in to comment.