Rename Schema Refactoring

This refactoring finds and changes all hard-coded references to database table and fields that you want to rename. You select the projects or directories that you want to change, input a list of old and new names, and the refactoring writes the modified files to an output directory which you can review before merging the changes into your source.

Usage

  1. In the Navigator view, select the files, directories, and/or projects to be refactored.
  2. From the Navigator view's context menu, choose ProRefactor > Rename Schema.
  3. The Rename Schema Refactoring wizard is presented. Input a list of old and new name pairs into the editor, or else enter the name of a file which contains old and new name pairs.
  4. This refactoring writes the modified files out to a temporary directory of your choice.

Features

  • Is not fooled by buffer names or by abbreviated table or field names.
  • Name qualifiers (db.table, table.field, db.table.field) are retained during the change.
  • A table can be renamed at the same time that fields in that table are renamed.

Caveats

  • Database name changes are not supported (logical, alias, or otherwise).
  • Buffer names are not changed.
  • Once this refactor is complete, and you have merged the results into your code, you should use a grep tool to find any remaining old name references in comments, strings, and preprocessor directives. Also consider any dynamic queries where you may be deriving the strings from external sources.

Example

Here is an example renaming list:

sports2000.customer client
sports2000.customer.name legalName
sports2000.invoice.amount totalAmount

Here is the code before refactoring:

find first customer.
display customer.name.
display cust.na.
display customer except name.
display customer.creditLimit.

find first invoice.
display invoice.amount.
display invoice except amount.

def buffer bCustomer for customer.
find first bCustomer.
display bCustomer.name.
display bCustomer except name.
display bCustomer.creditLimit.

def buffer bInvoice for invoice.
find first bInvoice.
display bInvoice.amount.
display bInvoice except amount.

Here is the code after Rename Schema refactoring has been run:

find first Client.
display Client.legalName.
display Client.legalName.
display Client except legalName.
display Client.creditLimit.

find first invoice.
display invoice.totalAmount.
display invoice except totalAmount.

def buffer bCustomer for Client.
find first bCustomer.
display bCustomer.legalName.
display bCustomer except legalName.
display bCustomer.creditLimit.

def buffer bInvoice for invoice.
find first bInvoice.
display bInvoice.totalAmount.
display bInvoice except totalAmount.