Class: V7Schema
- Inherits:
-
Object
- Object
- V7Schema
- Defined in:
- lib/mihari/database.rb
Overview
Mihari v7 DB schema
Instance Method Summary collapse
Instance Method Details
#change ⇒ Object
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 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 |
# File 'lib/mihari/database.rb', line 10 def change create_table :rules, id: :string, if_not_exists: true do |t| t.string :title, null: false t.string :description, null: false t.json :data, null: false t. end create_table :alerts, if_not_exists: true do |t| t.datetime :created_at t.belongs_to :rule, foreign_key: true, type: :string, null: false end create_table :artifacts, if_not_exists: true do |t| t.string :data, null: false t.string :data_type, null: false t.string :source t.string :query t.json :metadata t.datetime :created_at t.belongs_to :alert, foreign_key: true, null: false end create_table :autonomous_systems, if_not_exists: true do |t| t.integer :asn, null: false t.datetime :created_at t.belongs_to :artifact, foreign_key: true, null: false end create_table :geolocations, if_not_exists: true do |t| t.string :country, null: false t.string :country_code, null: false t.datetime :created_at t.belongs_to :artifact, foreign_key: true, null: false end create_table :whois_records, if_not_exists: true do |t| t.string :domain, null: false t.date :created_on t.date :updated_on t.date :expires_on t.json :registrar t.json :contacts t.datetime :created_at t.belongs_to :artifact, foreign_key: true, null: false end create_table :dns_records, if_not_exists: true do |t| t.string :resource, null: false t.string :value, null: false t.datetime :created_at t.belongs_to :artifact, foreign_key: true, null: false end create_table :reverse_dns_names, if_not_exists: true do |t| t.string :name, null: false t.datetime :created_at t.belongs_to :artifact, foreign_key: true, null: false end create_table :cpes, if_not_exists: true do |t| t.string :cpe, null: false t.datetime :created_at t.belongs_to :artifact, foreign_key: true, null: false end create_table :ports, if_not_exists: true do |t| t.integer :port, null: false t.datetime :created_at t.belongs_to :artifact, foreign_key: true, null: false end create_table :tags, if_not_exists: true do |t| t.string :name, null: false t.datetime :created_at end create_table :taggings, if_not_exists: true do |t| t.integer :tag_id t.string :rule_id t.datetime :created_at end add_index :taggings, :tag_id, if_not_exists: true add_index :taggings, %i[tag_id rule_id], unique: true, if_not_exists: true end |