Exemplo n.º 1
0
        internal static void MigrateTable(
            string generalTableName,
            string sourceTableName,
            bool old,
            IEnumerable <ColumnDefinition> columnDefinitionCollection,
            IEnumerable <IndexInfo> tableIndexCollection)
        {
            Consoles.Write(generalTableName, Consoles.Levels.Info);
            var destinationTableName = Times.Full() + "_" + sourceTableName;

            CreateTable(
                generalTableName,
                sourceTableName,
                old,
                columnDefinitionCollection,
                tableIndexCollection,
                null,
                destinationTableName);
            if (Def.ExistsTable(generalTableName, o => o.Identity &&
                                !sourceTableName.EndsWith("_deleted") &&
                                !sourceTableName.EndsWith("_old")))
            {
                Def.GetSqlIoOfAdmin().ExecuteNonQuery(
                    GetMigrateSql(
                        Def.Code.Sql_MigrateTableWithIdentity,
                        columnDefinitionCollection,
                        sourceTableName,
                        destinationTableName),
                    SqlCmd.Types.PlainSql);
            }
            else
            {
                Def.GetSqlIoOfAdmin().ExecuteNonQuery(
                    GetMigrateSql(
                        Def.Code.Sql_MigrateTable,
                        columnDefinitionCollection,
                        sourceTableName,
                        destinationTableName),
                    SqlCmd.Types.PlainSql);
            }
        }