• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: ERXMigrationDatabase and postUpgrade
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: ERXMigrationDatabase and postUpgrade


  • Subject: Re: ERXMigrationDatabase and postUpgrade
  • From: David Avendasora <email@hidden>
  • Date: Fri, 10 Apr 2009 16:49:49 -0400

Hi Sanford,

Your Migration class needs to implement IERXPostMigration in order for that method to get called, I believe.

According to the Package Description for Migrations:
http://webobjects.mdimension.com/wonder/api/index.html?overview-summary.html
<snip>

To perform a "post op", your migration can implement IERXPostMigration instead of IERXMigration, and this adds the additional method:

public void postUpgrade(EOEditingContext editingContext, EOModel model) throws Throwable;
So as migrations are running in dependency order, ERXMigrator keeps track of "Post Migrations", which will themselves execute in dependency order, but only after a completely successful model migration. So by the time IERXPostMigrations begin to run, all of your EOModels will match the database tables. postUpgrades also each run in a transaction. editingContext.saveChanges() will be called for you after postUpgrade is done.


</snip>

Dave


On Apr 10, 2009, at 4:01 PM, Sanford Selznick wrote:

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@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden



_______________________________________________ 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
  • Follow-Ups:
    • Re: ERXMigrationDatabase and postUpgrade
      • From: Mike Schrag <email@hidden>
    • Re: ERXMigrationDatabase and postUpgrade
      • From: Sanford Selznick <email@hidden>
References: 
 >ERXMigrationDatabase and postUpgrade (From: Sanford Selznick <email@hidden>)

  • Prev by Date: ERXMigrationDatabase and postUpgrade
  • Next by Date: [MEET] Chicago CocoaHeads / CAWUG Tuesday 4/14
  • Previous by thread: ERXMigrationDatabase and postUpgrade
  • Next by thread: Re: ERXMigrationDatabase and postUpgrade
  • Index(es):
    • Date
    • Thread