From 26e90717507db369f7159cda6d318a4649d9cbf6 Mon Sep 17 00:00:00 2001 From: Gabe Cook Date: Wed, 14 Jul 2021 16:24:33 -0500 Subject: [PATCH] :wrench: Add support for --table flag --- cmd/dump/dump.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/cmd/dump/dump.go b/cmd/dump/dump.go index 4b654387..1751ca27 100644 --- a/cmd/dump/dump.go +++ b/cmd/dump/dump.go @@ -35,6 +35,7 @@ var ( ifExists bool clean bool noOwner bool + tables []string excludeTable []string excludeTableData []string ) @@ -50,6 +51,7 @@ 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().StringSliceVarP(&tables, "table", "t", []string{}, "dump the specified table(s) only") Command.Flags().StringSliceVarP(&excludeTable, "exclude-table", "T", []string{}, "do NOT dump the specified table(s)") Command.Flags().StringSliceVar(&excludeTableData, "exclude-table-data", []string{}, "do NOT dump data for the specified table(s)") } @@ -178,11 +180,14 @@ func buildCommand() []string { if ifExists { cmd = append(cmd, "--if-exists") } + for _, table := range tables { + cmd = append(cmd, "--table="+table) + } for _, table := range excludeTable { - cmd = append(cmd, "--exclude-table=" + table) + cmd = append(cmd, "--exclude-table="+table) } for _, table := range excludeTableData { - cmd = append(cmd, "--exclude-table-data=" + table) + cmd = append(cmd, "--exclude-table-data="+table) } if outputFormat == sqlformat.Custom { cmd = append(cmd, "--format=c")