public void GenerateDropAllTables(IDatabaseSource conn, ISqlDumper dmp, ISqlDialect dialect) { DatabaseStructureMembers dbmem = new DatabaseStructureMembers { TableList = true, TableMembers = TableStructureMembers.ForeignKeys, IgnoreSystemObjects = true, }; var dbs = new DatabaseStructure(conn.InvokeLoadStructure(dbmem, null)); IMigrationProfile profile = dialect.CreateMigrationProfile(); dialect.MigrateDatabase(dbs, profile, null); foreach (ITableStructure tbl in dbs.Tables) { if (conn.Dialect.IsSystemTable(tbl.FullName)) { continue; } foreach (IForeignKey fk in tbl.GetConstraints <IForeignKey>()) { dmp.DropConstraint(fk); } } foreach (ITableStructure tbl in dbs.Tables) { if (conn.Dialect.IsSystemTable(tbl.FullName)) { continue; } dmp.DropTable(tbl, DropFlags.None); } }
private void DropTables() { LogMessage("Generating dropping references"); if (_options.TableOptions.DropReferences) { _tables.SelectMany(x => x.GetReferences()).ToList().ForEach(x => _dmp.DropForeignKey(x)); } LogMessage("Generating dropping tables"); if (_options.TableOptions.DropTables) { _tables.ForEach(x => _dmp.DropTable(x, _options.TableOptions.CheckIfTableExists)); } }
public void GenerateDropTable(ITableSource table, ISqlDumper dmp, ISqlDialect dialect) { dmp.DropTable(table.InvokeLoadStructure(TableStructureMembers.ReferencedFrom), DropFlags.DropReferences | DropFlags.TestIfExist); }
public static void DropTable(this ISqlDumper dmp, ITableStructure table) { dmp.DropTable(table, DropFlags.None); }