Sha256: 6e963257723cacd77918e939e1072879626b181849279e88e70a708e105abb40

Contents?: true

Size: 1.04 KB

Versions: 3

Compression:

Stored size: 1.04 KB

Contents

class CreateDeviseOauth2ProvidableSchema < ActiveRecord::Migration
  def change
    create_table :oauth2_clients do |t|
      t.belongs_to :user
      t.string :name
      t.string :redirect_uri
      t.string :website
      t.string :identifier
      t.string :secret
      t.timestamps
    end

    add_index :oauth2_clients, :identifier, unique: true
    add_index :oauth2_clients, :user_id

    token_tables = %W{
      oauth2_access_tokens
      oauth2_refresh_tokens
      oauth2_authorization_codes
    }.map &:to_sym

    token_tables.each do |table_name|
      create_table table_name do |t|
        t.belongs_to :user, :client
        t.belongs_to :refresh_token if table_name == :oauth2_access_tokens
        t.string :token
        t.datetime :expires_at
        t.timestamps  
      end

      add_index table_name, :token, unique: true
      add_index table_name, :expires_at
      add_index table_name, :user_id
      add_index table_name, :client_id

      add_index table_name, :refresh_token_id if table_name == :oauth2_access_tokens
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
anjlab-devise-oauth2-providable-1.1.3 db/migrate/20111014160714_create_devise_oauth2_providable_schema.rb
anjlab-devise-oauth2-providable-1.1.2 db/migrate/20111014160714_create_devise_oauth2_providable_schema.rb
anjlab-devise-oauth2-providable-1.1.1 db/migrate/20111014160714_create_devise_oauth2_providable_schema.rb