• 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: Entity Modeler, attributes default value for migrations
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Entity Modeler, attributes default value for migrations


  • Subject: Re: Entity Modeler, attributes default value for migrations
  • From: Theodore Petrosky <email@hidden>
  • Date: Wed, 18 Apr 2012 13:36:14 -0700 (PDT)

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@hidden> wrote:

From: David Holt <email@hidden>
Subject: Re: Entity Modeler, attributes default value for migrations
To: "Theodore Petrosky" <email@hidden>
Cc: email@hidden
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 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: Entity Modeler, attributes default value for migrations
      • From: John Huss <email@hidden>
References: 
 >Re: Entity Modeler, attributes default value for migrations (From: David Holt <email@hidden>)

  • Prev by Date: Re: Entity Modeler, attributes default value for migrations
  • Next by Date: Re: Entity Modeler, attributes default value for migrations
  • Previous by thread: Re: Entity Modeler, attributes default value for migrations
  • Next by thread: Re: Entity Modeler, attributes default value for migrations
  • Index(es):
    • Date
    • Thread