INT-4262-4.3: Fix SQL scripts for IF EXISTS

JIRA: https://jira.spring.io/browse/INT-4262

Since `IF EXISTS` doesn't exist for `DROP INDEX` command and even more
this command isn't necessary when we fully drop the table, we don't need it
as a separate command.
`DROP TABLE IF EXISTS` is fully sufficient for schema recreation requirements

* Add `NODROPINDEX` variable for VPP engine to let it do not add `DROP INDEX` command
* Fix `channel/schema-mysql.sql` for proper INDEX names
This commit is contained in:
Artem Bilan
2017-04-24 11:36:22 -04:00
committed by Gary Russell
parent b5c6158117
commit ecc6824a8c
15 changed files with 29 additions and 25 deletions

View File

@@ -1,5 +1,5 @@
-- Autogenerated: do not edit this file
-- Autogenerated: do not edit this file
DROP TABLE INT_MESSAGE ;
DROP TABLE INT_MESSAGE_GROUP ;
DROP TABLE INT_GROUP_TO_MESSAGE ;

View File

@@ -1,5 +1,5 @@
-- Autogenerated: do not edit this file
-- Autogenerated: do not edit this file
DROP TABLE INT_MESSAGE ;
DROP TABLE INT_MESSAGE_GROUP ;
DROP TABLE INT_GROUP_TO_MESSAGE ;

View File

@@ -1,5 +1,5 @@
-- Autogenerated: do not edit this file
-- Autogenerated: do not edit this file
DROP TABLE INT_MESSAGE IF EXISTS;
DROP TABLE INT_MESSAGE_GROUP IF EXISTS;
DROP TABLE INT_GROUP_TO_MESSAGE IF EXISTS;

View File

@@ -1,5 +1,5 @@
-- Autogenerated: do not edit this file
-- Autogenerated: do not edit this file
DROP TABLE INT_MESSAGE IF EXISTS;
DROP TABLE INT_MESSAGE_GROUP IF EXISTS;
DROP TABLE INT_GROUP_TO_MESSAGE IF EXISTS;

View File

@@ -1,7 +1,7 @@
-- Autogenerated: do not edit this file
-- Autogenerated: do not edit this file
DROP TABLE IF EXISTS INT_MESSAGE ;
DROP TABLE IF EXISTS INT_MESSAGE_GROUP ;
DROP TABLE IF EXISTS INT_GROUP_TO_MESSAGE ;
DROP TABLE IF EXISTS INT_LOCK ;
DROP INDEX IF EXISTS INT_MESSAGE_IX1 ;

View File

@@ -1,7 +1,7 @@
-- Autogenerated: do not edit this file
-- Autogenerated: do not edit this file
DROP TABLE IF EXISTS INT_MESSAGE ;
DROP TABLE IF EXISTS INT_MESSAGE_GROUP ;
DROP TABLE IF EXISTS INT_GROUP_TO_MESSAGE ;
DROP TABLE IF EXISTS INT_LOCK ;
DROP INDEX IF EXISTS INT_MESSAGE_IX1 ;

View File

@@ -1,5 +1,5 @@
-- Autogenerated: do not edit this file
-- Autogenerated: do not edit this file
DROP TABLE INT_MESSAGE ;
DROP TABLE INT_MESSAGE_GROUP ;
DROP TABLE INT_GROUP_TO_MESSAGE ;

View File

@@ -1,5 +1,5 @@
-- Autogenerated: do not edit this file
-- Autogenerated: do not edit this file
DROP TABLE INT_MESSAGE ;
DROP TABLE INT_MESSAGE_GROUP ;
DROP TABLE INT_GROUP_TO_MESSAGE ;

View File

@@ -1,5 +1,5 @@
-- Autogenerated: do not edit this file
-- Autogenerated: do not edit this file
DROP TABLE INT_MESSAGE ;
DROP TABLE INT_MESSAGE_GROUP ;
DROP TABLE INT_GROUP_TO_MESSAGE ;

View File

@@ -1,5 +1,5 @@
-- Autogenerated: do not edit this file
-- Autogenerated: do not edit this file
DROP TABLE INT_MESSAGE ;
DROP TABLE INT_MESSAGE_GROUP ;
DROP TABLE INT_GROUP_TO_MESSAGE ;

View File

@@ -10,7 +10,7 @@ CREATE TABLE INT_CHANNEL_MESSAGE (
) ENGINE=InnoDB;
ALTER TABLE INT_CHANNEL_MESSAGE
ADD INDEX MSG_INDEX_DATE_IDX USING BTREE (CREATED_DATE, MESSAGE_SEQUENCE);
ADD INDEX INT_CHANNEL_MSG_DATE_IDX USING BTREE (CREATED_DATE, MESSAGE_SEQUENCE);
ALTER TABLE INT_CHANNEL_MESSAGE
ADD INDEX MSG_INDEX_PRIORITY_IDX USING BTREE (MESSAGE_PRIORITY DESC, CREATED_DATE, MESSAGE_SEQUENCE);
ADD INDEX INT_CHANNEL_MSG_PRIORITY_IDX USING BTREE (MESSAGE_PRIORITY DESC, CREATED_DATE, MESSAGE_SEQUENCE);

View File

@@ -2,4 +2,5 @@ DROP TABLE $!{IFEXISTSBEFORE} INT_MESSAGE $!{IFEXISTS};
DROP TABLE $!{IFEXISTSBEFORE} INT_MESSAGE_GROUP $!{IFEXISTS};
DROP TABLE $!{IFEXISTSBEFORE} INT_GROUP_TO_MESSAGE $!{IFEXISTS};
DROP TABLE $!{IFEXISTSBEFORE} INT_LOCK $!{IFEXISTS};
DROP INDEX $!{IFEXISTSBEFORE} INT_MESSAGE_IX1 $!{IFEXISTS};
#if(!${NODROPINDEX})DROP INDEX $!{IFEXISTSBEFORE} INT_MESSAGE_IX1 $!{IFEXISTS};#end

View File

@@ -12,3 +12,4 @@ TIMESTAMP = DATETIME(6)
VARCHAR = VARCHAR
# for generating drop statements...
SEQUENCE = TABLE
NODROPINDEX = true

View File

@@ -12,3 +12,4 @@ TIMESTAMP = DATETIME
VARCHAR = VARCHAR
# for generating drop statements...
SEQUENCE = TABLE
NODROPINDEX = true

View File

@@ -72,6 +72,7 @@ public class DelayerHandlerRescheduleIntegrationTests {
public static void init() {
dataSource = new EmbeddedDatabaseBuilder()
.setType(EmbeddedDatabaseType.H2)
.addScript("classpath:/org/springframework/integration/jdbc/schema-drop-h2.sql")
.addScript("classpath:/org/springframework/integration/jdbc/schema-h2.sql")
.build();
}