public static void ExecuteScripts(string providerName, string connectionString, string tableName, IMigrationGenerator migrationGenerator) { var table = CreateTestTable(tableName); var newColumn = CreateNewColumn(); var uniqueConstraint = CreateUniqueConstraint(newColumn); var fk = CreateForeignKey(table); var index = CreateUniqueIndex(newColumn, tableName); var createTable = migrationGenerator.AddTable(table); var addColumn = migrationGenerator.AddColumn(table, newColumn); var addUniqueConstraint = migrationGenerator.AddConstraint(table, uniqueConstraint); var addForeignKey = migrationGenerator.AddConstraint(table, fk); var addUniqueIndex = migrationGenerator.AddIndex(table, index); var dropUniqueIndex = migrationGenerator.DropIndex(table, index); var dropForeignKey = migrationGenerator.DropConstraint(table, fk); var dropUniqueConstraint = migrationGenerator.DropConstraint(table, uniqueConstraint); var dropColumn = migrationGenerator.DropColumn(table, newColumn); var dropTable = migrationGenerator.DropTable(table); var factory = DbProviderFactories.GetFactory(providerName); using (var con = factory.CreateConnection()) { con.ConnectionString = connectionString; using (var cmd = con.CreateCommand()) { con.Open(); using (var tx = con.BeginTransaction()) { cmd.Transaction = tx; Execute(cmd, createTable); Execute(cmd, addColumn); Execute(cmd, addUniqueConstraint); Execute(cmd, addForeignKey); Execute(cmd, dropForeignKey); Execute(cmd, dropUniqueConstraint); //now we've dropped the unique constraint, add a unique index Execute(cmd, addUniqueIndex); Execute(cmd, dropUniqueIndex); Execute(cmd, dropColumn); Execute(cmd, dropTable); } } } }
public void BuildDropTable(DatabaseTable table) { try { var txt = _migrationGenerator.DropTable(table); Clipboard.SetText(txt, TextDataFormat.UnicodeText); } catch (Exception exception) { Debug.WriteLine(exception.Message); } }
public string BuildDropTable(DatabaseTable table) { StringBuilder sb = new StringBuilder(); try { sb.AppendLine(m_migrationGenerator.DropTable(table)); } catch (Exception exception) { Debug.WriteLine(exception.Message); } return(sb.ToString()); }
public string DropTable(DatabaseTable databaseTable) { return(_migration.DropTable(databaseTable)); }