Added CreateIndex to Migrator
This commit is contained in:
parent
a1653022ad
commit
76d029361b
|
@ -3,23 +3,23 @@ using System.Data;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace Migrator.Framework
|
namespace Migrator.Framework
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The main interface to use in Migrations to make changes on a database schema.
|
/// The main interface to use in Migrations to make changes on a database schema.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public interface ITransformationProvider : IDisposable
|
public interface ITransformationProvider : IDisposable
|
||||||
{
|
{
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Get this provider or a NoOp provider if you are not running in the context of 'provider'.
|
/// Get this provider or a NoOp provider if you are not running in the context of 'provider'.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
ITransformationProvider this[string provider] { get;}
|
ITransformationProvider this[string provider] { get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The list of Migrations currently applied to the database.
|
/// The list of Migrations currently applied to the database.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
List<long> AppliedMigrations { get; }
|
List<long> AppliedMigrations { get; }
|
||||||
|
|
||||||
ILogger Logger { get; set; }
|
ILogger Logger { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -32,7 +32,7 @@ namespace Migrator.Framework
|
||||||
/// <param name="property">Properties that can be ORed together</param>
|
/// <param name="property">Properties that can be ORed together</param>
|
||||||
/// <param name="defaultValue">The default value of the column if no value is given in a query</param>
|
/// <param name="defaultValue">The default value of the column if no value is given in a query</param>
|
||||||
void AddColumn(string table, string column, DbType type, int size, ColumnProperty property, object defaultValue);
|
void AddColumn(string table, string column, DbType type, int size, ColumnProperty property, object defaultValue);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Add a column to an existing table
|
/// Add a column to an existing table
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -40,7 +40,7 @@ namespace Migrator.Framework
|
||||||
/// <param name="column">The name of the new column</param>
|
/// <param name="column">The name of the new column</param>
|
||||||
/// <param name="type">The data type for the new columnd</param>
|
/// <param name="type">The data type for the new columnd</param>
|
||||||
void AddColumn(string table, string column, DbType type);
|
void AddColumn(string table, string column, DbType type);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Add a column to an existing table
|
/// Add a column to an existing table
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -49,7 +49,7 @@ namespace Migrator.Framework
|
||||||
/// <param name="type">The data type for the new columnd</param>
|
/// <param name="type">The data type for the new columnd</param>
|
||||||
/// <param name="size">The precision or size of the column</param>
|
/// <param name="size">The precision or size of the column</param>
|
||||||
void AddColumn(string table, string column, DbType type, int size);
|
void AddColumn(string table, string column, DbType type, int size);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Add a column to an existing table
|
/// Add a column to an existing table
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -59,7 +59,7 @@ namespace Migrator.Framework
|
||||||
/// <param name="size">The precision or size of the column</param>
|
/// <param name="size">The precision or size of the column</param>
|
||||||
/// <param name="property">Properties that can be ORed together</param>
|
/// <param name="property">Properties that can be ORed together</param>
|
||||||
void AddColumn(string table, string column, DbType type, int size, ColumnProperty property);
|
void AddColumn(string table, string column, DbType type, int size, ColumnProperty property);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Add a column to an existing table
|
/// Add a column to an existing table
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -194,6 +194,15 @@ namespace Migrator.Framework
|
||||||
/// <param name="constraint"></param>
|
/// <param name="constraint"></param>
|
||||||
void GenerateForeignKey(string foreignTable, string primaryTable, ForeignKeyConstraint constraint);
|
void GenerateForeignKey(string foreignTable, string primaryTable, ForeignKeyConstraint constraint);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Add an Index to a table
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="name">The name of the index to add.</param>
|
||||||
|
/// <param name="table">The name of the table that will get the index.</param>
|
||||||
|
/// <param name="unique">If the index will be unique</param>
|
||||||
|
/// <param name="columns">The name of the column or columns that are in the index.</param>
|
||||||
|
void AddIndex(string name, string table, bool unique, params string[] columns);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Add a primary key to a table
|
/// Add a primary key to a table
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -209,7 +218,7 @@ namespace Migrator.Framework
|
||||||
/// <param name="table">The name of the table that will get the constraint</param>
|
/// <param name="table">The name of the table that will get the constraint</param>
|
||||||
/// <param name="columns">The name of the column or columns that will get the constraint.</param>
|
/// <param name="columns">The name of the column or columns that will get the constraint.</param>
|
||||||
void AddUniqueConstraint(string name, string table, params string[] columns);
|
void AddUniqueConstraint(string name, string table, params string[] columns);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Add a constraint to a table
|
/// Add a constraint to a table
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -217,7 +226,7 @@ namespace Migrator.Framework
|
||||||
/// <param name="table">The name of the table that will get the constraint</param>
|
/// <param name="table">The name of the table that will get the constraint</param>
|
||||||
/// <param name="checkSql">The check constraint definition.</param>
|
/// <param name="checkSql">The check constraint definition.</param>
|
||||||
void AddCheckConstraint(string name, string table, string checkSql);
|
void AddCheckConstraint(string name, string table, string checkSql);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Add a table
|
/// Add a table
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -244,7 +253,7 @@ namespace Migrator.Framework
|
||||||
/// <param name="table">The name of the table that will get the new column</param>
|
/// <param name="table">The name of the table that will get the new column</param>
|
||||||
/// <param name="column">An instance of a <see cref="Column">Column</see> with the specified properties and the name of an existing column</param>
|
/// <param name="column">An instance of a <see cref="Column">Column</see> with the specified properties and the name of an existing column</param>
|
||||||
void ChangeColumn(string table, Column column);
|
void ChangeColumn(string table, Column column);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Check to see if a column exists
|
/// Check to see if a column exists
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -257,7 +266,7 @@ namespace Migrator.Framework
|
||||||
/// Commit the running transction
|
/// Commit the running transction
|
||||||
/// </summary>
|
/// </summary>
|
||||||
void Commit();
|
void Commit();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Check to see if a constraint exists
|
/// Check to see if a constraint exists
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -265,7 +274,7 @@ namespace Migrator.Framework
|
||||||
/// <param name="table">The table that the constraint lives on.</param>
|
/// <param name="table">The table that the constraint lives on.</param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
bool ConstraintExists(string table, string name);
|
bool ConstraintExists(string table, string name);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Check to see if a primary key constraint exists on the table
|
/// Check to see if a primary key constraint exists on the table
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -273,7 +282,7 @@ namespace Migrator.Framework
|
||||||
/// <param name="table">The table that the constraint lives on.</param>
|
/// <param name="table">The table that the constraint lives on.</param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
bool PrimaryKeyExists(string table, string name);
|
bool PrimaryKeyExists(string table, string name);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Execute an arbitrary SQL query
|
/// Execute an arbitrary SQL query
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -294,14 +303,14 @@ namespace Migrator.Framework
|
||||||
/// <param name="sql">The SQL to execute.</param>
|
/// <param name="sql">The SQL to execute.</param>
|
||||||
/// <returns>A single value that is returned.</returns>
|
/// <returns>A single value that is returned.</returns>
|
||||||
object ExecuteScalar(string sql);
|
object ExecuteScalar(string sql);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Get the information about the columns in a table
|
/// Get the information about the columns in a table
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="table">The table name that you want the columns for.</param>
|
/// <param name="table">The table name that you want the columns for.</param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Column[] GetColumns(string table);
|
Column[] GetColumns(string table);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Get information about a single column in a table
|
/// Get information about a single column in a table
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -309,13 +318,13 @@ namespace Migrator.Framework
|
||||||
/// <param name="column">The column name for which you want information.</param>
|
/// <param name="column">The column name for which you want information.</param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Column GetColumnByName(string table, string column);
|
Column GetColumnByName(string table, string column);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Get the names of all of the tables
|
/// Get the names of all of the tables
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>The names of all the tables.</returns>
|
/// <returns>The names of all the tables.</returns>
|
||||||
string[] GetTables();
|
string[] GetTables();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Insert data into a table
|
/// Insert data into a table
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -348,13 +357,13 @@ namespace Migrator.Framework
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="version">The version number of the migration that was applied</param>
|
/// <param name="version">The version number of the migration that was applied</param>
|
||||||
void MigrationApplied(long version);
|
void MigrationApplied(long version);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Marks a Migration version number as having been rolled back from the database
|
/// Marks a Migration version number as having been rolled back from the database
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="version">The version number of the migration that was removed</param>
|
/// <param name="version">The version number of the migration that was removed</param>
|
||||||
void MigrationUnApplied(long version);
|
void MigrationUnApplied(long version);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Remove an existing column from a table
|
/// Remove an existing column from a table
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -375,20 +384,27 @@ namespace Migrator.Framework
|
||||||
/// <param name="table">The table that contains the foreign key.</param>
|
/// <param name="table">The table that contains the foreign key.</param>
|
||||||
/// <param name="name">The name of the constraint to remove</param>
|
/// <param name="name">The name of the constraint to remove</param>
|
||||||
void RemoveConstraint(string table, string name);
|
void RemoveConstraint(string table, string name);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Remove an existing index
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="table">The table that contains the index.</param>
|
||||||
|
/// <param name="name">The name of the index to remove</param>
|
||||||
|
void RemoveIndex(string table, string name);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Remove an existing table
|
/// Remove an existing table
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="tableName">The name of the table</param>
|
/// <param name="tableName">The name of the table</param>
|
||||||
void RemoveTable(string tableName);
|
void RemoveTable(string tableName);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Rename an existing table
|
/// Rename an existing table
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="oldName">The old name of the table</param>
|
/// <param name="oldName">The old name of the table</param>
|
||||||
/// <param name="newName">The new name of the table</param>
|
/// <param name="newName">The new name of the table</param>
|
||||||
void RenameTable(string oldName, string newName);
|
void RenameTable(string oldName, string newName);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Rename an existing table
|
/// Rename an existing table
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -396,12 +412,12 @@ namespace Migrator.Framework
|
||||||
/// <param name="oldColumnName">The old name of the column</param>
|
/// <param name="oldColumnName">The old name of the column</param>
|
||||||
/// <param name="newColumnName">The new name of the column</param>
|
/// <param name="newColumnName">The new name of the column</param>
|
||||||
void RenameColumn(string tableName, string oldColumnName, string newColumnName);
|
void RenameColumn(string tableName, string oldColumnName, string newColumnName);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Rollback the currently running transaction.
|
/// Rollback the currently running transaction.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
void Rollback();
|
void Rollback();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Get values from a table
|
/// Get values from a table
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -418,7 +434,7 @@ namespace Migrator.Framework
|
||||||
/// <param name="from">The table to select from</param>
|
/// <param name="from">The table to select from</param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
IDataReader Select(string what, string from);
|
IDataReader Select(string what, string from);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Get a single value from a table
|
/// Get a single value from a table
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -435,14 +451,14 @@ namespace Migrator.Framework
|
||||||
/// <param name="from">The table to select from</param>
|
/// <param name="from">The table to select from</param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
object SelectScalar(string what, string from);
|
object SelectScalar(string what, string from);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Check if a table already exists
|
/// Check if a table already exists
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="tableName">The name of the table that you want to check on.</param>
|
/// <param name="tableName">The name of the table that you want to check on.</param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
bool TableExists(string tableName);
|
bool TableExists(string tableName);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Update the values in a table
|
/// Update the values in a table
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -451,7 +467,7 @@ namespace Migrator.Framework
|
||||||
/// <param name="columnValues">The values for the columns in the same order as the names.</param>
|
/// <param name="columnValues">The values for the columns in the same order as the names.</param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
int Update(string table, string[] columns, string[] columnValues);
|
int Update(string table, string[] columns, string[] columnValues);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Update the values in a table
|
/// Update the values in a table
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -461,7 +477,7 @@ namespace Migrator.Framework
|
||||||
/// <param name="where">A where clause to limit the update</param>
|
/// <param name="where">A where clause to limit the update</param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
int Update(string table, string[] columns, string[] values, string where);
|
int Update(string table, string[] columns, string[] values, string where);
|
||||||
|
|
||||||
IDbCommand GetCommand();
|
IDbCommand GetCommand();
|
||||||
|
|
||||||
void ExecuteSchemaBuilder(SchemaBuilder.SchemaBuilder schemaBuilder);
|
void ExecuteSchemaBuilder(SchemaBuilder.SchemaBuilder schemaBuilder);
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
using System;
|
||||||
using System.Data;
|
using System.Data;
|
||||||
using Migrator.Framework;
|
using Migrator.Framework;
|
||||||
using ForeignKeyConstraint=Migrator.Framework.ForeignKeyConstraint;
|
using ForeignKeyConstraint=Migrator.Framework.ForeignKeyConstraint;
|
||||||
|
@ -53,7 +54,12 @@ namespace Migrator.Providers
|
||||||
{
|
{
|
||||||
// No Op
|
// No Op
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void RemoveIndex(string table, string name)
|
||||||
|
{
|
||||||
|
// No Op
|
||||||
|
}
|
||||||
|
|
||||||
public void AddTable(string name, params Column[] columns)
|
public void AddTable(string name, params Column[] columns)
|
||||||
{
|
{
|
||||||
// No Op
|
// No Op
|
||||||
|
@ -129,6 +135,16 @@ namespace Migrator.Providers
|
||||||
// No Op
|
// No Op
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void AddIndex(string name, string table, params string[] columns)
|
||||||
|
{
|
||||||
|
//No Op
|
||||||
|
}
|
||||||
|
|
||||||
|
public void AddIndex(string name, string table, bool unique, params string[] columns)
|
||||||
|
{
|
||||||
|
//No Op
|
||||||
|
}
|
||||||
|
|
||||||
public void AddPrimaryKey(string name, string table, params string[] columns)
|
public void AddPrimaryKey(string name, string table, params string[] columns)
|
||||||
{
|
{
|
||||||
// No Op
|
// No Op
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue