evodata/db/migrate/20220124181635_create_api_keys.rb

16 lines
335 B
Ruby
Raw Permalink Normal View History

class CreateApiKeys < ActiveRecord::Migration[7.0]
def up
create_table :api_keys do |t|
t.string :token
t.references :bearer, polymorphic: true, null: false
end
add_index :api_keys, [:bearer_id, :bearer_type]
add_index :api_keys, :token, unique: true
end
def down
drop_table :api_keys
end
end