Class: CreateTables

Inherits:
ActiveRecord::Migration
  • Object
show all
Defined in:
db/migrate/000_create_tables.rb

Class Method Summary collapse

Class Method Details

.downObject



69
70
71
72
73
74
75
76
77
# File 'db/migrate/000_create_tables.rb', line 69

def self.down
  drop_table :hosts
  drop_table :clients
  drop_table :services
  drop_table :vulns
  drop_table :refs
  drop_table :vulns_refs
  drop_table :notes
end

.upObject



3
4
5
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'db/migrate/000_create_tables.rb', line 3

def self.up
  
  create_table :hosts do |t|
    t.timestamp :created
    t.string    :address, :limit => 16 # unique
    t.string    :address6
    t.string    :mac
    t.string    :comm
    t.string    :name
    t.string    :state
    t.string    :info, :limit => 1024
    t.string    :os_name
    t.string    :os_flavor
    t.string    :os_sp
    t.string    :os_lang
    t.string    :arch
  end
  
  add_index :hosts, :address, :unique => true
  
  create_table :clients do |t|
    t.integer   :host_id
    t.timestamp :created
    t.string    :ua_string, :limit => 1024, :null => false
    t.string    :ua_name, :limit => 64
    t.string    :ua_ver, :limit => 32
  end
  
  create_table :services do |t|
    t.integer   :host_id
    t.timestamp :created
    t.integer   :port, :null => false
    t.string    :proto, :limit => 16, :null => false
    t.string    :state
    t.string    :name
    t.string    :info, :limit => 1024
  end
  
  create_table :vulns do |t|
    t.integer   :host_id
    t.integer   :service_id
    t.timestamp :created
    t.string    :name
    t.text      :data
  end
  
  create_table :refs do |t|
    t.integer   :ref_id
    t.timestamp :created
    t.string    :name, :limit => 512
  end
  
  create_table :vulns_refs, :id => false do |t|
    t.integer   :ref_id
    t.integer   :vuln_id
  end
  
  create_table :notes do |t|
    t.integer   :host_id
    t.timestamp :created
    t.string    :ntype, :limit => 512
    t.text      :data
  end
  
end