Skip to content
This repository has been archived by the owner on Nov 9, 2017. It is now read-only.

General Usage Guide

jpoehls edited this page Aug 23, 2010 · 2 revisions

General Usage Guide

DotNetMigrations is a command line utility for tracking and migrating database versions. In order to use it’s compiled binaries, please follow the the steps below:

  1. Download the binaries from the Downloads section of this project.
  2. Unzip the files into a directory.
  3. Update the db.exe.config file
    1. Update the appSettings – migrateFolder value if you wish for migration scripts to be saved in a different location.
    2. Update the appSettings – PlugInDirectory value if you wish to store custom plug-ins that extend DotNetMigrations in a different location.
    3. Update the connectionString section with the migration name you wish to use as the key.
    4. Update the dnm.logs section if you are using additional log classes than the default.
  4. Open a command window and navigate to the directory that contains db.exe.
  5. Generate a new Migration Script (see examples below)
  6. Open the created file and write the setup and teardown sql scripts that’ll be used when the database migrates to the version.
  7. Migrate the database.

Command Syntax

db.exe “[connection string]”

  • In the above statement…
    • … represents the name of the command you wish to run.
    • … represents the name of the migration – should be the same name as your connection string key in the configuration file.
    • … represents any additional arguments required by the command (i.e. a specific version number to migrate to).
    • …[connection string] represents an optional argument where you can directly enter the connection string instead of referring to the one found in the configuration file.

Examples:

In the below examples, we’ll assume we have named our migrations as TestDb.

Generating a new Generation Script

db.exe generate TestDb

Migrate to the Latest Script Version

db.exe migrate TestDb

Migrate to the original version

db.exe migrate TestDb 0

Migrate to a specific version

db.exe migrate TestDb 201001291432

Examine what the current version of database and script

db.exe version TestDb

Rollback one database version

db.exe rollback TestDb