NexJ Logo

Generating upgrade steps for data sources

In the Persistence layer in NexJ Studio, you can generate upgrade steps for data sources and keep track of your changes in an .upgrade file, using the Generate Upgrade Steps menu option. When you generate upgrade steps for a data source, you will also include any changes from augments that apply to that data source.

When you generate upgrade steps from the menu of the upgrade file for the corresponding root data source, schema changes applied through a data source augment are recognized.

Data source augments enable you to extend an existing data source without editing the original code. For more information about augments, see Managing model behavior using aspects and augments.

An .upgrade file contains a set of changes to a relational data source from version to version. It is used by tools like the Data Load Tool and the Database Schema Tool to bring databases up to date in different environments.

The generated upgrade steps enable you to upgrade your physical database. NexJ Studio creates the upgrade steps by comparing the current version of the model to an earlier version of the model.

To generate the upgrade steps, complete the following procedure in the Persistence layer in NexJ Studio:

  1. Select the Data Sources tab, right-click your data source, and select Generate Upgrade Steps.
  2. Set the Current Data Source to your data source and select the corresponding Upgrade file, usually Main.
  3. Under Old Data Source, select Local History. This allows you to look at the changes you have made to the file recently and find the appropriate old version to start from. You are going to use a published model as the old model.
  4. Select the Revision that doesn't have your table in it. You can look at the differences by double-clicking on the Revision History items to compare them.
  5. Click Next.
  6. Whenever you upgrade a database, you must update the number in the Version field; for example, you would change 3.1092.1307.167.53 to 4.1092.1307.167.53.
  7. In the Description field, enter text that describes the change.
    On the left side, NexJ Studio displays a list of the upgrade steps that will be applied to the database.
  8. Click Finish to create the upgrade steps.
    At the top of the window, NexJ Studio displays a list of all upgrades that have been applied to the data source, including upgrades inherited from the base model. Your upgrade is the first one in the list.

After you have completed this procedure, you must ensure that your current model's version matches the upgrade version. Click the Set Current Model button Set current model button in the toolbar to open the Model Library and edit the model Version field to match the version associated with the upgrade steps. This enables NexJ Studio to recognize that the model has changed from the previous version and that your update needs to be applied to the supporting data stores.

Related topic

Managing model behavior using aspects and augments