class InitialSchema

Public Instance Methods

change() click to toggle source
# 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