Toad World® Forums

Deleting a relationship without deleting the associated attributes.

I created some wrong relationships within my model (TDM 6.1, Postgres 9.5) incorrectly linking the PK columns of both entities.

At some point I added the correct relationships including adding the correct FK columns.

I don’t really know how I did it, but somehow the wrong relationship is now between both PK columns, and when I delete that relationship the two PK columns are deleted automatically as well (which of course I don’t want).

So my question is: is there a trick so that I can delete that relationship but keep those columns that are incorrectly assumed to depend on that relationship?

It’s “Relationship29” in the below screenshot. If I delete that relatioinship, TDM als deletes both ID columns.

If needed I can supply the model itself but I did not find a way to attach a file other then a screenshot here.

Hello,

I assume that ID attribute in entity user_account was created by migration from entity element_type, when you create relationship29. So it is migrated attribute and it is dependent on relationship. There is no way how change this behavior in Toad Data Modeler UI. The only way is modify this attribute by scripting. Attribute has two boolean properties:

  • Migrated
  • KeepForeignKey
    I assume that user_account.id has Migrated = true and KeepForeignKey = false. You need switch theses values.

This is simple script that can be run from Scripting window in TDM (MainMenu - Expert Mode - Scripting Window).

function main(){
var Ent = Model.Entities.GetObjectByName(‘user_account’);
var Attr = Ent.Attributes.GetObjectByName(‘ID’);

//Only Log Current state
if (Attr.Migrated)
Log.Information(‘Migrated’);

if (Attr.KeepForeignKey)
Log.Information(‘Keep Foreign Key’);

//Change your state
Attr.Migrated = false; **
** Attr.KeepForeignKey = true;

}

You need select appropriate model in Scripting window before run it.

Regards

Thanks that did the trick.

Seems a duplicate of my question: www.toadworld.com/…/32306

Seems a duplicate of my question: www.toadworld.com/…/32306