|
|
@ -134,6 +134,11 @@ namespace Migrator.Providers
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void RemoveIndex(string table, string name)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
throw new NotImplementedException();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public virtual void AddTable(string table, string engine, string columns)
|
|
|
|
public virtual void AddTable(string table, string engine, string columns)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
table = _dialect.TableNameNeedsQuote ? _dialect.Quote(table) : table;
|
|
|
|
table = _dialect.TableNameNeedsQuote ? _dialect.Quote(table) : table;
|
|
|
@ -409,6 +414,23 @@ namespace Migrator.Providers
|
|
|
|
AddColumn(table, column, type, size, property, null);
|
|
|
|
AddColumn(table, column, type, size, property, null);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void AddIndex(string name, string table, bool unique, params string[] columns)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
try
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
var uniqueText = "";
|
|
|
|
|
|
|
|
if (unique) uniqueText = "UNIQUE";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var command = String.Format("CREATE {0} INDEX {1} ON {2} ({3})", uniqueText, name, table, String.Join(",", columns));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ExecuteNonQuery(command);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
catch (Exception e)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
Logger.Exception("Unable to add index", e);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// <summary>
|
|
|
|
/// Append a primary key to a table.
|
|
|
|
/// Append a primary key to a table.
|
|
|
|
/// </summary>
|
|
|
|
/// </summary>
|
|
|
@ -562,7 +584,8 @@ namespace Migrator.Providers
|
|
|
|
Logger.Warn(ex.Message);
|
|
|
|
Logger.Warn(ex.Message);
|
|
|
|
throw;
|
|
|
|
throw;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private IDbCommand BuildCommand(string sql)
|
|
|
|
private IDbCommand BuildCommand(string sql)
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -595,7 +618,8 @@ namespace Migrator.Providers
|
|
|
|
Logger.Warn("query failed: {0}", cmd.CommandText);
|
|
|
|
Logger.Warn("query failed: {0}", cmd.CommandText);
|
|
|
|
throw;
|
|
|
|
throw;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public object ExecuteScalar(string sql)
|
|
|
|
public object ExecuteScalar(string sql)
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -611,7 +635,8 @@ namespace Migrator.Providers
|
|
|
|
Logger.Warn("Query failed: {0}", cmd.CommandText);
|
|
|
|
Logger.Warn("Query failed: {0}", cmd.CommandText);
|
|
|
|
throw;
|
|
|
|
throw;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public IDataReader Select(string what, string from)
|
|
|
|
public IDataReader Select(string what, string from)
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -658,7 +683,7 @@ namespace Migrator.Providers
|
|
|
|
|
|
|
|
|
|
|
|
public virtual int Delete(string table)
|
|
|
|
public virtual int Delete(string table)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return Delete(table, (string[])null, (string[]) null);
|
|
|
|
return Delete(table, (string[])null, (string[])null);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public virtual int Delete(string table, string[] columns, string[] values)
|
|
|
|
public virtual int Delete(string table, string[] columns, string[] values)
|
|
|
@ -743,12 +768,14 @@ namespace Migrator.Providers
|
|
|
|
{
|
|
|
|
{
|
|
|
|
get
|
|
|
|
get
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if(_appliedMigrations == null)
|
|
|
|
if (_appliedMigrations == null)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
_appliedMigrations = new List<long>();
|
|
|
|
_appliedMigrations = new List<long>();
|
|
|
|
CreateSchemaInfoTable();
|
|
|
|
CreateSchemaInfoTable();
|
|
|
|
using(IDataReader reader = Select("version","SchemaInfo")){
|
|
|
|
using (IDataReader reader = Select("version", "SchemaInfo"))
|
|
|
|
while(reader.Read()){
|
|
|
|
{
|
|
|
|
|
|
|
|
while (reader.Read())
|
|
|
|
|
|
|
|
{
|
|
|
|
_appliedMigrations.Add(Convert.ToInt64(reader.GetValue(0)));
|
|
|
|
_appliedMigrations.Add(Convert.ToInt64(reader.GetValue(0)));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -764,7 +791,7 @@ namespace Migrator.Providers
|
|
|
|
public void MigrationApplied(long version)
|
|
|
|
public void MigrationApplied(long version)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
CreateSchemaInfoTable();
|
|
|
|
CreateSchemaInfoTable();
|
|
|
|
Insert("SchemaInfo",new string[]{"version"},new string[]{version.ToString()});
|
|
|
|
Insert("SchemaInfo", new string[] { "version" }, new string[] { version.ToString() });
|
|
|
|
_appliedMigrations.Add(version);
|
|
|
|
_appliedMigrations.Add(version);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -816,13 +843,14 @@ namespace Migrator.Providers
|
|
|
|
|
|
|
|
|
|
|
|
public virtual string QuoteValues(string values)
|
|
|
|
public virtual string QuoteValues(string values)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return QuoteValues(new string[] {values})[0];
|
|
|
|
return QuoteValues(new string[] { values })[0];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public virtual string[] QuoteValues(string[] values)
|
|
|
|
public virtual string[] QuoteValues(string[] values)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return Array.ConvertAll<string, string>(values,
|
|
|
|
return Array.ConvertAll<string, string>(values,
|
|
|
|
delegate(string val) {
|
|
|
|
delegate(string val)
|
|
|
|
|
|
|
|
{
|
|
|
|
if (null == val)
|
|
|
|
if (null == val)
|
|
|
|
return "null";
|
|
|
|
return "null";
|
|
|
|
else
|
|
|
|
else
|
|
|
|