No not really,
I create a model that has an attribute (an intBoolean) called isFiled. I ask
Entity Modeler to create the migrations for me and it gives me:
@Override
public void upgrade(EOEditingContext editingContext, ERXMigrationDatabase
database) throws Throwable {
ERXMigrationTable creativeBriefTable =
database.newTableNamed("creativebrief");
creativeBriefTable.newIntegerColumn("id", false);
creativeBriefTable.newFlagBooleanColumn("isfiled", false);
creativeBriefTable.newLargeStringColumn("jobnumber", true);
creativeBriefTable.create(); creativeBriefTable.setPrimaryKey("id");}
notice it created:
creativeBriefTable.newFlagBooleanColumn("isfiled", false);
except I need:
creativeBriefTable.newFlagBooleanColumn("isfiled", false, false);
the last property is the 'default' value.
from psql:
isfiled | boolean | not null default false
it is no big deal except in the design stage of a database. if I mess with the
schema and recreate the migrations, I have to remember which attributes I
created default values for.
I was hoping there was a box in Entity Modeler that said, "Default Value".
there are two signatures for newFlagBooleanColumn
newFlagBooleanColumn(name, allowNull)newFlagBooleanColumn(name, allowNull,
defalutValue)
newIntegerColumn is the same (two signatures)
Ted
--- On Wed, 4/18/12, David Holt <[email protected]> wrote:
From: David Holt <[email protected]>
Subject: Re: Entity Modeler, attributes default value for migrations
To: "Theodore Petrosky" <[email protected]>
Cc: [email protected]
Date: Wednesday, April 18, 2012, 4:19 PM
Hi Ted,
You can use EOF to set your values in migrations, so I guess you could set your
default values in your entity?
See Mike's example app SecretPal and the SecretPal0 migration postUpgrade
method. That might give you what you are looking for.
Also just recently someone (Ramsey?) posted that you can put default values in
your User Info Dictionary for the entity.
Before I found out about this approach I was using direct SQL statements (which
means that the migration may/will break across databases, so Mike's method is
better if you can do it).
@Override public void upgrade(EOEditingContext editingContext,
ERXMigrationDatabase database) throws Throwable {
ERXJDBCUtilities.executeUpdate(database.adaptorChannel(), "INSERT INTO Role
(roleDescription,id) VALUES ('Admin',1)", true); }
Is this what you're after?
David
On 2012-04-18, at 12:33 PM, Theodore Petrosky wrote:
When I create an attribute in Entity Modeler, and create the migrations, it
does a beautiful job.
creativeBriefTable.newFlagBooleanColumn("isfiled", false);
and I know I can add a default value here
creativeBriefTable.newFlagBooleanColumn("isfiled", false, false);
problem is that if I go back and alter the schema and recreate the migration, I
must remember to add in the default selector(s).
I don't see in EM where I could put in a default value (or I am blind).
Is there a place to put in a default value in Entity Modeler so the migrations
it creates include the default value?
Ted
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list ([email protected])
Help/Unsubscribe/Update your Subscription:
https://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 ([email protected])
Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com
This email sent to [email protected]