The Forward Engineering function allows users to export the database objects created in SqlDBM projects by generating SQL scripts. Through Forward Engineering, users can generate complete CREATE statements for selected objects or ALTER scripts for changes between project versions or environments.
SqlDBM can also forward engineer dbt source and model YAML. For more information, see the related article at the end of this page.
Getting started
Note that SqlDBM will not make any changes to your database directly. The generated script should be run manually once it has been reviewed.
To start, click the "Forward engineer" button from the left pane.
Generation Options
Generation options (on the right panel) allow users to fine-tune the SQL being generated. Please review the available options to understand how to customize the resulting DDL script.
The following options are available but will vary by database and project type:
Format
This selection affects the format of the script being generated. Currently, DDL and YAML (dbt format) are supported. See the related article to learn more about dbt YAML generation.
DDL and alter script - (default) used to generate DDL for CREATE and ALTER statements
dbt source YAML - outputs objects and properties in dbt source format
dbt model YAML - outputs objects and properties in dbt model format
Main
Safe scripts - adds the "IF NOT EXISTS" clause to the CREATE statement. Note that selecting both "Create" and "Drop" options for a given object (e.g., Table) will override this flag. The various configurations and resulting scripts are as follows:
Create and Drop selected: results in CREATE OR REPLACE [OBJECT]
Safe scripts and (Create or Drop): results in CREATE or DROP [OBJECT] IF NOT EXISTS
Create or Drop only: results in CREATE or DROP [OBJECT], respectively
[Object type] (e.g., Table)
Create - select to generate the CREATE table SQL for the corresponding object.
Drop - select to generate the DROP table SQL for the corresponding object.
Tags (Snowflake)
Create - select to generate the CREATE table SQL for the Tag object itself
Drop - select to generate the DROP the Tag object
Apply - select to generate tag assignments in objects in which Tags are applied
Quote Options
Respect object's 'Use Quotes' property (Snowflake only) - use the object (or column) setting
Double Quotes - select to enable double quotes when generating object names (e.g., "My_Schema"."My_Table")
Empty - select to generate object names without quotes (e.g., My_Schema.My_Table)
Generate SQL Script
To generate the DDL for the database objects created in your project, follow these steps.
Set the options (as described above)
Select all or some of the objects you wish to generate
Press the "Generate SQL" icon or button as indicated
Review the generated script on the next screen and run it in your database environment.
Use the broom icon to return to the "Forward Engineering" screen and start again.
Use the copy icon to copy the script to the clipboard for export.
Generate alter script
Use the Forward Engineering feature to generate an alter script with all the changes made between the current and any previous revisions.
Note that any unsaved changes will not be reflected until they are saved to a revision.
To generate the DDL for altered objects, follow these three steps.
Set the options (as described above)
Press the "Generate Alter SQL" icon or button as indicated (all modifications will be considered)
Select the "Generate Alter SQL" option.
Choose any previous revision to generate the later script.
Verify the script and proceed,
Use the broom icon to return to the "Forward Engineering" screen and start again.
Use the copy icon to copy the script to the clipboard for export.
See also