Skip to content
Permalink
Browse files

0002748: the Table 'sym_trigger' can not be created on informix

  • Loading branch information...
erilong committed Sep 9, 2016
1 parent 1585fde commit 5f3ba7c40449818cfc0a793695386160ec62d8b3
@@ -450,21 +450,22 @@ public boolean createOrAlterTablesIfNecessary(String... tableNames) {
List<IDatabaseUpgradeListener> databaseUpgradeListeners = extensionService
.getExtensionPointList(IDatabaseUpgradeListener.class);

for (IDatabaseUpgradeListener listener : databaseUpgradeListeners) {
String sql = listener.beforeUpgrade(this,
this.parameterService.getTablePrefix(), modelFromDatabase,
modelFromXml);
SqlScript script = new SqlScript(sql, getPlatform().getSqlTemplate(), true,
false, false, delimiter, null);
script.setListener(resultsListener);
script.execute(platform.getDatabaseInfo().isRequiresAutoCommitForDdl());
}

String alterSql = builder.alterDatabase(modelFromDatabase, modelFromXml,
interceptors);

if (isNotBlank(alterSql)) {
log.info("There are SymmetricDS tables that needed altered");

for (IDatabaseUpgradeListener listener : databaseUpgradeListeners) {
String sql = listener.beforeUpgrade(this,
this.parameterService.getTablePrefix(), modelFromDatabase,
modelFromXml);
SqlScript script = new SqlScript(sql, getPlatform().getSqlTemplate(), true,
false, false, delimiter, null);
script.setListener(resultsListener);
script.execute(platform.getDatabaseInfo().isRequiresAutoCommitForDdl());
}

log.debug("Alter SQL generated: {}", alterSql);

SqlScript script = new SqlScript(alterSql, getPlatform().getSqlTemplate(),
@@ -21,6 +21,7 @@
package org.jumpmind.symmetric.db;

import java.io.IOException;
import java.sql.Types;

import org.jumpmind.db.model.Column;
import org.jumpmind.db.model.Database;
@@ -71,6 +72,13 @@ public String beforeUpgrade(ISymmetricDialect symmetricDialect, String tablePref
engine.getDatabasePlatform().getName().equals(DatabaseNamesConstants.FIREBIRD_DIALECT1)) {
checkForDroppedColumns(currentModel, desiredModel);
}

if (engine.getDatabasePlatform().getName().equals(DatabaseNamesConstants.INFORMIX)) {
String triggerTableName = tablePrefix + "_" + TableConstants.SYM_TRIGGER;
convertToMaxVarchar(desiredModel, triggerTableName, "custom_before_insert_text");
convertToMaxVarchar(desiredModel, triggerTableName, "custom_before_update_text");
convertToMaxVarchar(desiredModel, triggerTableName, "custom_before_delete_text");
}
return sb.toString();
}

@@ -111,6 +119,19 @@ protected void dropTriggers(Database currentModel, String tableName, String colu
}
}
}

protected void convertToMaxVarchar(Database model, String tableName, String columnName) {
Table triggerTable = model.findTable(tableName);
if (triggerTable != null) {
Column column = triggerTable.findColumn(columnName);
if (column != null) {
column.setJdbcTypeCode(Types.VARCHAR);
column.setMappedType("VARCHAR");
column.setMappedTypeCode(Types.VARCHAR);
column.setSize("255");
}
}
}

@Override
public void setSymmetricEngine(ISymmetricEngine engine) {
@@ -757,9 +757,9 @@
<column name="sync_on_insert" type="BOOLEANINT" size="1" required="true" default="1" description="Whether or not to install an insert trigger." />
<column name="sync_on_delete" type="BOOLEANINT" size="1" required="true" default="1" description="Whether or not to install an delete trigger." />
<column name="sync_on_incoming_batch" type="BOOLEANINT" size="1" required="true" default="0" description="Whether or not an incoming batch that loads data into this table should cause the triggers to capture data_events. Be careful turning this on, because an update loop is possible." />
<column name="name_for_update_trigger" type="VARCHAR" size="128" description="Override the default generated name for the update trigger." />
<column name="name_for_insert_trigger" type="VARCHAR" size="128" description="Override the default generated name for the insert trigger." />
<column name="name_for_delete_trigger" type="VARCHAR" size="128" description="Override the default generated name for the delete trigger." />
<column name="name_for_update_trigger" type="VARCHAR" size="255" description="Override the default generated name for the update trigger." />
<column name="name_for_insert_trigger" type="VARCHAR" size="255" description="Override the default generated name for the insert trigger." />
<column name="name_for_delete_trigger" type="VARCHAR" size="255" description="Override the default generated name for the delete trigger." />
<column name="sync_on_update_condition" type="LONGVARCHAR" description="Specify a condition for the update trigger firing using an expression specific to the database." />
<column name="sync_on_insert_condition" type="LONGVARCHAR" description="Specify a condition for the insert trigger firing using an expression specific to the database." />
<column name="sync_on_delete_condition" type="LONGVARCHAR" description="Specify a condition for the delete trigger firing using an expression specific to the database." />

0 comments on commit 5f3ba7c

Please sign in to comment.
You can’t perform that action at this time.