diff --git a/NEWS.md b/NEWS.md index a81e9462b..dd1128e86 100644 --- a/NEWS.md +++ b/NEWS.md @@ -5,6 +5,8 @@ User-visible changes worth mentioning. - [#823] Make configuration and specs ORM independent - [#777] Add support for public client in password grant flow - [#745] Add created_at timestamp to token generation options +- [#838] Drop `Application#scopes` generator and warning, introduced for + upgrading doorkeeper from v2 to v3. --- diff --git a/lib/doorkeeper/config.rb b/lib/doorkeeper/config.rb index f07200bb4..9c797f6e3 100644 --- a/lib/doorkeeper/config.rb +++ b/lib/doorkeeper/config.rb @@ -10,17 +10,12 @@ def self.configure(&block) setup_orm_adapter setup_orm_models setup_application_owner if @config.enable_application_owner? - check_requirements end def self.configuration @config || (fail MissingConfiguration) end - def self.check_requirements - @orm_adapter.check_requirements!(configuration) - end - def self.setup_orm_adapter @orm_adapter = "doorkeeper/orm/#{configuration.orm}".classify.constantize rescue NameError => e diff --git a/lib/doorkeeper/orm/active_record.rb b/lib/doorkeeper/orm/active_record.rb index 328a644a3..6fd973c8e 100644 --- a/lib/doorkeeper/orm/active_record.rb +++ b/lib/doorkeeper/orm/active_record.rb @@ -18,22 +18,6 @@ def self.initialize_application_owner! 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.column_names.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 diff --git a/lib/generators/doorkeeper/application_scopes_generator.rb b/lib/generators/doorkeeper/application_scopes_generator.rb deleted file mode 100644 index 38146ee08..000000000 --- a/lib/generators/doorkeeper/application_scopes_generator.rb +++ /dev/null @@ -1,34 +0,0 @@ -require 'rails/generators/active_record' - -class Doorkeeper::ApplicationScopesGenerator < Rails::Generators::Base - include Rails::Generators::Migration - source_root File.expand_path('../templates', __FILE__) - desc 'Copies ActiveRecord migrations to handle upgrade to doorkeeper 2' - - def self.next_migration_number(path) - ActiveRecord::Generators::Base.next_migration_number(path) - end - - def application_scopes - if oauth_applications_exists? && !scopes_column_exists? - migration_template( - 'add_scopes_to_oauth_applications.rb', - 'db/migrate/add_scopes_to_oauth_applications.rb' - ) - end - end - - private - - def scopes_column_exists? - ActiveRecord::Base.connection.column_exists?( - :oauth_applications, - :scopes - ) - end - - # Might be running this before install - def oauth_applications_exists? - ActiveRecord::Base.connection.table_exists? :oauth_applications - end -end diff --git a/lib/generators/doorkeeper/templates/add_scopes_to_oauth_applications.rb b/lib/generators/doorkeeper/templates/add_scopes_to_oauth_applications.rb deleted file mode 100644 index cd1755175..000000000 --- a/lib/generators/doorkeeper/templates/add_scopes_to_oauth_applications.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddScopesToOauthApplications < ActiveRecord::Migration - def change - add_column :oauth_applications, :scopes, :string, null: false, default: '' - end -end