PyCharm 2021.1 Help

Run migrations

After you reviewed changes in the object source code, you can submit these changes to a database. When you press the Submit button (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.

PyCharm 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).

Colors of object state

By default, all the objects are displayed in black. It means that the current state of an object source code does not differ from source code of the same object on a server.

If source code of the object has been changed but there are no conflicts with the object source code on a server, the object is displayed in blue.

If there are conflicts in source code of a local object and the same object on a server, the object is displayed in red. If you open such object in the editor, you will see a notification about conflicts.

For example, on the following screenshot, the Do_Something procedure is modified but contains no conflicts, the V1_trg_i trigger was modified and conflicts with source of the same trigger on a server, other objects are not modified.

Generate a migration script

  1. Select two schemas, right-click any of them, and click Compare. Alternatively, select two schemas and press Ctrl+D.

  2. In the Diff Between <schema_1> and <schema_2> dialog, specify comparing options.

  3. Depending on the migration direction, click Apply Right to the Left and Apply Left to the Right.

    Generate a migration script

Modify SQL objects with a migration tool

  1. Double-click the database object.

  2. Make changes in a source code of the object. PyCharm highlights all changes in the gutter.

  3. Click the Submit icon (the Submit icon).

  4. In the Object Migration window, review changes and click OK.

    Migrate a database object
Last modified: 09 July 2021