Class: InfluxdbSetup::CreateDb

Inherits:
Command
  • Object
show all
Defined in:
lib/influxdb_setup/create_db.rb

Instance Attribute Summary

Attributes inherited from Command

#config

Instance Method Summary collapse

Methods inherited from Command

#initialize, #log

Constructor Details

This class inherits a constructor from InfluxdbSetup::Command

Instance Method Details

#callObject



3
4
5
6
7
8
9
10
11
12
13
# File 'lib/influxdb_setup/create_db.rb', line 3

def call
  db = @config.db_name
  root = @config.build_client
  databases = root.list_databases.map { |row| row["name"] }

  unless databases.include?(db)
    root.create_database(db)
  else
    log "Influxdb database '#{db}' already exists"
  end
end