Sha256: 2a1dc16b704d7f464f6bcf4a7eb093c70f25a2a43b7514a3696e590181ae7e78

Contents?: true

Size: 1.94 KB

Versions: 10

Compression:

Stored size: 1.94 KB

Contents

require 'devise/schema'

module Devise
  module Oauth2Providable
    module Schema
      def self.up(migration)
        migration.create_table :clients do |t|
          t.string :name
          t.string :redirect_uri
          t.string :website
          t.string :identifier
          t.string :secret
          t.timestamps
        end
        migration.add_index :clients, :identifier, :unique => true

        migration.create_table :access_tokens do |t|
          t.belongs_to :user, :client, :refresh_token
          t.string :token
          t.datetime :expires_at
          t.timestamps
        end
        migration.add_index :access_tokens, :token, :unique => true
        migration.add_index :access_tokens, :expires_at
        migration.add_index :access_tokens, :user_id
        migration.add_index :access_tokens, :client_id

        migration.create_table :refresh_tokens do |t|
          t.belongs_to :user, :client
          t.string :token
          t.datetime :expires_at
          t.timestamps
        end
        migration.add_index :refresh_tokens, :token, :unique => true
        migration.add_index :refresh_tokens, :expires_at
        migration.add_index :refresh_tokens, :user_id
        migration.add_index :refresh_tokens, :client_id

        migration.create_table :authorization_codes do |t|
          t.belongs_to :user, :client
          t.string :token
          t.datetime :expires_at
          t.string :redirect_uri
          t.timestamps
        end
        migration.add_index :authorization_codes, :token, :unique => true
        migration.add_index :authorization_codes, :expires_at
        migration.add_index :authorization_codes, :user_id
        migration.add_index :authorization_codes, :client_id
      end

      def self.down(migration)
        migration.drop_table :refresh_tokens
        migration.drop_table :access_tokens
        migration.drop_table :authorization_codes
        migration.drop_table :clients
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
devise_oauth2_providable-0.3.8 lib/devise_oauth2_providable/schema.rb
devise_oauth2_providable-0.3.7 lib/devise_oauth2_providable/schema.rb
devise_oauth2_providable-0.3.6 lib/devise_oauth2_providable/schema.rb
devise_oauth2_providable-0.3.5 lib/devise_oauth2_providable/schema.rb
devise_oauth2_providable-0.3.4 lib/devise_oauth2_providable/schema.rb
devise_oauth2_providable-0.3.3 lib/devise_oauth2_providable/schema.rb
devise_oauth2_providable-0.3.2 lib/devise_oauth2_providable/schema.rb
devise_oauth2_providable-0.3.1 lib/devise_oauth2_providable/schema.rb
devise_oauth2_providable-0.3.0 lib/devise_oauth2_providable/schema.rb
devise_oauth2_providable-0.2.4 lib/devise_oauth2_providable/schema.rb