Class: Hotdog::Commands::Init

Inherits:
BaseCommand show all
Defined in:
lib/hotdog/commands/init.rb

Instance Attribute Summary

Attributes inherited from BaseCommand

#application, #formatter, #logger, #options, #tags

Instance Method Summary collapse

Methods inherited from BaseCommand

#execute, #initialize

Constructor Details

This class inherits a constructor from Hotdog::Commands::BaseCommand

Instance Method Details

#run(args = []) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/hotdog/commands/init.rb', line 6

def run(args=[])
  execute("    CREATE TABLE IF NOT EXISTS hosts (\n      id INTEGER PRIMARY KEY AUTOINCREMENT,\n      name VARCHAR(255) NOT NULL\n    );\n  EOS\n  execute(<<-EOS)\n    CREATE UNIQUE INDEX IF NOT EXISTS hosts_name ON hosts ( name );\n  EOS\n  execute(<<-EOS)\n    CREATE TABLE IF NOT EXISTS tags (\n      id INTEGER PRIMARY KEY AUTOINCREMENT,\n      name VARCHAR(200) NOT NULL,\n      value VARCHAR(200) NOT NULL DEFAULT \"\"\n    );\n  EOS\n  execute(<<-EOS)\n    CREATE UNIQUE INDEX IF NOT EXISTS tags_name_value ON tags ( name, value );\n  EOS\n  execute(<<-EOS)\n    CREATE TABLE IF NOT EXISTS hosts_tags (\n      host_id INTEGER NOT NULL,\n      tag_id INTEGER NOT NULL,\n      expires_at INTEGER NOT NULL\n    );\n  EOS\n  execute(<<-EOS)\n    CREATE UNIQUE INDEX IF NOT EXISTS hosts_tags_host_id_tag_id ON hosts_tags ( host_id, tag_id );\n  EOS\n  execute(<<-EOS)\n    CREATE INDEX IF NOT EXISTS hosts_tags_expires_at ON hosts_tags ( expires_at );\n  EOS\nend\n")