houdini/db/migrate/20180214124311_create_source_tokens.rb

21 lines
682 B
Ruby
Raw Normal View History

# frozen_string_literal: true
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
2019-11-14 20:47:53 +00:00
class CreateSourceTokens < ActiveRecord::Migration[4.2]
def change
create_table :source_tokens, id: false do |t|
t.column :token, 'uuid', primary_key: true, null: false
t.datetime :expiration
t.references :tokenizable, polymorphic: true
t.references :event
t.integer :max_uses, default: 1
t.integer :total_uses, default: 0
t.timestamps
end
add_index :source_tokens, :token, unique: true
add_index :source_tokens, :expiration
add_index :source_tokens, %i[tokenizable_id tokenizable_type]
end
end