unique constraint

3 views
Skip to first unread message

Theodore Petrosky

unread,
Mar 30, 2012, 3:18:37 PM3/30/12
to webobje...@lists.apple.com
Is there a way to put a unique constraint on an attribute in Entity Modeler and have it create the migrations. I don't see anything in any of the menus.

Ted
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (Webobje...@lists.apple.com)
Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/webobjects-dev/webobjects-dev-garchive-31333%40googlegroups.com

This email sent to webobjects-dev...@googlegroups.com

Theodore Petrosky

unread,
Mar 30, 2012, 3:40:42 PM3/30/12
to John Huss, webobje...@lists.apple.com
I found the entity index by right clicking on the attribute, but I can not find anything that says 'unique'.

--- On Fri, 3/30/12, John Huss <john...@gmail.com> wrote:

From: John Huss <john...@gmail.com>
Subject: Re: unique constraint
To: "Theodore Petrosky" <ted...@yahoo.com>
Date: Friday, March 30, 2012, 3:27 PM

On Fri, Mar 30, 2012 at 2:18 PM, Theodore Petrosky <ted...@yahoo.com> wrote:
Is there a way to put a unique constraint on an attribute in Entity Modeler and have it create the migrations. I don't see anything in any of the menus.

You add an "entity index" and mark it as unique in modeler.  A unique index is essentially the same as a unique constraint for most databases. 

John Huss

unread,
Mar 30, 2012, 3:47:15 PM3/30/12
to Theodore Petrosky, WebObjects-Dev Mailing List List
Distinct
unique.tiff

Paul Hoadley

unread,
Mar 30, 2012, 8:37:02 PM3/30/12
to Theodore Petrosky, webobje...@lists.apple.com
Hi Ted,

On 31/03/2012, at 5:48 AM, Theodore Petrosky wrote:

> Is there a way to put a unique constraint on an attribute in Entity Modeler and have it create the migrations. I don't see anything in any of the menus.

1. Right-click entity, select "New Entity Index".

2. Give the index a name, select "Distinct" for Constraint, select the attribute in the drop-down at the bottom and click "Add".

3. Generate migration.

Whether this works might be database-plugin-dependent, but I can vouch for PostgreSQL. It should generate something like this:

personTable.addIndex(new ERXMigrationIndex("person_username_key", true, new ColumnIndex("username")));


--
Paul.

http://logicsquad.net/

Theodore Petrosky

unread,
Mar 30, 2012, 9:25:25 PM3/30/12
to Paul Hoadley, webobje...@lists.apple.com
I must have been in a weird state as the dialog for creating the Distinct setting was not showing up.

But we are working fine (and I also use postgresql so I project no problems)


Ted

--- On Fri, 3/30/12, Paul Hoadley <pa...@logicsquad.net> wrote:

> From: Paul Hoadley <pa...@logicsquad.net>
> Subject: Re: unique constraint
> To: "Theodore Petrosky" <ted...@yahoo.com>

Reply all
Reply to author
Forward
0 new messages