using System;
using System.Data;
using System.Collections.Generic;
namespace Migrator.Framework
{
///
/// The main interface to use in Migrations to make changes on a database schema.
///
public interface ITransformationProvider : IDisposable
{
///
/// Get this provider or a NoOp provider if you are not running in the context of 'provider'.
///
ITransformationProvider this[string provider] { get;}
///
/// The list of Migrations currently applied to the database.
///
List AppliedMigrations { get; }
ILogger Logger { get; set; }
///
/// 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
void AddColumn(string table, string column, DbType type, int size, ColumnProperty property, object defaultValue);
///
/// 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
void AddColumn(string table, string column, DbType type);
///
/// 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
void AddColumn(string table, string column, DbType type, int size);
///
/// 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
void AddColumn(string table, string column, DbType type, int size, ColumnProperty property);
///
/// 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
void AddColumn(string table, string column, DbType type, ColumnProperty property);
///
/// 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
void AddColumn(string table, string column, DbType type, object defaultValue);
///
/// 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
void AddColumn(string table, Column column);
///
/// 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)
void AddForeignKey(string name, string foreignTable, string[] foreignColumns, string primaryTable, string[] primaryColumns);
///
/// 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
void AddForeignKey(string name, string foreignTable, string[] foreignColumns, string primaryTable, string[] primaryColumns, ForeignKeyConstraint constraint);
///
/// 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)
void AddForeignKey(string name, string foreignTable, string foreignColumn, string primaryTable, string primaryColumn);
///
/// 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
void AddForeignKey(string name, string foreignTable, string foreignColumn, string primaryTable, string primaryColumn, ForeignKeyConstraint constraint);
///
/// 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)
void GenerateForeignKey(string foreignTable, string foreignColumn, string primaryTable, string primaryColumn);
///
/// 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)
void GenerateForeignKey(string foreignTable, string[] foreignColumns, string primaryTable, string[] primaryColumns);
///
/// 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
void GenerateForeignKey(string foreignTable, string[] foreignColumns, string primaryTable, string[] primaryColumns, ForeignKeyConstraint constraint);
///
/// 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
void GenerateForeignKey(string foreignTable, string foreignColumn, string primaryTable, string primaryColumn,
ForeignKeyConstraint constraint);
///
/// 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)
void GenerateForeignKey(string foreignTable, string primaryTable);
///
/// 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)
///
void GenerateForeignKey(string foreignTable, string primaryTable, ForeignKeyConstraint constraint);
///
/// 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.
void AddPrimaryKey(string name, string table, params string[] columns);
///
/// 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.
void AddUniqueConstraint(string name, string table, params string[] columns);
///
/// 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.
void AddCheckConstraint(string name, string table, string checkSql);
///
/// Add a table
///
/// The name of the table to add.
/// The columns that are part of the table.
void AddTable(string name, params Column[] columns);
///
/// 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.
void AddTable(string name, string engine, params Column[] columns);
///
/// Start a transction
///
void BeginTransaction();
///
/// 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
void ChangeColumn(string table, Column column);
///
/// Check to see if a column exists
///
///
///
///
bool ColumnExists(string table, string column);
///
/// Commit the running transction
///
void Commit();
///
/// Check to see if a constraint exists
///
/// The name of the constraint
/// The table that the constraint lives on.
///
bool ConstraintExists(string table, string name);
///
/// 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.
///
bool PrimaryKeyExists(string table, string name);
///
/// Execute an arbitrary SQL query
///
/// The SQL to execute.
///
int ExecuteNonQuery(string sql);
///
/// Execute an arbitrary SQL query
///
/// The SQL to execute.
///
IDataReader ExecuteQuery(string sql);
///
/// Execute an arbitrary SQL query
///
/// The SQL to execute.
/// A single value that is returned.
object ExecuteScalar(string sql);
///
/// Get the information about the columns in a table
///
/// The table name that you want the columns for.
///
Column[] GetColumns(string table);
///
/// 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.
///
Column GetColumnByName(string table, string column);
///
/// Get the names of all of the tables
///
/// The names of all the tables.
string[] GetTables();
///
/// 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
///
int Insert(string table, string[] columns, string[] values);
///
/// 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
///
int Delete(string table, string[] columns, string[] values);
///
/// 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
///
int Delete(string table, string whereColumn, string whereValue);
///
/// Marks a Migration version number as having been applied
///
/// The version number of the migration that was applied
void MigrationApplied(long version);
///
/// Marks a Migration version number as having been rolled back from the database
///
/// The version number of the migration that was removed
void MigrationUnApplied(long version);
///
/// Remove an existing column from a table
///
/// The name of the table to remove the column from
/// The column to remove
void RemoveColumn(string table, string column);
///
/// Remove an existing foreign key constraint
///
/// The table that contains the foreign key.
/// The name of the foreign key to remove
void RemoveForeignKey(string table, string name);
///
/// Remove an existing constraint
///
/// The table that contains the foreign key.
/// The name of the constraint to remove
void RemoveConstraint(string table, string name);
///
/// Remove an existing table
///
/// The name of the table
void RemoveTable(string tableName);
///
/// Rename an existing table
///
/// The old name of the table
/// The new name of the table
void RenameTable(string oldName, string newName);
///
/// Rename an existing table
///
/// The name of the table
/// The old name of the column
/// The new name of the column
void RenameColumn(string tableName, string oldColumnName, string newColumnName);
///
/// Rollback the currently running transaction.
///
void Rollback();
///
/// Get values from a table
///
/// The columns to select
/// The table to select from
/// The where clause to limit the selection
///
IDataReader Select(string what, string from, string where);
///
/// Get values from a table
///
/// The columns to select
/// The table to select from
///
IDataReader Select(string what, string from);
///
/// Get a single value from a table
///
/// The columns to select
/// The table to select from
///
///
object SelectScalar(string what, string from, string where);
///
/// Get a single value from a table
///
/// The columns to select
/// The table to select from
///
object SelectScalar(string what, string from);
///
/// Check if a table already exists
///
/// The name of the table that you want to check on.
///
bool TableExists(string tableName);
///
/// 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.
///
int Update(string table, string[] columns, string[] columnValues);
///
/// 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
///
int Update(string table, string[] columns, string[] values, string where);
IDbCommand GetCommand();
void ExecuteSchemaBuilder(SchemaBuilder.SchemaBuilder schemaBuilder);
}
}