Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2013-04-06 04:41:40 -0400
committerEike Stepper2013-04-06 06:53:52 -0400
commit6e703893541443e59cab2ef3635591f78f17d7eb (patch)
treeebcdad34cc1f1c21b404ff8b7e44e45c03ab7afa
parentb0a698bc30310fd540a01a1b9d76179890de5315 (diff)
downloadcdo-6e703893541443e59cab2ef3635591f78f17d7eb.tar.gz
cdo-6e703893541443e59cab2ef3635591f78f17d7eb.tar.xz
cdo-6e703893541443e59cab2ef3635591f78f17d7eb.zip
[404047] DB-Migration from 4.1 to 4.2 failed
https://bugs.eclipse.org/bugs/show_bug.cgi?id=404047
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStore.java27
-rw-r--r--plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/IDBAdapter.java5
-rw-r--r--plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/spi/db/DBAdapter.java20
3 files changed, 50 insertions, 2 deletions
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStore.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStore.java
index 3bd14d1340..6f22ca9faa 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStore.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStore.java
@@ -77,7 +77,7 @@ public class DBStore extends Store implements IDBStore, IMappingConstants, CDOAl
{
public static final String TYPE = "db"; //$NON-NLS-1$
- public static final int SCHEMA_VERSION = 3;
+ public static final int SCHEMA_VERSION = 4;
private static final int FIRST_START = -1;
@@ -956,8 +956,31 @@ public class DBStore extends Store implements IDBStore, IMappingConstants, CDOAl
}
};
+ private static final SchemaMigrator NULLABLE_COLUMNS_MIGRATION = new SchemaMigrator()
+ {
+ @Override
+ public void migrateSchema(DBStore store, final Connection connection) throws Exception
+ {
+ IDBAdapter dbAdapter = store.getDBAdapter();
+ IDBSchema schema = DBUtil.createSchema("MIGRATION");
+ IDBField field1 = schema.addTable(null).addField(null, null);
+
+ Statement statement = null;
+
+ try
+ {
+ statement = connection.createStatement();
+ statement.execute(dbAdapter.sqlModifyField(field1));
+ }
+ finally
+ {
+ DBUtil.close(statement);
+ }
+ }
+ };
+
private static final SchemaMigrator[] SCHEMA_MIGRATORS = { NO_MIGRATION_NEEDED, NON_AUDIT_MIGRATION,
- LOB_SIZE_MIGRATION };
+ LOB_SIZE_MIGRATION, NULLABLE_COLUMNS_MIGRATION };
static
{
diff --git a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/IDBAdapter.java b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/IDBAdapter.java
index 00817f0ae1..7460eb469b 100644
--- a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/IDBAdapter.java
+++ b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/IDBAdapter.java
@@ -139,4 +139,9 @@ public interface IDBAdapter
* @since 4.2
*/
public String sqlRenameField(IDBField field, String oldName);
+
+ /**
+ * @since 4.2
+ */
+ public String sqlModifyField(IDBField field);
}
diff --git a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/spi/db/DBAdapter.java b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/spi/db/DBAdapter.java
index ca043bc934..4b7ee9e4c8 100644
--- a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/spi/db/DBAdapter.java
+++ b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/spi/db/DBAdapter.java
@@ -1010,6 +1010,26 @@ public abstract class DBAdapter implements IDBAdapter
/**
* @since 4.2
*/
+ public String sqlModifyField(IDBField field)
+ {
+ String tableName = field.getTable().getName();
+ String fieldName = field.getName();
+
+ String definition = createFieldDefinition(field);
+ return sqlModifyField(tableName, fieldName, definition);
+ }
+
+ /**
+ * @since 4.2
+ */
+ protected String sqlModifyField(String tableName, String fieldName, String definition)
+ {
+ return "ALTER TABLE " + tableName + " ALTER COLUMN " + fieldName + " " + definition;
+ }
+
+ /**
+ * @since 4.2
+ */
public String format(PreparedStatement stmt)
{
return stmt.toString();

Back to the top