private void BuildCreateSchemasNotInTarget(StringBuilder sb)
        {
            var header = false;

            foreach (var schema in sourceSchemas.Where(s => !targetSchemas.Contains(s)))
            {
                if (!header)
                {
                    AddComment(sb, "#region CREATE NON EXISTING SCHEMAS");
                    header = true;
                }
                var content = new SchemaDumpTransformer(schema, SourceLines).BuildLines(ignorePrepend: true);
                sb.AppendLine(content.ToString());
            }
            if (header)
            {
                AddComment(sb, "#endregion CREATE NON EXISTING SCHEMAS");
            }
        }
        public IEnumerable <(string name, string content, PgType type, string schema)> GetDatabaseObjects()
        {
            var args = string.Concat(
                baseArg,
                " --schema-only",
                settings.DbObjectsOwners ? "" : " --no-owner",
                settings.DbObjectsPrivileges ? "" : " --no-acl",
                settings.DbObjectsDropIfExists ? " --clean --if-exists" : "");

            foreach (var table in Connection.GetTables(settings))
            {
                var    name    = table.GetFileName();
                string content = null;
                try
                {
#pragma warning disable CS8509
                    content = table.Type switch
#pragma warning restore CS8509
                    {
                        PgType.Table => GetTableContent(table, args),
                        PgType.View => GetViewContent(table, args)
                    };
                }
                catch (Exception e)
                {
                    Program.WriteLine(ConsoleColor.Red, $"Could not write dump file {name}", $"ERROR: {e.Message}");
                    continue;
                }

                yield return(name, content, table.Type, table.Schema);
            }

            foreach (var seq in Connection.GetSequences(settings))
            {
                var    name = seq.GetFileName();
                string content;
                try
                {
                    content = GetSeqContent(seq, args);
                }
                catch (Exception e)
                {
                    Program.WriteLine(ConsoleColor.Red, $"Could not write dump file {name}", $"ERROR: {e.Message}");
                    continue;
                }
                yield return(name, content, seq.Type, seq.Schema);
            }

            List <string> lines = null;
            List <PgItem> types = new();
            try
            {
                lines = GetDumpLines(args, excludeTables, out types);
            }
            catch (Exception e)
            {
                Program.WriteLine(ConsoleColor.Red, $"Could not create pg_dump for functions and procedures", $"ERROR: {e.Message}");
            }

            if (lines != null)
            {
                foreach (var routine in Connection.GetRoutines(settings))
                {
                    var    name = routine.GetFileName();
                    string content;
                    try
                    {
                        content = new RoutineDumpTransformer(routine, lines)
                                  .BuildLines(dbObjectsCreateOrReplace: settings.DbObjectsCreateOrReplace)
                                  .ToString();
                    }
                    catch (Exception e)
                    {
                        Program.WriteLine(ConsoleColor.Red, $"Could not write dump file {name}", $"ERROR: {e.Message}");
                        continue;
                    }
                    yield return(name, content, routine.Type, routine.Schema);
                }

                foreach (var domain in Connection.GetDomains(settings))
                {
                    var    name = domain.GetFileName();
                    string content;
                    try
                    {
                        content = new DomainDumpTransformer(domain, lines)
                                  .BuildLines()
                                  .ToString();
                    }
                    catch (Exception e)
                    {
                        Program.WriteLine(ConsoleColor.Red, $"Could not write dump file {name}", $"ERROR: {e.Message}");
                        continue;
                    }
                    yield return(name, content, domain.Type, domain.Schema);
                }

                foreach (var type in Connection.FilterTypes(types, settings))
                {
                    var    name = type.GetFileName();
                    string content;
                    try
                    {
                        content = new TypeDumpTransformer(type, lines)
                                  .BuildLines()
                                  .ToString();
                    }
                    catch (Exception e)
                    {
                        Program.WriteLine(ConsoleColor.Red, $"Could not write dump file {name}", $"ERROR: {e.Message}");
                        continue;
                    }
                    yield return(name, content, type.Type, type.Schema);
                }

                foreach (var schema in Connection.GetSchemas(settings))
                {
                    if (string.Equals(schema, "public"))
                    {
                        continue;
                    }
                    var    name = $"{schema}.sql";
                    string content;
                    try
                    {
                        content = new SchemaDumpTransformer(schema, lines)
                                  .BuildLines()
                                  .ToString();
                    }
                    catch (Exception e)
                    {
                        Program.WriteLine(ConsoleColor.Red, $"Could not write dump file {name}", $"ERROR: {e.Message}");
                        continue;
                    }
                    yield return(name, content, PgType.Schema, null);
                }
            }
        }