Skip to content

Commit

Permalink
SYMMETRICDS-512 - fix drop/recreate problem w/ oracle 11g and ojdbc6.jar
Browse files Browse the repository at this point in the history
  • Loading branch information
chenson42 committed Sep 16, 2011
1 parent 6b6eb91 commit 376ab22
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 17 deletions.
Expand Up @@ -992,6 +992,7 @@ protected boolean createTablesIfNecessary() {
SqlBuilder builder = platform.getSqlBuilder();

if (builder.isAlterDatabase(currentModel, databaseTables, null)) {
log.info("TablesAutoUpdatingFoundTablesToAlter");
DataSource ds = jdbcTemplate.getDataSource();
String delimiter = platform.getPlatformInfo().getSqlCommandDelimiter();

Expand All @@ -1004,13 +1005,17 @@ protected boolean createTablesIfNecessary() {
builder.setWriter(writer);
builder.alterDatabase(currentModel, databaseTables, null);
String alterSql = writer.toString();
log.debug("TablesAutoUpdatingAlterSql", alterSql);
if (log.isDebugEnabled()) {
log.debug("TablesAutoUpdatingAlterSql", alterSql);
}
new SqlScript(alterSql, ds, true, delimiter, null).execute();

for (IDatabaseUpgradeListener listener : databaseUpgradeListeners) {
String sql = listener.afterUpgrade(this, tablePrefix, databaseTables);
new SqlScript(sql, ds, true, delimiter, null).execute();
}

log.info("TablesAutoUpdatingDone");
return true;
} else {
return false;
Expand Down
Expand Up @@ -273,8 +273,9 @@ TableDuplicating=Duplicating table %s into %s
TableGeneratingEventsFailure=Not generating data/data events for table %s because a trigger or trigger hist is not created yet.
TablesMissing=There are SymmetricDS tables missing. They will be auto created.
TablesAutoUpdatingStart=Starting auto update of SymmetricDS tables.
TablesAutoUpdatingFoundTablesToAlter = There are SymmetricDS tables that needed altered.
TablesAutoUpdatingAlterSql=Alter SQL Generated: %s
TablesAutoUpdatingDone=Done with auto update of SymmetricDS tables. There should now be a total of %s tables in the database.
TablesAutoUpdatingDone=Done with auto update of SymmetricDS tables.
TextMessagePublishing=Publishing text message %s
TextMessagePublished=%s published %d messages in the last %d ms.
TransactionIDSupportEnabling=Enabling transaction ID support
Expand Down
@@ -1,5 +1,7 @@
package org.jumpmind.symmetric.ddl.platform.oracle;

import java.sql.Types;

/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
Expand Down
Expand Up @@ -73,7 +73,7 @@ public Oracle8Platform()
info.addNativeTypeMapping(Types.LONGVARCHAR, "CLOB", Types.CLOB);
info.addNativeTypeMapping(Types.NULL, "BLOB", Types.BLOB);
info.addNativeTypeMapping(Types.NUMERIC, "NUMBER", Types.DECIMAL);
info.addNativeTypeMapping(Types.INTEGER, "NUMBER", Types.DECIMAL);
info.addNativeTypeMapping(Types.INTEGER, "NUMBER(22)", Types.DECIMAL);
info.addNativeTypeMapping(Types.OTHER, "BLOB", Types.BLOB);
info.addNativeTypeMapping(Types.REF, "BLOB", Types.BLOB);
info.addNativeTypeMapping(Types.SMALLINT, "NUMBER(5)");
Expand Down
Expand Up @@ -71,7 +71,7 @@ public void testColumnTypes() throws Exception
" \"COL_DISTINCT\" BLOB,\n"+
" \"COL_DOUBLE\" DOUBLE PRECISION,\n"+
" \"COL_FLOAT\" FLOAT,\n"+
" \"COL_INTEGER\" NUMBER,\n"+
" \"COL_INTEGER\" NUMBER(22),\n"+
" \"COL_JAVA_OBJECT\" BLOB,\n"+
" \"COL_LONGVARBINARY\" BLOB,\n"+
" \"COL_LONGVARCHAR\" CLOB,\n"+
Expand Down Expand Up @@ -107,7 +107,7 @@ public void testColumnConstraints() throws Exception
"CREATE TABLE \"constraints\"\n"+
"(\n"+
" \"COL_PK\" VARCHAR2(32),\n"+
" \"COL_PK_AUTO_INCR\" NUMBER,\n"+
" \"COL_PK_AUTO_INCR\" NUMBER(22),\n"+
" \"COL_NOT_NULL\" RAW(100) NOT NULL,\n"+
" \"COL_NOT_NULL_DEFAULT\" DOUBLE PRECISION DEFAULT -2.0 NOT NULL,\n"+
" \"COL_DEFAULT\" CHAR(4) DEFAULT 'test',\n"+
Expand All @@ -133,7 +133,7 @@ public void testTableConstraints() throws Exception
"CREATE TABLE \"table1\"\n"+
"(\n"+
" \"COL_PK_1\" VARCHAR2(32) NOT NULL,\n"+
" \"COL_PK_2\" NUMBER,\n"+
" \"COL_PK_2\" NUMBER(22),\n"+
" \"COL_INDEX_1\" RAW(100) NOT NULL,\n"+
" \"COL_INDEX_2\" DOUBLE PRECISION NOT NULL,\n"+
" \"COL_INDEX_3\" CHAR(4),\n"+
Expand All @@ -143,15 +143,15 @@ public void testTableConstraints() throws Exception
"CREATE UNIQUE INDEX \"testindex2\" ON \"table1\" (\"COL_INDEX_3\", \"COL_INDEX_1\");\n"+
"CREATE TABLE \"table2\"\n"+
"(\n"+
" \"COL_PK\" NUMBER,\n"+
" \"COL_FK_1\" NUMBER,\n"+
" \"COL_PK\" NUMBER(22),\n"+
" \"COL_FK_1\" NUMBER(22),\n"+
" \"COL_FK_2\" VARCHAR2(32) NOT NULL,\n"+
" PRIMARY KEY (\"COL_PK\")\n"+
");\n"+
"CREATE TABLE \"table3\"\n"+
"(\n"+
" \"COL_PK\" VARCHAR2(16),\n"+
" \"COL_FK\" NUMBER NOT NULL,\n"+
" \"COL_FK\" NUMBER(22) NOT NULL,\n"+
" PRIMARY KEY (\"COL_PK\")\n"+
");\n"+
"ALTER TABLE \"table2\" ADD CONSTRAINT \"table2_FK_COL_F_OL_FK_2_table1\" FOREIGN KEY (\"COL_FK_1\", \"COL_FK_2\") REFERENCES \"table1\" (\"COL_PK_2\", \"COL_PK_1\");\n"+
Expand All @@ -168,7 +168,7 @@ public void testCharacterEscaping() throws Exception
"DROP TABLE \"escapedcharacters\" CASCADE CONSTRAINTS;\n"+
"CREATE TABLE \"escapedcharacters\"\n"+
"(\n"+
" \"COL_PK\" NUMBER,\n"+
" \"COL_PK\" NUMBER(22),\n"+
" \"COL_TEXT\" VARCHAR2(128) DEFAULT '\'\'',\n"+
" PRIMARY KEY (\"COL_PK\")\n"+
");\n",
Expand Down
Expand Up @@ -61,7 +61,7 @@ public void testColumnTypes() throws Exception
" \"COL_DISTINCT\" BLOB,\n"+
" \"COL_DOUBLE\" DOUBLE PRECISION,\n"+
" \"COL_FLOAT\" FLOAT,\n"+
" \"COL_INTEGER\" NUMBER,\n"+
" \"COL_INTEGER\" NUMBER(22),\n"+
" \"COL_JAVA_OBJECT\" BLOB,\n"+
" \"COL_LONGVARBINARY\" BLOB,\n"+
" \"COL_LONGVARCHAR\" CLOB,\n"+
Expand Down Expand Up @@ -97,7 +97,7 @@ public void testColumnConstraints() throws Exception
"CREATE TABLE \"constraints\"\n"+
"(\n"+
" \"COL_PK\" VARCHAR2(32),\n"+
" \"COL_PK_AUTO_INCR\" NUMBER,\n"+
" \"COL_PK_AUTO_INCR\" NUMBER(22),\n"+
" \"COL_NOT_NULL\" RAW(100) NOT NULL,\n"+
" \"COL_NOT_NULL_DEFAULT\" DOUBLE PRECISION DEFAULT -2.0 NOT NULL,\n"+
" \"COL_DEFAULT\" CHAR(4) DEFAULT 'test',\n"+
Expand All @@ -123,7 +123,7 @@ public void testTableConstraints() throws Exception
"CREATE TABLE \"table1\"\n"+
"(\n"+
" \"COL_PK_1\" VARCHAR2(32) NOT NULL,\n"+
" \"COL_PK_2\" NUMBER,\n"+
" \"COL_PK_2\" NUMBER(22),\n"+
" \"COL_INDEX_1\" RAW(100) NOT NULL,\n"+
" \"COL_INDEX_2\" DOUBLE PRECISION NOT NULL,\n"+
" \"COL_INDEX_3\" CHAR(4),\n"+
Expand All @@ -133,15 +133,15 @@ public void testTableConstraints() throws Exception
"CREATE UNIQUE INDEX \"testindex2\" ON \"table1\" (\"COL_INDEX_3\", \"COL_INDEX_1\");\n"+
"CREATE TABLE \"table2\"\n"+
"(\n"+
" \"COL_PK\" NUMBER,\n"+
" \"COL_FK_1\" NUMBER,\n"+
" \"COL_PK\" NUMBER(22),\n"+
" \"COL_FK_1\" NUMBER(22),\n"+
" \"COL_FK_2\" VARCHAR2(32) NOT NULL,\n"+
" PRIMARY KEY (\"COL_PK\")\n"+
");\n"+
"CREATE TABLE \"table3\"\n"+
"(\n"+
" \"COL_PK\" VARCHAR2(16),\n"+
" \"COL_FK\" NUMBER NOT NULL,\n"+
" \"COL_FK\" NUMBER(22) NOT NULL,\n"+
" PRIMARY KEY (\"COL_PK\")\n"+
");\n"+
"ALTER TABLE \"table2\" ADD CONSTRAINT \"table2_FK_COL_F_OL_FK_2_table1\" FOREIGN KEY (\"COL_FK_1\", \"COL_FK_2\") REFERENCES \"table1\" (\"COL_PK_2\", \"COL_PK_1\");\n"+
Expand All @@ -158,7 +158,7 @@ public void testCharacterEscaping() throws Exception
"DROP TABLE \"escapedcharacters\" CASCADE CONSTRAINTS;\n"+
"CREATE TABLE \"escapedcharacters\"\n"+
"(\n"+
" \"COL_PK\" NUMBER,\n"+
" \"COL_PK\" NUMBER(22),\n"+
" \"COL_TEXT\" VARCHAR2(128) DEFAULT '\'\'',\n"+
" PRIMARY KEY (\"COL_PK\")\n"+
");\n",
Expand Down

0 comments on commit 376ab22

Please sign in to comment.