Custom SQL Scripts
Custom SQL scripts let you add SQL that should run alongside generated DDL when DBModeler’s built-in model is not enough.
What scripts are for
Section titled “What scripts are for”Use custom SQL scripts when you need logic such as:
- helper objects created before tables
- post-table adjustments or patch logic
- hand-authored SQL that belongs to a specific version
Scripts are version-scoped, so they live with the checkpoint they belong to.
Script phases
Section titled “Script phases”DBModeler uses two execution phases:
PRE_TABLESfor SQL that should run before generated table DDLPOST_TABLESfor SQL that should run after generated DDL
This keeps custom logic aligned with generated schema output.
Create and edit scripts
Section titled “Create and edit scripts”From the scripts dialog you can:
- create a script
- name it
- choose the phase
- edit the SQL body
- reorder scripts within the same phase
The editor helps with authoring, but SQL correctness is still your responsibility.
Script accumulation across versions
Section titled “Script accumulation across versions”When you export migration SQL up to a given version, DBModeler can accumulate scripts from previous finalized versions.
This matters when a deployment needs the full chain of custom SQL, not just the newest script.
Supersede older scripts
Section titled “Supersede older scripts”If a newer version needs to replace an earlier custom script, you can mark the new script as superseding the older one.
Use this when a previous script should no longer participate in the accumulated export path.
Good practices
Section titled “Good practices”- Keep scripts narrowly scoped to the version that introduced them.
- Use
PRE_TABLESonly when ordering truly matters. - Re-run SQL preview after adding or reordering scripts.
- Prefer clear script names that describe purpose, not just timing.
Next: Versions and Migrations and Export SQL