C# Класс 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.

Наследование: IMigration
Показать файл Открыть проект

Открытые методы

Метод Описание
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.

Описание методов

AfterDown() публичный Метод

This is run after the Down transaction has been committed
public AfterDown ( ) : void
Результат void

AfterUp() публичный Метод

This is run after the Up transaction has been committed
public AfterUp ( ) : void
Результат void

Down() публичный абстрактный Метод

Defines transformations to revert things done in Up.
public abstract Down ( ) : void
Результат void

InitializeOnce() публичный Метод

This gets called once on the first migration object.
public InitializeOnce ( string args ) : void
args string
Результат void

Up() публичный абстрактный Метод

Defines tranformations to port the database to the current version.
public abstract Up ( ) : void
Результат void