示例#1
0
        /// <summary>
        /// Drops the types.
        /// </summary>
        internal static void Drop(StreamWriter writer, [NullGuard.AllowNull] PgSchema oldSchema, PgSchema newSchema, SearchPathHelper searchPathHelper)
        {
            if (oldSchema == null)
            {
                return;
            }

            foreach (PgType oldType in oldSchema.Types)
            {
                if (!newSchema.ContainsType(oldType.Signature))
                {
                    List <string> newValues = newSchema.TypeEntriesChanged(oldType);
                    if (newValues != null)
                    {
                        AddDefinition(writer, oldType, newValues, searchPathHelper);
                    }
                    else
                    {
                        var newType = newSchema.GetEnum(oldType.Name);
                        if (newType != null)
                        {
                            // definitions of type changed
                            // to avoid conflicts, dont delete schema and ignore the additional definition
                            writer.WriteLine("-- Type was not dropped because of conflicts");
                        }
                        else
                        {
                            // type was deleted
                            searchPathHelper.OutputSearchPath(writer);
                            writer.WriteLine();
                            writer.WriteLine(oldType.DropSQL);
                        }
                    }
                }
            }
        }