Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(influx_inspect): multiple retention policies problem in influx_inspect export #23197

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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