Migrate to Postgresql for better network handling. Add more user functionality.

This commit is contained in:
Dan Milne
2025-11-06 14:08:39 +11:00
parent 85252a1a07
commit fc567f0b91
69 changed files with 4266 additions and 952 deletions

View File

@@ -0,0 +1,36 @@
# frozen_string_literal: true
class CreateRules < ActiveRecord::Migration[8.1]
def change
create_table :rules, force: :cascade do |t|
# Rule classification
t.string :rule_type, null: false, index: true
t.string :action, null: false, index: true
t.string :source, limit: 100, default: 'manual', index: true
# Priority for rule evaluation (higher = more specific)
t.integer :priority, index: true
# Rule conditions (JSON for flexibility)
t.json :conditions, default: {}
# Rule metadata (JSON for extensibility)
t.json :metadata, default: {}
# Rule lifecycle
t.boolean :enabled, default: true, null: false, index: true
t.datetime :expires_at, index: true
# Relationships
t.references :user, foreign_key: true
t.references :network_range, foreign_key: true
t.timestamps
# Composite indexes for common queries
t.index [:rule_type, :enabled], name: 'idx_rules_type_enabled'
t.index [:enabled, :expires_at], name: 'idx_rules_active'
t.index [:updated_at, :id], name: 'idx_rules_sync'
end
end
end