Welcome to ModelRight Sign in | Join | Help

Auto Rename Migrating Column to Prefix with Parent Table Name

File Details
Downloads: 150 File Size: 589 bytes
Posted By: admin Views: 280
Date Added: Thu, Oct 11 2007

As of Build 2020, ModelRight has the ability to rename a migrating column as it migrates.

For example, you could prefix a migrating column with the parent table name.  We did this via a script that gets evaluated and returns a name for the migrating column.  This approach is more general than just being able to prefix with something specific - like the parent table name. 

To use it go to the Script Explorer (probably a tab for it next to Model Explorer), expand to <database>/Relation/Auto Rename Migrating Column.  Enter the following text for the script in the property browser (this will prefix the migrating column with the parent table name):

'  Auto Rename Migrating Column Script
Sub Evaluate_OnLoad()
    Dim Context
    Set Context = CreateObject("SCF.ScriptContext")
    Dim Document
    Set Document = Context.ScriptDocument
    Dim MigratingColumn
    Set MigratingColumn = Context.MigratingColumn
    Dim MigratingRelation
    Set MigratingRelation = Context.MigratingRelation
    Dim ParentTable
    Set ParentTable = MigratingRelation.Property("Parent Table").AsObject
    Document.Write(ParentTable.Property("Name").AsString & "_" & MigratingColumn.Property("Name").AsString)
End Sub

If you want all of your models to use this, then right click on the script in the script explorer and select Save to Disk.

Comments
No comments exist for this file.

Add Comment

Name (required)
Web Site (optional)
Comment (required)
Add