Class: InitialSchema

Inherits:
Object
  • Object
show all
Defined in:
lib/mihari/database.rb

Instance Method Summary collapse

Instance Method Details

#changeObject



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
# File 'lib/mihari/database.rb', line 21

def change
  create_table :tags, if_not_exists: true do |t|
    t.string :name, null: false
  end

  create_table :alerts, if_not_exists: true do |t|
    t.string :title, null: false
    t.string :description, null: true
    t.string :source, null: false
    t.timestamps
  end

  create_table :artifacts, if_not_exists: true do |t|
    t.string :data, null: false
    t.string :data_type, null: false
    t.belongs_to :alert, foreign_key: true
    t.timestamps
  end

  create_table :taggings, if_not_exists: true do |t|
    t.integer :tag_id
    t.integer :alert_id
  end

  add_index :taggings, :tag_id, if_not_exists: true
  add_index :taggings, [:tag_id, :alert_id], unique: true, if_not_exists: true
end