Skip to content

Commit

Permalink
✨ Add support for exclude-table and exclude-table-data
Browse files Browse the repository at this point in the history
  • Loading branch information
gabe565 committed May 27, 2021
1 parent 5f9877c commit 9626f6e
Showing 1 changed file with 18 additions and 8 deletions.
26 changes: 18 additions & 8 deletions cmd/dump/dump.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,16 @@ const (
)

var (
dbname string
username string
password string
directory string
outputFormat uint8
ifExists bool
clean bool
noOwner bool
dbname string
username string
password string
directory string
outputFormat uint8
ifExists bool
clean bool
noOwner bool
excludeTable []string
excludeTableData []string
)

func init() {
Expand All @@ -54,6 +56,8 @@ func init() {
Command.Flags().BoolVar(&ifExists, "if-exists", true, "use IF EXISTS when dropping objects")
Command.Flags().BoolVarP(&clean, "clean", "c", true, "clean (drop) database objects before recreating")
Command.Flags().BoolVarP(&noOwner, "no-owner", "O", true, "skip restoration of object ownership in plain-text format")
Command.Flags().StringArrayVarP(&excludeTable, "exclude-table", "T", []string{}, "do NOT dump the specified table(s)")
Command.Flags().StringArrayVar(&excludeTableData, "exclude-table-data", []string{}, "do NOT dump data for the specified table(s)")
}

func preRun(cmd *cobra.Command, args []string) error {
Expand Down Expand Up @@ -183,6 +187,12 @@ func buildCommand() []string {
if ifExists {
cmd = append(cmd, "--if-exists")
}
for _, table := range excludeTable {
cmd = append(cmd, "--exclude-table=" + table)
}
for _, table := range excludeTableData {
cmd = append(cmd, "--exclude-table-data=" + table)
}
if outputFormat == CustomFormat {
cmd = append(cmd, "--format=c")
} else {
Expand Down

0 comments on commit 9626f6e

Please sign in to comment.