discourse/db/migrate/20191101113230_add_revoked_at_to_api_key.rb
David Taylor 52c5cf33f8
FEATURE: Overhaul of admin API key system (#8284)
- Allow revoking keys without deleting them
- Auto-revoke keys after a period of no use (default 6 months)
- Allow multiple keys per user
- Allow attaching a description to each key, for easier auditing
- Log changes to keys in the staff action log
- Move all key management to one place, and improve the UI
2019-11-05 14:10:23 +00:00

18 lines
521 B
Ruby

# frozen_string_literal: true
class AddRevokedAtToApiKey < ActiveRecord::Migration[5.2]
def up
add_column :api_keys, :revoked_at, :datetime
add_column :api_keys, :description, :text
execute "INSERT INTO site_settings(name, data_type, value, created_at, updated_at)
VALUES ('api_key_last_used_epoch', 1, now(), now(), now())"
remove_index :api_keys, :user_id # Remove unique index
add_index :api_keys, :user_id
end
def down
raise ActiveRecord::IrreversibleMigration
end
end