Migrator.Framework
Describe a migration
Describe the migration
The unique version of the migration.
The version reflected by the migration
Set to true to ignore this migration.
Convert a classname to something more readable.
ex.: CreateATable => Create a table
Log that we have started a migration
Start list of versions
Final Version
Log that we are migrating up
Version we are migrating to
Migration name
Log that we are migrating down
Version we are migrating to
Migration name
Inform that a migration corresponding to the number of
version is untraceable (not found?) and will be ignored.
Version we couldnt find
Log that we are rolling back to version
version
Log a Sql statement that changes the schema or content of the database as part of a migration
SELECT statements should not be logged using this method as they do not alter the data or schema of the
database.
The Sql statement to log
Log that we had an exception on a migration
The version of the migration that caused the exception.
The name of the migration that caused the exception.
The exception itself
Log that we had an exception on a migration
An informative message to show to the user.
The exception itself
Log that we have finished a migration
List of versions with which we started
Final Version
Log a message
The format string ("{0}, blabla {1}").
Parameters to apply to the format string.
Log a Warning
The format string ("{0}, blabla {1}").
Parameters to apply to the format string.
Log a Trace Message
The format string ("{0}, blabla {1}").
Parameters to apply to the format string.
The main interface to use in Migrations to make changes on a database schema.
Add a column to an existing table
The name of the table that will get the new column
The name of the new column
The data type for the new columnd
The precision or size of the column
Properties that can be ORed together
The default value of the column if no value is given in a query
Add a column to an existing table
The name of the table that will get the new column
The name of the new column
The data type for the new columnd
Add a column to an existing table
The name of the table that will get the new column
The name of the new column
The data type for the new columnd
The precision or size of the column
Add a column to an existing table
The name of the table that will get the new column
The name of the new column
The data type for the new columnd
The precision or size of the column
Properties that can be ORed together
Add a column to an existing table
The name of the table that will get the new column
The name of the new column
The data type for the new columnd
Properties that can be ORed together
Add a column to an existing table with the default column size.
The name of the table that will get the new column
The name of the new column
The data type for the new columnd
The default value of the column if no value is given in a query
Add a column to an existing table
The name of the table that will get the new column
An instance of a Column with the specified properties
Add a foreign key constraint
The name of the foreign key. e.g. FK_TABLE_REF
The table that the foreign key will be created in (eg. Table.FK_id)
The columns that are the foreign keys (eg. FK_id)
The table that holds the primary keys (eg. Table.PK_id)
The columns that are the primary keys (eg. PK_id)
Add a foreign key constraint
The name of the foreign key. e.g. FK_TABLE_REF
The table that the foreign key will be created in (eg. Table.FK_id)
The columns that are the foreign keys (eg. FK_id)
The table that holds the primary keys (eg. Table.PK_id)
The columns that are the primary keys (eg. PK_id)
Constraint parameters
Add a foreign key constraint
The name of the foreign key. e.g. FK_TABLE_REF
The table that the foreign key will be created in (eg. Table.FK_id)
The column that is the foreign key (eg. FK_id)
The table that holds the primary keys (eg. Table.PK_id)
The column that is the primary key (eg. PK_id)
Add a foreign key constraint
The name of the foreign key. e.g. FK_TABLE_REF
The table that the foreign key will be created in (eg. Table.FK_id)
The column that is the foreign key (eg. FK_id)
The table that holds the primary key (eg. Table.PK_id)
The column that is the primary key (eg. PK_id)
Constraint parameters
Add a foreign key constraint when you don't care about the name of the constraint.
Warning: This will prevent you from dropping the constraint since you won't know the name.
The table that the foreign key will be created in (eg. Table.FK_id)
The column that is the foreign key (eg. FK_id)
The table that holds the primary key (eg. Table.PK_id)
The column that is the primary key (eg. PK_id)
Add a foreign key constraint when you don't care about the name of the constraint.
Warning: This will prevent you from dropping the constraint since you won't know the name.
The table that the foreign key will be created in (eg. Table.FK_id)
The columns that are the foreign keys (eg. FK_id)
The table that holds the primary key (eg. Table.PK_id)
The column that is the primary key (eg. PK_id)
Add a foreign key constraint when you don't care about the name of the constraint.
Warning: This will prevent you from dropping the constraint since you won't know the name.
The table that the foreign key will be created in (eg. Table.FK_id)
The columns that are the foreign keys (eg. FK_id)
The table that holds the primary key (eg. Table.PK_id)
The columns that are the primary keys (eg. PK_id)
Constraint parameters
Add a foreign key constraint when you don't care about the name of the constraint.
Warning: This will prevent you from dropping the constraint since you won't know the name.
The table that the foreign key will be created in (eg. Table.FK_id)
The columns that are the foreign keys (eg. FK_id)
The table that holds the primary key (eg. Table.PK_id)
The column that is the primary key (eg. PK_id)
Constraint parameters
Add a foreign key constraint when you don't care about the name of the constraint.
Warning: This will prevent you from dropping the constraint since you won't know the name.
The current expectations are that there is a column named the same as the foreignTable present in
the table. This is subject to change because I think it's not a good convention.
The table that the foreign key will be created in (eg. Table.FK_id)
The table that holds the primary key (eg. Table.PK_id)
Add a foreign key constraint when you don't care about the name of the constraint.
Warning: This will prevent you from dropping the constraint since you won't know the name.
The current expectations are that there is a column named the same as the foreignTable present in
the table. This is subject to change because I think it's not a good convention.
The table that the foreign key will be created in (eg. Table.FK_id)
The table that holds the primary key (eg. Table.PK_id)
Add a primary key to a table
The name of the primary key to add.
The name of the table that will get the primary key.
The name of the column or columns that are in the primary key.
Add a constraint to a table
The name of the constraint to add.
The name of the table that will get the constraint
The name of the column or columns that will get the constraint.
Add a constraint to a table
The name of the constraint to add.
The name of the table that will get the constraint
The check constraint definition.
Add a table
The name of the table to add.
The columns that are part of the table.
Add a table
The name of the table to add.
The name of the database engine to use. (MySQL)
The columns that are part of the table.
Start a transction
Change the definition of an existing column.
The name of the table that will get the new column
An instance of a Column with the specified properties and the name of an existing column
Check to see if a column exists
Commit the running transction
Check to see if a constraint exists
The name of the constraint
The table that the constraint lives on.
Check to see if a primary key constraint exists on the table
The name of the primary key
The table that the constraint lives on.
Execute an arbitrary SQL query
The SQL to execute.
Execute an arbitrary SQL query
The SQL to execute.
Execute an arbitrary SQL query
The SQL to execute.
A single value that is returned.
Get the information about the columns in a table
The table name that you want the columns for.
Get information about a single column in a table
The table name that you want the columns for.
The column name for which you want information.
Get the names of all of the tables
The names of all the tables.
Insert data into a table
The table that will get the new data
The names of the columns
The values in the same order as the columns
Delete data from a table
The table that will have the data deleted
The names of the columns used in a where clause
The values in the same order as the columns
Delete data from a table
The table that will have the data deleted
The name of the column used in a where clause
The value for the where clause
Marks a Migration version number as having been applied
The version number of the migration that was applied
Marks a Migration version number as having been rolled back from the database
The version number of the migration that was removed
Remove an existing column from a table
The name of the table to remove the column from
The column to remove
Remove an existing foreign key constraint
The table that contains the foreign key.
The name of the foreign key to remove
Remove an existing constraint
The table that contains the foreign key.
The name of the constraint to remove
Remove an existing table
The name of the table
Rename an existing table
The old name of the table
The new name of the table
Rename an existing table
The name of the table
The old name of the column
The new name of the column
Rollback the currently running transaction.
Get values from a table
The columns to select
The table to select from
The where clause to limit the selection
Get values from a table
The columns to select
The table to select from
Get a single value from a table
The columns to select
The table to select from
Get a single value from a table
The columns to select
The table to select from
Check if a table already exists
The name of the table that you want to check on.
Update the values in a table
The name of the table to update
The names of the columns.
The values for the columns in the same order as the names.
Update the values in a table
The name of the table to update
The names of the columns.
The values for the columns in the same order as the names.
A where clause to limit the update
Get a command instance
Execute a schema builder
Quote a multiple column names, if required
Quaote column if required
Quote table name if required
Encodes a guid value as a string, suitable for inclusion in sql statement
Get this provider or a NoOp provider if you are not running in the context of 'provider'.
The list of Migrations currently applied to the database.
Logger used to log details of operations performed during migration
Return the plural of a word.
The singular form
The plural form of
Return the singular of a word.
The plural form
The singular form of
Capitalizes a word.
The word to be capitalized.
capitalized.
Defines tranformations to port the database to the current version.
This is run after the Up transaction has been committed
Defines transformations to revert things done in Up.
This is run after the Down transaction has been committed
This gets called once on the first migration object.
Represents the database.
.
Migration.Framework.ITransformationProvider
Represents a table column properties.
Null is allowable
Null is not allowable
Identity column, autoinc
Unique Column
Indexed Column
Unsigned Column
Foreign Key
Primary Key
Primary key. Make the column a PrimaryKey and unsigned
ILogger interface.
Implicit in this interface is that the logger will delegate actual
logging to the (s) that have been attached
Attach an
Detach an
Represents a table column.
Base class for migration errors.
Handles writing a message to the log medium (i.e. file, console)
Write this message
Write this message, as a line
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.
The following migration creates a new Customer table.
(File 003_AddCustomerTable.cs)
[Migration(3)]
public class AddCustomerTable : Migration
{
public override void Up()
{
Database.AddTable("Customer",
new Column("Name", typeof(string), 50),
new Column("Address", typeof(string), 100)
);
}
public override void Down()
{
Database.RemoveTable("Customer");
}
}
Defines tranformations to port the database to the current version.
This is run after the Up transaction has been committed
Defines transformations to revert things done in Up.
This is run after the Down transaction has been committed
This gets called once on the first migration object.
Represents the database.
.
Migration.Framework.ITransformationProvider
Adds a Table to be created to the Schema
Table name to be created
SchemaBuilder for chaining
Reference an existing table.
Table to reference
SchemaBuilder for chaining
Reference an existing table.
Table to reference
SchemaBuilder for chaining
Adds a Column to be created
Column name to be added
IColumnOptions to restrict chaining
A set of extension methods for the transformation provider to make it easier to
build many-to-many joining tables (takes care of adding the joining table and foreign
key constraints as necessary.
This functionality was useful when bootstrapping a number of projects a few years ago, but
now that most changes are brown-field I'm thinking of removing these methods as it's easier to maintain
code that creates the tables etc. directly within migration.
Text logger for the migration mediator