I think this is commonly handled in a post migration http://webobjects.mdimension.com/hudson/job/Wonder/javadoc/er/extensions/migration/IERXPostMigration.html
Just make your migration implement that interface, and the post migration
method will be called after the tables are created. From the package
documentation:
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.
Ramsey
On Nov 1, 2011, at 7:06 AM, Theodore Petrosky wrote:
> I use migrations for all of my company stuff. They are great!!!!
>
> I am running into a problem:
>
> public void upgrade(EOEditingContext editingContext, ERXMigrationDatabase
> database) throws Throwable {
>
> ERXMigrationTable workingTable =
> database.existingTableNamed("t_employee");
>
> workingTable.newLargeStringColumn("c_password", true);
> workingTable.newLargeStringColumn("c_user_name", true);
>
> ERXJDBCUtilities.executeUpdate(database.adaptorChannel(),
> "update t_employee " +
> "set c_password = '4004'");
>
> ERXJDBCUtilities.executeUpdate(database.adaptorChannel(),
> "update t_employee " +
> "set c_user_name = 'theuser'");
>
>
> workingTable.existingColumnNamed("c_password").setAllowsNull(false);
>
> workingTable.existingColumnNamed("c_user_name").setAllowsNull(false);
>
> }
>
> I get an error:
>
> ERROR: cannot ALTER TABLE "t_employee" because it has pending trigger events
>
> migrations doesn't like it when I try to update these two columns in one pass.
>
> My solution is to create a migration after this one and put (obviously
> commenting out those lines in the first migration):
>
> public void upgrade(EOEditingContext editingContext, ERXMigrationDatabase
> database) throws Throwable {
>
> ERXMigrationTable workingTable =
> database.existingTableNamed("t_employee");
>
> ERXJDBCUtilities.executeUpdate(database.adaptorChannel(), "update
> t_employee " +
> "set c_user_name = 'theuser'");
>
> workingTable.existingColumnNamed("c_user_name").setAllowsNull(false);
>
> }
>
> can this be done in one pass?
>
> Ted
>
>
> _______________________________________________
> 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/ramseygurley%40gmail.com
>
> This email sent to [email protected]
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________ 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]
