I'm currently trying to write a transformation script that creates a new foreign key, but I can't quite seem to get it to work.
Given the following variables, could someone quickly explain the steps I need to go through?
model // The model variable provided to the script
source_table // a 'Table' object, representing the source table. Assume it has a primary key "id"
target_table // a 'Table' object, representing the target table. Assume it has a primary key "id", and a column "source_id" to be used as the foreign key.
Thank you for your quick reply. I had searched, but I obviously wasn't using the right terms.
Looking at the code in that thread, I was able to create a foreign key, but it adds a column to the source table. Is there any way to create a foreign key without creating a new column? Or, failing that, how can I alter the FKAssociation object so that it points to a column of my choosing?
Looking at the second link, I tried using the addForeignKey method, but it triggers a script evaluation error. I'm assuming my types are wrong. My referred is obtained by target_table.getPK() and the list of colums is:
list = new List();
list.add(column) // where column is a Column object
Edited by: 958587 on 13-Sep-2012 03:42