> Date: Thu, 17 Mar 2011 18:36:55 +0800 > From: Yung-Luen Lan <[email protected]> > Subject: First Time Database Migration fail > To: webobjects <[email protected]> > Message-ID: > > <[email protected]> > Content-Type: text/plain; charset=ISO-8859-1 > > 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 >
what are the property settings? here are the setting I use on a project that work well: # Connection Dictionary dbConnectURLGLOBAL=jdbc:postgresql://localhost/colorgrid?capitalizeTypenames=true&zeroDateTimeBehavior=convertToNull dbConnectUserGLOBAL=admin dbConnectPasswordGLOBAL=mypassword dbConnectPluginGLOBAL=PostgresqlPlugIn dbConnectDriverGLOBAL=org.postgresql.Driver dbEOPrototypesEntityGLOBAL=EOJDBCPostgresqlPrototypes # Migrations er.migration.migrateAtStartup=true er.migration.createTablesIfNecessary=true #commented out to make the system not look to the model only #er.migration.modelNames=TheWorkTrackerModel ColorGridModel.MigrationClassPrefix=com.eltek.migrations.ColorGridMigration > <<Stack Trace>> > Position: 38at > _______________________________________________ Do not post admin requests to the list. They will be ignored. Webobjects-dev mailing list ([email protected]) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com This email sent to [email protected]
