Skip to content

Commit

Permalink
fix(influx_inspect): multiple retention policies problem in influx_in…
Browse files Browse the repository at this point in the history
…spect export (influxdata/influxdb#23197)
  • Loading branch information
chengshiwen committed Sep 18, 2022
1 parent 5d0dfa0 commit 42cf676
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion cmd/influx_inspect/export/export.go
Original file line number Diff line number Diff line change
Expand Up @@ -201,10 +201,23 @@ func (cmd *Command) walkWALFiles() error {
func (cmd *Command) writeDDL(mw io.Writer, w io.Writer) error {
// Write out all the DDL
fmt.Fprintln(mw, "# DDL")
manifest := make(map[string][]string)
for key := range cmd.manifest {
keys := strings.Split(key, string(os.PathSeparator))
db, rp := influxql.QuoteIdent(keys[0]), influxql.QuoteIdent(keys[1])
fmt.Fprintf(w, "CREATE DATABASE %s WITH NAME %s\n", db, rp)
manifest[db] = append(manifest[db], rp)
}
for db, rps := range manifest {
if len(rps) > 1 {
fmt.Fprintf(w, "CREATE DATABASE %s WITH NAME autogen\n", db)
for _, rp := range rps {
if rp != "autogen" {
fmt.Fprintf(w, "CREATE RETENTION POLICY %s ON %s DURATION 0s REPLICATION 1\n", rp, db)
}
}
} else {
fmt.Fprintf(w, "CREATE DATABASE %s WITH NAME %s\n", db, rps[0])
}
}

return nil
Expand Down

0 comments on commit 42cf676

Please sign in to comment.