ReadyRoll 1

Migration Grouping

Over time, your database project may fill up with a large number of scripts from different releases.

Organizing your migrations into smaller groups makes your project easier to navigate as it scales.

Selecting migration grouping

By default, migrations are grouped by file path. If you wish to change that:

  1. Open the project properties for the project (right click on the project in the solution explorer and select properties)
  2. Select your preferred option in the Migration Grouping section
    Migration Grouping properties section, with three options to pick from

File path

You would want to use file path ordering when you want to group work together based on when its done, but do not want to restrict your folder structure.

Migrations grouped by sprint number with optional sub folders

Here it is easy to visualize how your scripts will be executed as it is the same order as they appear in the solution explorer.

In situations where scripts are likely to be reordered or generated in locations other than the end, using sub-folders can help, as new scripts can easily be added at the end of any folder.

Note that file prefixes need not be unique so scripts can also be inserted into earlier locations within a folder without renaming all scripts which follow.

You cannot have both scripts and folders together. Each folder either just holds other folders or just contains migration scripts.

Execution Order

Scripts will be run in the order you see in the solution explorer

Semantic version folders

The main reason why you may want to use semantic version ordering in your database projects is for release planning. For example, say your organization uses the convention of branching by release. Each release branch is given a unique reference number (e.g. RL123), which can be used to look up the release in a change management/control system.

This value is appended to the version number, which is incremented within the major/minor/patch format.

Note that Semantic versioning ordering is not quite the same as file path ordering. With this ordering scripts in folder 10.0.0 will execute after folder 9.0.0 and scripts in folder 10.0.0-PreRelease will execute before folder 10.0.0.

Migrations grouped by the semantic version in the folder name

Execution Order

Database projects with semver enabled will execute migrations in the following order:

  1. The version number (i.e. the folder name)
  2. The filename prefix (e.g. 001002003 etc)
  3. The filename suffix (e.g. 20131123-1420_ryanp.sql)

File name, ignoring folders

This allows you to group migrations by what they are doing, rather than the order they are going to run.

 sql scripts grouped by concept rather than deployment order

Execution Order

Database projects with semver enabled will execute migrations in the following order:

  1. The filename prefix (e.g. 001002003 etc)
  2. The filename suffix (e.g. 20131123-1420_ryanp.sql)
  3. The full folder path

Didn't find what you were looking for?