Hello,

  I'm experimenting with Migrations.  I'm a little new to all this.

What's the proper way to implement postUpgrade? Below is a snippet of what I've got, but postUpgrade is never called. I don't see an ERXMigrationDatabase.PostMigration class. And I don't really want to duplicate what's in ERXMigrationDatabase.Migration.

public class CCLimsModel0 extends ERXMigrationDatabase.Migration {
  ...

  @Override
  public void upgrade(EOEditingContext editingContext,
                       ERXMigrationDatabase database) throws Throwable {
    ERXMigrationTable accessTable = database.newTableNamed("Access");
    accessTable.newIntegerColumn("id", false);
    accessTable.newStringColumn("password", 255, false);
    accessTable.newStringColumn("username", 255, false);
    accessTable.create();
    accessTable.setPrimaryKey("id");
  }

  public void postUpgrade(EOEditingContext editingContext,
                        EOModel model) throws Throwable {

    // Add a record after migrations are done.
    Access a = new Access();
    editingContext.insertObject(a);
    a.setUsername("thing1");
    a.setPassword("thing2");
    editingContext.saveChanges();

  }

}

Thank you,
  Sanford

PS - Wouldn't it be cool if the migration generator in Entity Modeler would use the string constants from the model for table and column names instead of in-line strings? :-)
_______________________________________________
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]

Reply via email to