class CreateJobEventsTable < ActiveRecord::Migration[7.2]
  def change
    up_only { execute "SET DEFAULT_TABLESPACE = mirai" }

    create_table :domain_user_job_event_add_tracked_objects do |t|
      t.integer :kind, null: false

      t.integer :num_added, null: false
      t.integer :num_total, null: false
      t.interval :duration_since_last_scan

      t.references :user, null: false, foreign_key: { to_table: :domain_users }
      t.references :log_entry, foreign_key: { to_table: :http_log_entries }

      t.jsonb :json_attributes, default: {}
      t.timestamps

      t.index %i[kind user_id]
    end
  end
end
