コード例 #1
0
        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);
            }
        }
コード例 #2
0
        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));
            }
        }
コード例 #3
0
 public void GenerateDropTable(ITableSource table, ISqlDumper dmp, ISqlDialect dialect)
 {
     dmp.DropTable(table.InvokeLoadStructure(TableStructureMembers.ReferencedFrom), DropFlags.DropReferences | DropFlags.TestIfExist);
 }
コード例 #4
0
 public static void DropTable(this ISqlDumper dmp, ITableStructure table)
 {
     dmp.DropTable(table, DropFlags.None);
 }