Class: VagrantAutoDNS::AutoDNSDB::Query

Inherits:
Object
  • Object
show all
Defined in:
lib/vagrant-autodns/autodnsdb.rb

Constant Summary collapse

DELETE_ALL_RECORDS =
'DELETE FROM records'
LIST_ALL_RECORDS =
'SELECT * FROM records'
UPDATE_RECORD =
<<-END_QUERY.gsub(/\s+/, ' ').strip
  INSERT OR REPLACE INTO records (hostname, ip, vagrant_id, modified)
  VALUES (?, ?, ?, ?)
END_QUERY
FIND_RECORD =
'SELECT * FROM records WHERE hostname = ?'
DELETE_RECORD =
'DELETE FROM records WHERE hostname = ?'
DELETE_HOST =
'DELETE FROM records WHERE vagrant_id = ?'
LIST_DEPENDENT_VMS =
<<-END_QUERY.gsub(/\s+/, ' ').strip
  SELECT vagrant_id FROM records
  WHERE vagrant_id IS NOT null
  GROUP BY vagrant_id
END_QUERY
CREATE_RECORDS_TABLE =
<<-DBSETUP.gsub(/\s+/, ' ').strip
  CREATE TABLE IF NOT EXISTS records
  (
    hostname varchar(100) PRIMARY KEY,
    ip varchar(45),
    vagrant_id varchar(100),
    modified timestamp(20)
  )
DBSETUP