Welcome to ModelRight Database Design Tool - Database Modeling Done Right Sign in | Join | Help

Auto Rename Migrating Column to Prefix with Parent Table Name

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

Note: This technique is no longer needed as ModelRight now has more explicit support for auto-naming objects. 

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
 

arsim said:

gut
Fri, Jan 30 2009 5:32 PM
 

arsim said:

mir
Fri, Jan 30 2009 5:33 PM

Add Comment

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