Re: Primary keys
Re: Primary keys
- Subject: Re: Primary keys
- From: Chuck Hill <email@hidden>
- Date: Thu, 02 Oct 2014 18:17:20 +0000
- Thread-topic: Primary keys
On 2014-10-02, 10:45 AM, "Mark Wardle" wrote:
Thanks Ted, that is interesting. Unfortunately, the existing primary key is used in joins from other tables so I think it will need to be a multi-step procedure.
Take home message for me is never ever have primary keys with any kind of meaning, even if coming from an external reputable third-party because even they will decide to change their primary keys in the future. I’ve not done it since but this
is from work from years ago so I blame my younger self!
At least you are coming FROM that and not going TO that! :-) I’ve seen that done.
Chuck
Mark
On 2 Oct 2014, at 12:01, Theodore Petrosky < email@hidden> wrote:
if there is already a primary key, then I think the correct thing to do is to drop the first and add what you want. I have no experience doing this, but it seems logical.
ERXMigrationTable
theTable =
database.existingTableNamed(“yourTable”);
theTable.dropPrimaryKey(columns);
theTable.setPrimaryKey(columns);
interesting that when I ask WOLips, it comes up with columns (plural). I assume you can add a multi column primary key. I have
no idea where that would be useful. or this implications as a primary key does not want to be a class property.
Ted
On Oct 2, 2014, at 5:00 AM, Mark Wardle < email@hidden> wrote:
Dear all,
I need to add a new primary key to a table that already contains data.
Is it possible to use migrations to add this and have the column auto-populated with a serial number?
My other plan was to create an integer column and then, in code, iterate through the objects manually setting the serial integer, and then later on migrating that to a primary key. Would this then break primary key generation for newly created
objects?
All advice appreciated!
Many thanks,
Mark
--
Dr. Mark Wardle
Consultant Neurologist, University Hospital Wales, Cardiff, UK
Email: email@hidden or email@hidden Twitter: @mwardle
Telephone: 02920745274 (secretary) or facsimile: 02920744166
_______________________________________________
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
|
_______________________________________________
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