Generating database schema SQL

Use the Database Schema Tool's setup command to generate an SQL script for creating an initial database schema.
You or your database administrator can review and run this script against your database system to create the databases required by the model.

To generate code for setting up a new database schema:

  1. In NexJ Studio, click the arrow next to the Run Tool button and select Database Schema Tool.
    The Database Schema Tool opens.
  2. From the Model section, choose the model that you want to create a schema for:
    • For the currently loaded model, shown in the label, select Current.
    • For a base model in your Model Library, select Base Model and select one of the available models from the drop-down.
    • For a previously published model in your file system, select Published Model JAR and click the Browse button to locate the published model. You might be prompted to specify the directory where the published model's mixins are located.
  3. If you want to use your database to run the application in a test environment, select the Test check box.
  4. Specify the server and connections that you want the application to support when running with this database.
    Note: If you are creating a schema for the current model, then the fields allow you to select from among the environment, server, and connection files within the model. If you are creating a schema for a base or published model, then your choice is limited to only those server and connection files contained in your global environment folder.
    1. In the Server field, specify either the server or environment file that contains the server configuration information you want to use when creating the database schema. If you specify an environment file, then it will also include the connections information.
    2. In the Connections field, specify the connections file that you want to use when creating the database schema. If you previously selected an environment file in the Server field, then it already has the connections information, and this field becomes inactive.
  5. In the Command field, select setup.
  6. In the Data Source field, select the model data source that you want to set up the schema for.
    Your selection must be one of the relational data sources described in the model.
  7. In the Output Directory field, click the Browse button , specify where you want to save the resulting SQL file, and click OK.
  8. Optional: In the Owner field, specify an owner prefix for your tables.
    This field refers to the metadata table owner value. If you leave the field blank, a default value of dbo is used.
  9. Click Advanced to display the additional VM arguments that will be used in the script.
  10. In the VM Arguments field, review the parameters and their values.
    Important: The directories set for the following parameters must exist on the machine where the scripts will be run:
    • datapath
    • indexpath
    • longpath
    • undopath
  11. Click Run.
The tool outputs a script file named modelname_datasourcename_setup.sql to the output directory, where modelname is the name of the chosen model and datasourcename is the name of the chosen data source.
You can now provide your database administrator with this file to create the database schema, or you can run it yourself if you have database administrator privileges.