forked from doorkeeper-gem/doorkeeper
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
applications.scopes upgrade notice and rake task
- Loading branch information
Showing
9 changed files
with
113 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
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 |
2 changes: 1 addition & 1 deletion
2
...140813024646_add_scopes_to_application.rb → ...lates/add_scopes_to_oauth_applications.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
5 changes: 5 additions & 0 deletions
5
spec/dummy/db/migrate/20141209001746_add_scopes_to_oauth_applications.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
class AddScopesToOauthApplications < ActiveRecord::Migration | ||
def change | ||
add_column :oauth_applications, :scopes, :string, null: false, default: '' | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters