Migration Scripts

Vertabelo has added a feature that automatically generates migration scripts. These scripts make it possible to change database structure from one version to another. In this way, you can update your database or go back to a previous schema with much less hassle.

Accessing the Generate Migration Script Screen

Start by opening a model in Vertabelo’s Edit mode. From there, click on the model name on the left and choose Model details:

Model details in Vertabelo

In the Model details screen, click on the GENERATE MIGRATION SQL option on the right:

Generate migration SQL button in Model details window

This takes you to the Generate Migration Script screen, where you can set up the migration script.

The Generate Migration Script Screen

Each migration script requires two different models: the source model and the target model. Vertabelo will generate the code needed to change the database schema from the source model to the target model.

The current model, from whose Model details screen you began this process, is set as the target model by default. You can click the Swap source with target button on the right to make this model the source model.

Regardless of the role (source or target) of this model, you will be asked to provide the name and version (target or source, respectively) of the second model. You can do this by choosing its name from the Model section on the left [1] and then specifying its detailed Version on the right [2]. You can also include any autosaved versions in the list by checking the Show autosaved box on the right:

Show autosaved box

Once you’ve selected the proper source and target models, you can choose some additional options and press GENERATE to get the SQL migration script.

SQL generation settings

After the script has been generated, you will be redirected to the SQL migration result screen.

The SQL Migration Result Screen

SQL migration result screen

In the SQL migration result screen, you can download your script by pressing the Download button [1]. The Warnings list [2] shows you potential code errors. You can click on list items and the problematic pieces of code will be displayed in the Code preview area [3].