We're provisioning (in some of our environments) influxdb using Puppet, that means creating databases and users, etc. It would help a lot if we could conditionally create databases, rather than listing, grep'ing, and trying to guess if the database already exists on subsequent Puppet runs to avoid errors such as:
==> e2e: Error: /opt/influxdb/influx -execute "CREATE DATABASE metrics"
returned 1 instead of one of [0]
==> e2e: Error: /Stage[main]/Influxdb/Exec[/opt/influxdb/influx -execute
"CREATE DATABASE metrics"]/returns: change from notrun to 0 failed:
/opt/influxdb/influx -execute "CREATE DATABASE metrics" returned 1 instead of
one of [0]
Support for this was added in 0.9.4 #3892
Syntax is:
CREATE DATABASE IF NOT EXISTS metrics
Thanks Cory, documentation is then out of date, thanks.
On 5 Oct 2015 1:51 pm, "Cory LaNou" [email protected] wrote:
Closed #4323 https://github.com/influxdb/influxdb/issues/4323.
—
Reply to this email directly or view it on GitHub
https://github.com/influxdb/influxdb/issues/4323#event-426688570.
I added a ticket to have the documentation updated as well. Thanks! https://github.com/influxdb/influxdb.com/issues/360
For anyone coming here first, the syntax has changed to-
CREATE DATABASE <dbname> for version > 1.0
Most helpful comment
For anyone coming here first, the syntax has changed to-
CREATE DATABASE <dbname>for version > 1.0