private List <string> GetDumpLines(string args, string tableArg, out List <PgItem> types) { List <PgItem> found = new(); var result = GetDumpLines(args, tableArg, lineAction: line => { var entry = line.FirstWordAfter("CREATE TYPE"); if (entry != null) { var type = new PgItem { Type = PgType.Type }; var parts = entry.Split('.'); if (parts.Length < 2) { type.Schema = "public"; type.Name = entry; } else { type.Schema = parts[0]; type.Name = parts[1]; } found.Add(type); } }); types = found; return(result); }
public List <string> GetRawTableDumpLines(PgItem table, bool withPrivileges) { var tableArg = table.GetTableArg(); var args = string.Concat(baseArg, " --schema-only --no-owner", withPrivileges ? "" : " --no-acl"); return(GetDumpLines(args, tableArg)); }
public static string GetFileName(this PgItem item) { if (!string.Equals(item.Schema, "public")) { return($"{item.Schema}.{item.Name}.sql"); } return($"{item.Name}.sql"); }
private string GetSeqContent(PgItem seq, string args) { var tableArg = seq.GetTableArg(); if (settings.DbObjectsRaw) { return(GetPgDumpContent($"{args} {tableArg}")); } return(new SequenceDumpTransformer(seq, GetDumpLines(args, tableArg)).BuildLines().ToString()); }
private string GetViewContent(PgItem table, string args) { var tableArg = table.GetTableArg(); if (settings.DbObjectsRaw) { return(GetPgDumpContent($"{args} {tableArg}")); } return(new ViewDumpTransformer(GetDumpLines(args, tableArg)) .BuildLines(dbObjectsCreateOrReplace: settings.DbObjectsCreateOrReplace) .ToString()); }
public TypeDumpTransformer(PgItem item, List <string> lines) : base(lines) { this.Item = item; }
public static string GetTableArg(this PgItem item) => $"--table=\\\"{item.Schema}\\\".\\\"{item.Name}\\\"";