Migrate to Postgresql for better network handling. Add more user functionality.
This commit is contained in:
117
db/schema.rb
117
db/schema.rb
@@ -10,7 +10,10 @@
|
||||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema[8.1].define(version: 2025_11_03_225251) do
|
||||
ActiveRecord::Schema[8.1].define(version: 7) do
|
||||
# These are extensions that must be enabled in order to support this database
|
||||
enable_extension "pg_catalog.plpgsql"
|
||||
|
||||
create_table "events", force: :cascade do |t|
|
||||
t.string "agent_name"
|
||||
t.string "agent_version"
|
||||
@@ -20,11 +23,11 @@ ActiveRecord::Schema[8.1].define(version: 2025_11_03_225251) do
|
||||
t.datetime "created_at", null: false
|
||||
t.string "environment"
|
||||
t.string "event_id", null: false
|
||||
t.string "ip_address"
|
||||
t.inet "ip_address"
|
||||
t.json "payload"
|
||||
t.integer "project_id", null: false
|
||||
t.integer "request_host_id"
|
||||
t.integer "request_method"
|
||||
t.bigint "project_id", null: false
|
||||
t.bigint "request_host_id"
|
||||
t.integer "request_method", default: 0
|
||||
t.string "request_path"
|
||||
t.string "request_protocol"
|
||||
t.string "request_segment_ids"
|
||||
@@ -35,13 +38,13 @@ ActiveRecord::Schema[8.1].define(version: 2025_11_03_225251) do
|
||||
t.string "server_name"
|
||||
t.datetime "timestamp", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
t.text "user_agent"
|
||||
t.integer "waf_action"
|
||||
t.string "user_agent"
|
||||
t.integer "waf_action", default: 0, null: false
|
||||
t.index ["event_id"], name: "index_events_on_event_id", unique: true
|
||||
t.index ["ip_address"], name: "index_events_on_ip_address"
|
||||
t.index ["project_id", "ip_address"], name: "index_events_on_project_id_and_ip_address"
|
||||
t.index ["project_id", "timestamp"], name: "index_events_on_project_id_and_timestamp"
|
||||
t.index ["project_id", "waf_action"], name: "index_events_on_project_id_and_waf_action"
|
||||
t.index ["project_id", "ip_address"], name: "idx_events_project_ip"
|
||||
t.index ["project_id", "timestamp"], name: "idx_events_project_time"
|
||||
t.index ["project_id", "waf_action"], name: "idx_events_project_action"
|
||||
t.index ["project_id"], name: "index_events_on_project_id"
|
||||
t.index ["request_host_id", "request_method", "request_segment_ids"], name: "idx_events_host_method_path"
|
||||
t.index ["request_host_id"], name: "index_events_on_request_host_id"
|
||||
@@ -50,52 +53,33 @@ ActiveRecord::Schema[8.1].define(version: 2025_11_03_225251) do
|
||||
t.index ["waf_action"], name: "index_events_on_waf_action"
|
||||
end
|
||||
|
||||
create_table "ipv4_ranges", force: :cascade do |t|
|
||||
create_table "network_ranges", force: :cascade do |t|
|
||||
t.text "abuser_scores"
|
||||
t.text "additional_data"
|
||||
t.integer "asn"
|
||||
t.string "asn_org"
|
||||
t.string "company"
|
||||
t.string "country"
|
||||
t.datetime "created_at", null: false
|
||||
t.string "geo2_country"
|
||||
t.string "ip_api_country"
|
||||
t.text "creation_reason"
|
||||
t.boolean "is_datacenter", default: false
|
||||
t.boolean "is_proxy", default: false
|
||||
t.boolean "is_vpn", default: false
|
||||
t.datetime "last_api_fetch"
|
||||
t.integer "network_end", limit: 8, null: false
|
||||
t.integer "network_prefix", null: false
|
||||
t.integer "network_start", limit: 8, null: false
|
||||
t.inet "network", null: false
|
||||
t.string "source", default: "api_imported", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
t.index ["asn"], name: "idx_ipv4_asn"
|
||||
t.index ["company"], name: "idx_ipv4_company"
|
||||
t.index ["ip_api_country"], name: "idx_ipv4_country"
|
||||
t.index ["is_datacenter", "is_proxy", "is_vpn"], name: "idx_ipv4_flags"
|
||||
t.index ["network_start", "network_end", "network_prefix"], name: "idx_ipv4_range_lookup"
|
||||
end
|
||||
|
||||
create_table "ipv6_ranges", force: :cascade do |t|
|
||||
t.text "abuser_scores"
|
||||
t.text "additional_data"
|
||||
t.integer "asn"
|
||||
t.string "asn_org"
|
||||
t.string "company"
|
||||
t.datetime "created_at", null: false
|
||||
t.string "geo2_country"
|
||||
t.string "ip_api_country"
|
||||
t.boolean "is_datacenter", default: false
|
||||
t.boolean "is_proxy", default: false
|
||||
t.boolean "is_vpn", default: false
|
||||
t.datetime "last_api_fetch"
|
||||
t.binary "network_end", limit: 16, null: false
|
||||
t.integer "network_prefix", null: false
|
||||
t.binary "network_start", limit: 16, null: false
|
||||
t.datetime "updated_at", null: false
|
||||
t.index ["asn"], name: "idx_ipv6_asn"
|
||||
t.index ["company"], name: "idx_ipv6_company"
|
||||
t.index ["ip_api_country"], name: "idx_ipv6_country"
|
||||
t.index ["is_datacenter", "is_proxy", "is_vpn"], name: "idx_ipv6_flags"
|
||||
t.index ["network_start", "network_end", "network_prefix"], name: "idx_ipv6_range_lookup"
|
||||
t.bigint "user_id"
|
||||
t.index ["asn"], name: "index_network_ranges_on_asn"
|
||||
t.index ["asn_org"], name: "index_network_ranges_on_asn_org"
|
||||
t.index ["company"], name: "index_network_ranges_on_company"
|
||||
t.index ["country"], name: "index_network_ranges_on_country"
|
||||
t.index ["is_datacenter", "is_proxy", "is_vpn"], name: "idx_network_flags"
|
||||
t.index ["is_datacenter"], name: "index_network_ranges_on_is_datacenter"
|
||||
t.index ["network"], name: "index_network_ranges_on_network", opclass: :inet_ops, using: :gist
|
||||
t.index ["network"], name: "index_network_ranges_on_network_unique", unique: true
|
||||
t.index ["source"], name: "index_network_ranges_on_source"
|
||||
t.index ["user_id"], name: "index_network_ranges_on_user_id"
|
||||
end
|
||||
|
||||
create_table "path_segments", force: :cascade do |t|
|
||||
@@ -154,48 +138,38 @@ ActiveRecord::Schema[8.1].define(version: 2025_11_03_225251) do
|
||||
t.index ["protocol"], name: "index_request_protocols_on_protocol", unique: true
|
||||
end
|
||||
|
||||
create_table "rule_sets", force: :cascade do |t|
|
||||
t.datetime "created_at", null: false
|
||||
t.text "description"
|
||||
t.boolean "enabled"
|
||||
t.string "name"
|
||||
t.integer "priority"
|
||||
t.json "projects"
|
||||
t.json "projects_subscription"
|
||||
t.json "rules"
|
||||
t.string "slug"
|
||||
t.datetime "updated_at", null: false
|
||||
t.index ["enabled"], name: "index_rule_sets_on_enabled"
|
||||
t.index ["priority"], name: "index_rule_sets_on_priority"
|
||||
t.index ["slug"], name: "index_rule_sets_on_slug", unique: true
|
||||
end
|
||||
|
||||
create_table "rules", force: :cascade do |t|
|
||||
t.string "action"
|
||||
t.json "conditions"
|
||||
t.string "action", null: false
|
||||
t.json "conditions", default: {}
|
||||
t.datetime "created_at", null: false
|
||||
t.boolean "enabled"
|
||||
t.boolean "enabled", default: true, null: false
|
||||
t.datetime "expires_at"
|
||||
t.json "metadata"
|
||||
t.json "metadata", default: {}
|
||||
t.bigint "network_range_id"
|
||||
t.integer "priority"
|
||||
t.string "rule_type"
|
||||
t.string "source", limit: 100
|
||||
t.string "target"
|
||||
t.string "rule_type", null: false
|
||||
t.string "source", limit: 100, default: "manual"
|
||||
t.datetime "updated_at", null: false
|
||||
t.bigint "user_id"
|
||||
t.index ["action"], name: "index_rules_on_action"
|
||||
t.index ["enabled", "expires_at"], name: "idx_rules_active"
|
||||
t.index ["enabled"], name: "index_rules_on_enabled"
|
||||
t.index ["expires_at"], name: "index_rules_on_expires_at"
|
||||
t.index ["network_range_id"], name: "index_rules_on_network_range_id"
|
||||
t.index ["priority"], name: "index_rules_on_priority"
|
||||
t.index ["rule_type", "enabled"], name: "idx_rules_type_enabled"
|
||||
t.index ["rule_type"], name: "index_rules_on_rule_type"
|
||||
t.index ["source"], name: "index_rules_on_source"
|
||||
t.index ["updated_at", "id"], name: "idx_rules_sync"
|
||||
t.index ["user_id"], name: "index_rules_on_user_id"
|
||||
end
|
||||
|
||||
create_table "sessions", force: :cascade do |t|
|
||||
t.datetime "created_at", null: false
|
||||
t.string "ip_address"
|
||||
t.inet "ip_address"
|
||||
t.datetime "updated_at", null: false
|
||||
t.string "user_agent"
|
||||
t.integer "user_id", null: false
|
||||
t.bigint "user_id", null: false
|
||||
t.index ["user_id"], name: "index_sessions_on_user_id"
|
||||
end
|
||||
|
||||
@@ -210,5 +184,8 @@ ActiveRecord::Schema[8.1].define(version: 2025_11_03_225251) do
|
||||
|
||||
add_foreign_key "events", "projects"
|
||||
add_foreign_key "events", "request_hosts"
|
||||
add_foreign_key "network_ranges", "users"
|
||||
add_foreign_key "rules", "network_ranges"
|
||||
add_foreign_key "rules", "users"
|
||||
add_foreign_key "sessions", "users"
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user