First Time Database Migration fail
First Time Database Migration fail
- Subject: First Time Database Migration fail
- From: Yung-Luen Lan <email@hidden>
- Date: Thu, 17 Mar 2011 18:36:55 +0800
Hi,
I have a project setup with ERXMigration. The migration works except
the first time database initialization.
That is, I have a newly installed server with an empty database and I
want my project create those tables automatically.
But I get errors like this:
Mar 17 17:56:43 MyWebApp[52666] (ERXDatabaseContextDelegate.java:177)
INFO - Database Exception occured: ERROR: relation "preference" does
not exist
<<Stack Trace>>
Mar 17 17:56:43 MyWebApp[52666] (ERXApplication.java:1307) ERROR -
MyWebApp failed to start.
<<Stack Trace>>
Mar 17 17:56:43 MyWebApp[52666] (ERXNSLogLog4jBridge.java:43) WARN -
A fatal exception occurred: EvaluateExpression failed:
<com.webobjects.jdbcadaptor.PostgresqlExpression: "SELECT t0.key,
t0.pID, t0.value FROM Preference t0 ORDER BY t0.key DESC"
withBindings: >:
Next exception:SQL State:42P01 -- error code: 0 -- msg: ERROR:
relation "preference" does not exist
<<Stack Trace>>
where preference is one of my data model. Stack trace was listed as
the following. I can create those tables by running "Generate SQL" in
Eclipse, but that's not a friendly way to install a webapp. Any
insight about this is appreciated.
My Database0.java look like this:
public class Database0 extends Migration {
// downgrade omitted
public void upgrade(EOEditingContext ec, ERXMigrationDatabase
database) throws Throwable {
ERXMigrationTable bookTable = database.newTableNamed("Book");
bookTable.newStringColumn("annotation", 1024, true);
bookTable.newStringColumn("barcode", 64, false);
bookTable.newIntegerColumn("bookID", false);
bookTable.newIntBooleanColumn("duplex", false);
bookTable.create();
bookTable.setPrimaryKey("bookID");
ERXMigrationTable preferenceTable = database.newTableNamed("Preference");
preferenceTable.newStringColumn("key", 128, false);
preferenceTable.newIntegerColumn("pID", false);
preferenceTable.newStringColumn("value", 1024, false);
preferenceTable.create();
preferenceTable.setPrimaryKey("pID");
// ...
}
}
And I set the properties:
# Migrations
er.migration.migrateAtStartup=true
er.migration.createTablesIfNecessary=true
er.migration.modelNames=Database
Database.MigrationClassPrefix=com.example.migration.Database
dbConnectURLGLOBAL=jdbc:postgresql://localhost/mydb
dbConnectUserGLOBAL=postgres
#Database.InitialMigrationVersion=0
<<Stack Trace>>
Position: 38at
org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2102)
at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1835)
at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:257)
at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:500)
at org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:374)
at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:366)
at com.webobjects.jdbcadaptor.JDBCChannel._bindInputVariablesWithBindingsAndExecute(JDBCChannel.java:272)
at com.webobjects.jdbcadaptor.JDBCChannel._evaluateExpression(JDBCChannel.java:337)
at com.webobjects.jdbcadaptor.JDBCChannel.evaluateExpression(JDBCChannel.java:296)
at com.webobjects.jdbcadaptor.JDBCChannel.selectAttributes(JDBCChannel.java:220)
at com.webobjects.eoaccess.EODatabaseChannel._selectWithFetchSpecificationEditingContext(EODatabaseChannel.java:897)
at com.webobjects.eoaccess.EODatabaseChannel.selectObjectsWithFetchSpecification(EODatabaseChannel.java:234)
at com.webobjects.eoaccess.EODatabaseContext._objectsWithFetchSpecificationEditingContext(EODatabaseContext.java:3055)
at com.webobjects.eoaccess.EODatabaseContext.objectsWithFetchSpecification(EODatabaseContext.java:3195)
at com.webobjects.eocontrol.EOObjectStoreCoordinator.objectsWithFetchSpecification(EOObjectStoreCoordinator.java:488)
at com.webobjects.eocontrol.EOEditingContext.objectsWithFetchSpecification(EOEditingContext.java:4069)
at com.webobjects.eocontrol.EOSharedEditingContext.bindObjectsWithFetchSpecification(EOSharedEditingContext.java:401)
at com.webobjects.eoaccess.EODatabaseContext._preloadSharedObjectsWithModel(EODatabaseContext.java:1217)
at com.webobjects.eoaccess.EODatabaseContext.registeredDatabaseContextForModel(EODatabaseContext.java:1012)
at com.webobjects.eoaccess.EODatabaseContext.registeredDatabaseContextForModel(EODatabaseContext.java:1033)
at er.extensions.jdbc.ERXJDBCUtilities.databaseProductName(ERXJDBCUtilities.java:826)
at er.extensions.migration.ERXMigrator._buildDependenciesForModel(ERXMigrator.java:352)
at er.extensions.migration.ERXMigrator._buildDependenciesForModelsNamed(ERXMigrator.java:275)
at er.extensions.migration.ERXMigrator.migrateToLatest(ERXMigrator.java:184)
at er.extensions.appserver.ERXApplication.finishInitialization(ERXApplication.java:1186)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.webobjects.foundation.NSSelector._safeInvokeMethod(NSSelector.java:122)
at com.webobjects.foundation.NSNotificationCenter$_Entry.invokeMethod(NSNotificationCenter.java:588)
at com.webobjects.foundation.NSNotificationCenter.postNotification(NSNotificationCenter.java:532)
at com.webobjects.foundation.NSNotificationCenter.postNotification(NSNotificationCenter.java:546)
at com.webobjects.appserver.WOApplication.run(WOApplication.java:1229)
at er.extensions.appserver.ERXApplication.run(ERXApplication.java:1303)
at com.webobjects.appserver.WOApplication.main(WOApplication.java:548)
at er.extensions.appserver.ERXApplication.main(ERXApplication.java:783)
at com.example.app.Application.main(Application.java:22)
at com.webobjects.jdbcadaptor.JDBCContext._jdbcErrorWithChannel(JDBCContext.java:170)
at com.webobjects.jdbcadaptor.JDBCChannel._evaluateExpression(JDBCChannel.java:344)
at com.webobjects.jdbcadaptor.JDBCChannel.evaluateExpression(JDBCChannel.java:296)
at com.webobjects.jdbcadaptor.JDBCChannel.selectAttributes(JDBCChannel.java:220)
at com.webobjects.eoaccess.EODatabaseChannel._selectWithFetchSpecificationEditingContext(EODatabaseChannel.java:897)
at com.webobjects.eoaccess.EODatabaseChannel.selectObjectsWithFetchSpecification(EODatabaseChannel.java:234)
at com.webobjects.eoaccess.EODatabaseContext._objectsWithFetchSpecificationEditingContext(EODatabaseContext.java:3055)
at com.webobjects.eoaccess.EODatabaseContext.objectsWithFetchSpecification(EODatabaseContext.java:3195)
at com.webobjects.eocontrol.EOObjectStoreCoordinator.objectsWithFetchSpecification(EOObjectStoreCoordinator.java:488)
at com.webobjects.eocontrol.EOEditingContext.objectsWithFetchSpecification(EOEditingContext.java:4069)
at com.webobjects.eocontrol.EOSharedEditingContext.bindObjectsWithFetchSpecification(EOSharedEditingContext.java:401)
at com.webobjects.eoaccess.EODatabaseContext._preloadSharedObjectsWithModel(EODatabaseContext.java:1217)
at com.webobjects.eoaccess.EODatabaseContext.registeredDatabaseContextForModel(EODatabaseContext.java:1012)
at com.webobjects.eoaccess.EODatabaseContext.registeredDatabaseContextForModel(EODatabaseContext.java:1033)
at er.extensions.jdbc.ERXJDBCUtilities.databaseProductName(ERXJDBCUtilities.java:826)
at er.extensions.migration.ERXMigrator._buildDependenciesForModel(ERXMigrator.java:352)
at er.extensions.migration.ERXMigrator._buildDependenciesForModelsNamed(ERXMigrator.java:275)
at er.extensions.migration.ERXMigrator.migrateToLatest(ERXMigrator.java:184)
at er.extensions.appserver.ERXApplication.finishInitialization(ERXApplication.java:1186)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.webobjects.foundation.NSSelector._safeInvokeMethod(NSSelector.java:122)
at com.webobjects.foundation.NSNotificationCenter$_Entry.invokeMethod(NSNotificationCenter.java:588)
at com.webobjects.foundation.NSNotificationCenter.postNotification(NSNotificationCenter.java:532)
at com.webobjects.foundation.NSNotificationCenter.postNotification(NSNotificationCenter.java:546)
at com.webobjects.appserver.WOApplication.run(WOApplication.java:1229)
at er.extensions.appserver.ERXApplication.run(ERXApplication.java:1303)
at com.webobjects.appserver.WOApplication.main(WOApplication.java:548)
at er.extensions.appserver.ERXApplication.main(ERXApplication.java:783)
at com.example.app.Application.main(Application.java:22)
Regards,
yllan
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden