Schema comparison and migration
In the Database tool window, select two database objects and press .
This functionality relies on the Database Tools and SQL plugin, which is bundled and enabled in PhpStorm by default. If the relevant features aren't available, make sure that you didn't disable the plugin.
Press to open the IDE settings and then select Plugins.
Open the Installed tab, find the Database Tools and SQL plugin, and select the checkbox next to the plugin name.
In PhpStorm, you can compare two database objects of the same type. For example, you can compare two schemas, two tables, or two routines. Databases with objects can be hosted on different servers. PhpStorm shows you the differences in the structures of these two objects in the Migration dialog.
Migration is a process of transferring structure and changes from one object to another (for example, from one schema to another). In PhpStorm, these objects are called Origin and Target. The migration script is generated to make Target equal to Origin. But you can modify the script to satisfy your requirements.
For changes, PhpStorm uses the following color coding.
Color | Description |
---|---|
Objects added in Origin, which will be created in Target in case of a successful migration. | |
Modified objects, which will be altered in Target. | |
Objects deleted in Origin, which will be dropped in Target in case of a successful migration. |
See the description of the dialog controls in the reference section.
In the Database tool window ( View | Tool Windows | Database) , select two objects of the same type. For example, two schemas.
Right-click the selection and navigate to Tools | Compare Structure. Alternatively, press .
In the Migration dialog, click an item in Origin or Target fields.
Click the Object Properties Diff tab.
In the Migration dialog, click an item in Origin or Target fields.
Click the DDL Diff tab.
To display all items that are identical in Origin and Target objects, select the Show identical checkbox.
EnabledDisabled
In the Database tool window ( View | Tool Windows | Database) , select two objects of the same type. For example, two schemas.
Right-click the selection and navigate to Tools | Compare Structure. Alternatively, press .
A set of statements that you can use for writing migration scripts is generated in the Script Preview tab.
In the Script Preview tab, verify that the migration scripts are correct.
Click Execute. Alternatively, click Open Query in Console to open all the scripts in a query console.
To exclude a change, click the checkbox neat the change.
To exclude all the changes, click the checkbox near the Target label.
To include all the changes that were excluded, click the checkbox near the Target label.
Icon | Tooltip and shortcut | Description |
---|---|---|
Expand All | Expands all the collapsed nodes. | |
Collapse All | Collapses all the expanded nodes. | |
Swap | Swap the Origin and Target panels. | |
Options | Select options according to which changes are differentiated. If the option is selected, properties that are mentioned in the option are ignored in the diff.
| |
Include change | Apply the selected change. | |
Show identical | Show all items that are identical. |
Item | Tooltip and Shortcut | Description |
---|---|---|
/ | Previous Difference/Next Difference / | Jump to the next or previous difference. |
Jump to Source | Open a definition of the selected object in the active pane in the editor. The caret is placed in the same position as in the Diff Viewer. | |
Side-by-side viewer | Select a viewer mode: Side-by-side viewer or Unified viewer. The side-by-side mode has two panels, and the unified mode has one panel. | |
Whitespaces | Define how the Diff Viewer should treat whitespaces.
| |
Highlighting mode | Select the way differences are highlighted. The available options are:
| |
Synchronize Scrolling | Synchronize scrolling in the left and right panes. | |
Settings | Select options that you want to ignore during the comparison.
| |
Help
| Open a browser and show the corresponding help page. |