Sha256: 443c1bb4650183be434902b872aea8a5c49735884ecb9a24d2c4a4435c297ee4

Contents?: true

Size: 1.43 KB

Versions: 5

Compression:

Stored size: 1.43 KB

Contents

module Doorkeeper
  module Orm
    module ActiveRecord
      def self.initialize_models!
        require 'doorkeeper/orm/active_record/access_grant'
        require 'doorkeeper/orm/active_record/access_token'
        require 'doorkeeper/orm/active_record/application'

        if Doorkeeper.configuration.active_record_options[:establish_connection]
          [Doorkeeper::AccessGrant, Doorkeeper::AccessToken, Doorkeeper::Application].each do |c|
            c.send :establish_connection, Doorkeeper.configuration.active_record_options[:establish_connection]
          end
        end
      end

      def self.initialize_application_owner!
        require 'doorkeeper/models/concerns/ownership'

        Doorkeeper::Application.send :include, Doorkeeper::Models::Ownership
      end

      def self.check_requirements!(_config)
        if ::ActiveRecord::Base.connected? &&
           ::ActiveRecord::Base.connection.table_exists?(
             Doorkeeper::Application.table_name
           )
          unless Doorkeeper::Application.new.attributes.include?("scopes")
            migration_path = '../../../generators/doorkeeper/templates/add_scopes_to_oauth_applications.rb'
            puts <<-MSG.squish
[doorkeeper] Missing column: `oauth_applications.scopes`.
Create the following migration and run `rake db:migrate`.
            MSG
            puts File.read(File.expand_path(migration_path, __FILE__))
          end
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
doorkeeper-4.0.0.rc3 lib/doorkeeper/orm/active_record.rb
doorkeeper-4.0.0.rc2 lib/doorkeeper/orm/active_record.rb
doorkeeper-4.0.0.rc1 lib/doorkeeper/orm/active_record.rb
doorkeeper-3.1.0 lib/doorkeeper/orm/active_record.rb
doorkeeper-2.2.2 lib/doorkeeper/orm/active_record.rb