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