-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix migration file for rails 5 #985
Conversation
migration_version: migration_version | ||
) | ||
@migration_version = Rails::VERSION::STRING[0..2].to_f | ||
migration_template 'migration.rb.erb', 'db/migrate/create_doorkeeper_tables.rb' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.
Line is too long. [83/80]
'add_owner_to_application_migration.rb', | ||
'db/migrate/add_owner_to_application.rb' | ||
'add_owner_to_application_migration.rb.erb', | ||
'db/migrate/add_owner_to_application.rb', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.
@@ -7,8 +7,9 @@ class Doorkeeper::ApplicationOwnerGenerator < Rails::Generators::Base | |||
|
|||
def application_owner | |||
migration_template( | |||
'add_owner_to_application_migration.rb', | |||
'db/migrate/add_owner_to_application.rb' | |||
'add_owner_to_application_migration.rb.erb', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.
…to_application_migration.rb.erb
@@ -1,4 +1,4 @@ | |||
class AddPreviousRefreshTokenToAccessTokens < ActiveRecord::Migration | |||
class AddPreviousRefreshTokenToAccessTokens < ActiveRecord::Migration<%= migration_version %> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unterminated string meets end of file
'add_previous_refresh_token_to_access_tokens.rb', | ||
'db/migrate/add_previous_refresh_token_to_access_tokens.rb' | ||
'add_previous_refresh_token_to_access_tokens.rb.erb', | ||
'db/migrate/add_previous_refresh_token_to_access_tokens.rb', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.
@@ -12,8 +12,9 @@ def self.next_migration_number(path) | |||
def previous_refresh_token | |||
if no_previous_refresh_token_column? | |||
migration_template( | |||
'add_previous_refresh_token_to_access_tokens.rb', | |||
'db/migrate/add_previous_refresh_token_to_access_tokens.rb' | |||
'add_previous_refresh_token_to_access_tokens.rb.erb', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.
) | ||
end | ||
|
||
def self.next_migration_number(dirname) | ||
ActiveRecord::Generators::Base.next_migration_number(dirname) | ||
end | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Trailing whitespace detected.
@@ -8,12 +8,19 @@ class Doorkeeper::PreviousRefreshTokenGenerator < Rails::Generators::Base | |||
def self.next_migration_number(path) | |||
ActiveRecord::Generators::Base.next_migration_number(path) | |||
end | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Trailing whitespace detected.
It has not been done for the other migration like adding applications & stuff. |
Hi i've updated the gem to the last version. Thanks! |
This branch works fine. Master does not. |
Hi @maclover7 . I think we can merge it with the master branch. @jonhue one thing that I would change: Rails version check. Why not to compare integers, not strings? I mean why not |
@nbulaj Here you go ... I want to point out though, that the other generators in this repository are sing a string comparison: |
@jonhue take a look at the TravisCI log - there are some errors :) |
@nbulaj Seems like poor little Travis didn't like that change too much :) |
Hi @jonhue . Some comments: 1. Could you please check Rails version as:
As I said before, I don't like the way of string comparison. Let's check integers :) 2. Could you add some specs for this feature (check Rails version in the specs, and if it more than 5, then check if migration template has a version specification) ? You can take a look at some already existing examples After that please rebase your commits and squash them into one, and add an entry to NEWS.md. Thanks for your work and patience! |
Add migration versioning for migration templates if ActiveRecord greater than 5.0. Add specs to ensure valid generator implementation.
Thanks @jonhue for your work! I already fixed this issue with some corrections and specs to prepare a new release of the gem. |
The migration file generated with
rails generate doorkeeper:migration
did not have the appropriate[5.x]
when I was installing it.Rails version: 5.1.3
So here is a fix.