Hello,
You may want to move this question to the Wonder list for better
answers.
My response is below:
On 20-Jun-08, at 12:33 AM, Yung-Luen Lan wrote:
Hi,
Since Chuck said "Use prototype, or you're stupid" in his awesome
session in WOWODC 08, I looked into my project and realized that I
need to modernize it: legacy format (eogenerator / Xcode project / not
fluffy bunny layout), not using prototype in EOModel, using
session().defaultEditingContext(), pageWithName("ClassName"), etc.
Thanks to the help from David LeBer and Pascal, I converted my project
into fluffy bunny during WWDC webobjects lab.
However, when I come back and try to continuely improving my code, I
got a little bit confused about migration.
Today I read an article about migration:
http://www.stepwise.com/Articles/2005/DBChanges/index.html
finally I realized where all the java file in my project like
Database.java, Updater.java, Update0.java come from. Of course I
didn't write the corresponding UpdateX.java file since I have no idea
what it do before. When I changed EOModel, I just manually write SQL
statement and paste into psql.
Now we have er.extensions.migration. How do I convert those old-school
java file into WONDER world? I mean, my app has already run as
production server for a long time. How do I leverage the ERXMigration
into a project that didn't start with ERXMigration at first?
You'll need to read the package summary file <http://
webobjects.mdimension.com/wonder/api/er/extensions/migration/package-
summary.html> for information about how to incorporate migrations
into an existing project. You will probably need to choose one method
or the other. You could, for example, take the current state of the
database as your Migration 0 and use the Wonder method going forward.
Remember to either update your version table or set the property
described in the overview file so that you don't recreate your
existing tables. Be really careful with this stuff!! Back up your
databases before you do any testing with it!!
"Introducing Migrations into Existing Systems
The migrations counter starts at zero, so YourModel0 is the first
migration that will run. Migration zero is the one that will
generally have your first create table statements in it. So if you
are wanting to use migrations on an application that is already
deployed with an existing database, you need to tell the migration
system "I'm already at version 1 (or version x), so don't recreate
the tables -- just pretend you've already done that." You can use
YourModelName.InitialMigrationVersion=2 (for example) in your
properties file to specify this. I generally specify these ONLY in
the Application properties file (and not in a framework Properties
file), because a framework might be reused in multiple applications,
and any NEW deployment would actually need to start at 0 (rather than
the application-specific "v2")."
After
that, when I make changes to EOModel, I must create an migration class
like MyMigrationX+1 right? Anything else?
No just the new migration file for each model every time you update
the model.
And I'm adding prototype to my EOModel, which changes my EOModel a
lot. (each attribute will be assigned a prototype, which my change
their type or width.) Should I write my migration class for every
column manually?
Not sure what you mean by this.
Is there any way to generate those migration
automatically?
You can generate the base migration class using EntityModeler. It
takes prototypes into consideration, so this might address your
question above.
David
Regards,
yllan
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (Webobjects-dev@lists.apple.com)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/programmingosx
%40mac.com
This email sent to [EMAIL PROTECTED]
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (Webobjects-dev@lists.apple.com)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com
This email sent to [EMAIL PROTECTED]