After you reviewed changes in the object source code, you can submit these changes to a database. When you press the Submit button () in the Database changes tool window, you see the Object Migration dialog. The Object Migration dialog displays a migration script for the object.
A migration script is code that changes all database or a part of it. You can use migration scripts to add or remove a column, upgrade the database version, or change column properties.
IntelliJ IDEA can automatically generate a migration script but you must check it before running.
You can use a migration tool for the following types of SQL objects: procedures, functions, views, materialized views, rules (PostgreSQL), events (MySQL), scripts (Exasol), triggers (except for PostgreSQL).
Generate a migration script
Select two schemas, right-click any of them, and click Compare. Alternatively, select two schemas and press Ctrl+D.
In the Diff Between <schema_1> and <schema_2> dialog, specify comparing options.
Depending on the migration direction, click Apply Right to the Left and Apply Left to the Right.
note
The DEFINER clause specifies the security context (access privileges) for the routine execution. Select Ignore definer to skip this clause when you generate a migration script.
Modify SQL objects with a migration tool
Double-click the database object.
Make changes in a source code of the object. IntelliJ IDEA highlights all changes in the gutter.
Click the Submit icon ( ).
In the Object Migration window, review changes and click OK.
tip
To see the side-by-side diff between the original code and your changes, click the Show Diff icon ( ).