C# Class Simple.Migrator.Framework.Migration

A migration is a group of transformation applied to the database schema (or sometimes data) to port the database from one version to another. The Up() method must apply the modifications (eg.: create a table) and the Down() method must revert, or rollback the modifications (eg.: delete a table).

Each migration must be decorated with the [Migration(0)] attribute. Each migration number (0) must be unique, or else a DuplicatedVersionException will be trown.

All migrations are executed inside a transaction. If an exception is thrown, the transaction will be rolledback and transformations wont be applied.

It is best to keep a limited number of transformation inside a migration so you can easely move from one version of to another with fine grain modifications. You should give meaningful name to the migration class and prepend the migration number to the filename so they keep ordered, eg.: 002_CreateTableTest.cs.

Use the Database property to apply transformation and the Logger property to output informations in the console (or other). For more details on transformations see ITransformationProvider.

Inheritance: IMigration
ファイルを表示 Open project: juanplopes/simple

Public Methods

Method Description
AfterDown ( ) : void

This is run after the Down transaction has been committed

AfterUp ( ) : void

This is run after the Up transaction has been committed

Down ( ) : void

Defines transformations to revert things done in Up.

InitializeOnce ( string args ) : void

This gets called once on the first migration object.

Up ( ) : void

Defines tranformations to port the database to the current version.

Method Details

AfterDown() public method

This is run after the Down transaction has been committed
public AfterDown ( ) : void
return void

AfterUp() public method

This is run after the Up transaction has been committed
public AfterUp ( ) : void
return void

Down() public abstract method

Defines transformations to revert things done in Up.
public abstract Down ( ) : void
return void

InitializeOnce() public method

This gets called once on the first migration object.
public InitializeOnce ( string args ) : void
args string
return void

Up() public abstract method

Defines tranformations to port the database to the current version.
public abstract Up ( ) : void
return void