# frozen_string_literal: true

class CreateProjects < ActiveRecord::Migration[8.1]
  def change
    create_table :projects, force: :cascade do |t|
      t.string :name, null: false, index: true
      t.string :slug, null: false, index: { unique: true }
      t.string :public_key, null: false, index: { unique: true }
      t.boolean :enabled, default: true, null: false, index: true

      # WAF settings
      t.integer :rate_limit_threshold, default: 100, null: false
      t.text :settings, default: "{}", null: false
      t.text :custom_rules, default: "{}", null: false

      # Analytics
      t.integer :blocked_ip_count, default: 0, null: false

      t.timestamps
    end
  end
end