From 4e47770d5282e481b2669d1c580d2e1cae9defb8 Mon Sep 17 00:00:00 2001 From: jonhue Date: Thu, 24 Aug 2017 17:29:48 +0200 Subject: [PATCH 01/15] fix migration file for rails 5 --- lib/generators/doorkeeper/migration_generator.rb | 7 ++----- .../templates/{migration.rb => migration.rb.erb} | 2 +- 2 files changed, 3 insertions(+), 6 deletions(-) rename lib/generators/doorkeeper/templates/{migration.rb => migration.rb.erb} (95%) diff --git a/lib/generators/doorkeeper/migration_generator.rb b/lib/generators/doorkeeper/migration_generator.rb index 53ad21be2..9bff06e02 100644 --- a/lib/generators/doorkeeper/migration_generator.rb +++ b/lib/generators/doorkeeper/migration_generator.rb @@ -6,11 +6,8 @@ class Doorkeeper::MigrationGenerator < ::Rails::Generators::Base desc 'Installs Doorkeeper migration file.' def install - migration_template( - 'migration.rb', - 'db/migrate/create_doorkeeper_tables.rb', - migration_version: migration_version - ) + @migration_version = Rails::VERSION::STRING[0..2].to_f + migration_template 'migration.rb.erb', 'db/migrate/create_doorkeeper_tables.rb' end def self.next_migration_number(dirname) diff --git a/lib/generators/doorkeeper/templates/migration.rb b/lib/generators/doorkeeper/templates/migration.rb.erb similarity index 95% rename from lib/generators/doorkeeper/templates/migration.rb rename to lib/generators/doorkeeper/templates/migration.rb.erb index 5a2bd6a52..6944ce5ab 100644 --- a/lib/generators/doorkeeper/templates/migration.rb +++ b/lib/generators/doorkeeper/templates/migration.rb.erb @@ -1,4 +1,4 @@ -class CreateDoorkeeperTables < ActiveRecord::Migration<%= migration_version %> +class CreateDoorkeeperTables < ActiveRecord::Migration<% if Rails::VERSION::MAJOR >= 5 %>[<%= @migration_version %>]<% end %> def change create_table :oauth_applications do |t| t.string :name, null: false From aa4f22e7cf24ac8ccbcb6745fa6880524983d84a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20H=C3=BCbotter?= Date: Thu, 24 Aug 2017 17:36:17 +0200 Subject: [PATCH 02/15] Update migration_generator.rb --- lib/generators/doorkeeper/migration_generator.rb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/generators/doorkeeper/migration_generator.rb b/lib/generators/doorkeeper/migration_generator.rb index 9bff06e02..23018ac6f 100644 --- a/lib/generators/doorkeeper/migration_generator.rb +++ b/lib/generators/doorkeeper/migration_generator.rb @@ -7,7 +7,10 @@ class Doorkeeper::MigrationGenerator < ::Rails::Generators::Base def install @migration_version = Rails::VERSION::STRING[0..2].to_f - migration_template 'migration.rb.erb', 'db/migrate/create_doorkeeper_tables.rb' + migration_template( + "migration.rb.erb", + "db/migrate/create_doorkeeper_tables.rb" + ) end def self.next_migration_number(dirname) From 7ba04f93c84e674055b650a425415d71ed313ee6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20H=C3=BCbotter?= Date: Thu, 24 Aug 2017 18:15:05 +0200 Subject: [PATCH 03/15] Update migration.rb.erb --- lib/generators/doorkeeper/templates/migration.rb.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/generators/doorkeeper/templates/migration.rb.erb b/lib/generators/doorkeeper/templates/migration.rb.erb index 6944ce5ab..5a2bd6a52 100644 --- a/lib/generators/doorkeeper/templates/migration.rb.erb +++ b/lib/generators/doorkeeper/templates/migration.rb.erb @@ -1,4 +1,4 @@ -class CreateDoorkeeperTables < ActiveRecord::Migration<% if Rails::VERSION::MAJOR >= 5 %>[<%= @migration_version %>]<% end %> +class CreateDoorkeeperTables < ActiveRecord::Migration<%= migration_version %> def change create_table :oauth_applications do |t| t.string :name, null: false From 911b165996ea842695f4d384e88f80e537467db6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20H=C3=BCbotter?= Date: Thu, 24 Aug 2017 18:15:49 +0200 Subject: [PATCH 04/15] Update migration_generator.rb --- lib/generators/doorkeeper/migration_generator.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/generators/doorkeeper/migration_generator.rb b/lib/generators/doorkeeper/migration_generator.rb index 23018ac6f..510ade772 100644 --- a/lib/generators/doorkeeper/migration_generator.rb +++ b/lib/generators/doorkeeper/migration_generator.rb @@ -6,10 +6,10 @@ class Doorkeeper::MigrationGenerator < ::Rails::Generators::Base desc 'Installs Doorkeeper migration file.' def install - @migration_version = Rails::VERSION::STRING[0..2].to_f migration_template( "migration.rb.erb", - "db/migrate/create_doorkeeper_tables.rb" + "db/migrate/create_doorkeeper_tables.rb", + migration_version: migration_version ) end From 45eb63734d488dbc2c1058eb224c24d389595e9a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20H=C3=BCbotter?= Date: Thu, 24 Aug 2017 18:17:19 +0200 Subject: [PATCH 05/15] Update application_owner_generator.rb --- lib/generators/doorkeeper/application_owner_generator.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/generators/doorkeeper/application_owner_generator.rb b/lib/generators/doorkeeper/application_owner_generator.rb index ce6ca58e1..db7371528 100644 --- a/lib/generators/doorkeeper/application_owner_generator.rb +++ b/lib/generators/doorkeeper/application_owner_generator.rb @@ -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', + 'db/migrate/add_owner_to_application.rb', + migration_version: migration_version ) end From 1325e21be32e9f8a96f6282de8aa5921864303f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20H=C3=BCbotter?= Date: Thu, 24 Aug 2017 18:17:47 +0200 Subject: [PATCH 06/15] Update and rename add_owner_to_application_migration.rb to add_owner_to_application_migration.rb.erb --- ...n_migration.rb => add_owner_to_application_migration.rb.erb} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename lib/generators/doorkeeper/templates/{add_owner_to_application_migration.rb => add_owner_to_application_migration.rb.erb} (73%) diff --git a/lib/generators/doorkeeper/templates/add_owner_to_application_migration.rb b/lib/generators/doorkeeper/templates/add_owner_to_application_migration.rb.erb similarity index 73% rename from lib/generators/doorkeeper/templates/add_owner_to_application_migration.rb rename to lib/generators/doorkeeper/templates/add_owner_to_application_migration.rb.erb index 76fcf8993..542a17b02 100644 --- a/lib/generators/doorkeeper/templates/add_owner_to_application_migration.rb +++ b/lib/generators/doorkeeper/templates/add_owner_to_application_migration.rb.erb @@ -1,4 +1,4 @@ -class AddOwnerToApplication < ActiveRecord::Migration +class AddOwnerToApplication < ActiveRecord::Migration<%= migration_version %> def change add_column :oauth_applications, :owner_id, :integer, null: true add_column :oauth_applications, :owner_type, :string, null: true From 9b2e5d5e089688bbdc3f7cf980836237a02f0acc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20H=C3=BCbotter?= Date: Thu, 24 Aug 2017 18:18:09 +0200 Subject: [PATCH 07/15] Update add_previous_refresh_token_to_access_tokens.rb --- .../templates/add_previous_refresh_token_to_access_tokens.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/generators/doorkeeper/templates/add_previous_refresh_token_to_access_tokens.rb b/lib/generators/doorkeeper/templates/add_previous_refresh_token_to_access_tokens.rb index e3f07e352..9dc447512 100644 --- a/lib/generators/doorkeeper/templates/add_previous_refresh_token_to_access_tokens.rb +++ b/lib/generators/doorkeeper/templates/add_previous_refresh_token_to_access_tokens.rb @@ -1,4 +1,4 @@ -class AddPreviousRefreshTokenToAccessTokens < ActiveRecord::Migration +class AddPreviousRefreshTokenToAccessTokens < ActiveRecord::Migration<%= migration_version %> def change add_column( :oauth_access_tokens, From 24768226f19a308651adfc2f597d587c2ca575fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20H=C3=BCbotter?= Date: Thu, 24 Aug 2017 18:19:22 +0200 Subject: [PATCH 08/15] Update previous_refresh_token_generator.rb --- .../doorkeeper/previous_refresh_token_generator.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/generators/doorkeeper/previous_refresh_token_generator.rb b/lib/generators/doorkeeper/previous_refresh_token_generator.rb index 88509e394..5b8ec5710 100644 --- a/lib/generators/doorkeeper/previous_refresh_token_generator.rb +++ b/lib/generators/doorkeeper/previous_refresh_token_generator.rb @@ -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', + 'db/migrate/add_previous_refresh_token_to_access_tokens.rb', + migration_version: migration_version ) end end From 7509e89b4cc348e3fd24142471300445f14ea43b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20H=C3=BCbotter?= Date: Thu, 24 Aug 2017 18:19:40 +0200 Subject: [PATCH 09/15] Rename add_previous_refresh_token_to_access_tokens.rb to add_previous_refresh_token_to_access_tokens.rb.erb --- ...kens.rb => add_previous_refresh_token_to_access_tokens.rb.erb} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename lib/generators/doorkeeper/templates/{add_previous_refresh_token_to_access_tokens.rb => add_previous_refresh_token_to_access_tokens.rb.erb} (100%) diff --git a/lib/generators/doorkeeper/templates/add_previous_refresh_token_to_access_tokens.rb b/lib/generators/doorkeeper/templates/add_previous_refresh_token_to_access_tokens.rb.erb similarity index 100% rename from lib/generators/doorkeeper/templates/add_previous_refresh_token_to_access_tokens.rb rename to lib/generators/doorkeeper/templates/add_previous_refresh_token_to_access_tokens.rb.erb From b0111c7003e43d2fa2fa061042bae2333d2b2b72 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20H=C3=BCbotter?= Date: Thu, 24 Aug 2017 18:20:30 +0200 Subject: [PATCH 10/15] Update application_owner_generator.rb --- lib/generators/doorkeeper/application_owner_generator.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/generators/doorkeeper/application_owner_generator.rb b/lib/generators/doorkeeper/application_owner_generator.rb index db7371528..042680f23 100644 --- a/lib/generators/doorkeeper/application_owner_generator.rb +++ b/lib/generators/doorkeeper/application_owner_generator.rb @@ -7,8 +7,8 @@ class Doorkeeper::ApplicationOwnerGenerator < Rails::Generators::Base def application_owner migration_template( - 'add_owner_to_application_migration.rb.erb', - 'db/migrate/add_owner_to_application.rb', + "add_owner_to_application_migration.rb.erb", + "db/migrate/add_owner_to_application.rb", migration_version: migration_version ) end From 24fbb75725454f6a1ae01920f5a0464148870ee3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20H=C3=BCbotter?= Date: Thu, 24 Aug 2017 18:21:32 +0200 Subject: [PATCH 11/15] Update previous_refresh_token_generator.rb --- lib/generators/doorkeeper/previous_refresh_token_generator.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/generators/doorkeeper/previous_refresh_token_generator.rb b/lib/generators/doorkeeper/previous_refresh_token_generator.rb index 5b8ec5710..5d198c0bc 100644 --- a/lib/generators/doorkeeper/previous_refresh_token_generator.rb +++ b/lib/generators/doorkeeper/previous_refresh_token_generator.rb @@ -12,8 +12,8 @@ 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.erb', - '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", migration_version: migration_version ) end From 38fd4520dd11b59e7b29f18459e9a28810333a95 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20H=C3=BCbotter?= Date: Thu, 24 Aug 2017 20:45:43 +0200 Subject: [PATCH 12/15] Update application_owner_generator.rb --- lib/generators/doorkeeper/application_owner_generator.rb | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/generators/doorkeeper/application_owner_generator.rb b/lib/generators/doorkeeper/application_owner_generator.rb index 042680f23..0db39ea47 100644 --- a/lib/generators/doorkeeper/application_owner_generator.rb +++ b/lib/generators/doorkeeper/application_owner_generator.rb @@ -16,4 +16,10 @@ def application_owner def self.next_migration_number(dirname) ActiveRecord::Generators::Base.next_migration_number(dirname) end + + def migration_version + if Rails.version >= "5.0.0" + "[#{Rails::VERSION::MAJOR}.#{Rails::VERSION::MINOR}]" + end + end end From 0cf2cf493da84e5dabd6eb7f000a86037c6c261c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20H=C3=BCbotter?= Date: Thu, 24 Aug 2017 20:46:02 +0200 Subject: [PATCH 13/15] Update previous_refresh_token_generator.rb --- .../doorkeeper/previous_refresh_token_generator.rb | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/generators/doorkeeper/previous_refresh_token_generator.rb b/lib/generators/doorkeeper/previous_refresh_token_generator.rb index 5d198c0bc..1f650dcc3 100644 --- a/lib/generators/doorkeeper/previous_refresh_token_generator.rb +++ b/lib/generators/doorkeeper/previous_refresh_token_generator.rb @@ -8,6 +8,12 @@ class Doorkeeper::PreviousRefreshTokenGenerator < Rails::Generators::Base def self.next_migration_number(path) ActiveRecord::Generators::Base.next_migration_number(path) end + + def migration_version + if Rails.version >= "5.0.0" + "[#{Rails::VERSION::MAJOR}.#{Rails::VERSION::MINOR}]" + end + end def previous_refresh_token if no_previous_refresh_token_column? From d6bdbe1ab863d8755beac3a41b7ecc9ce6c01103 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20H=C3=BCbotter?= Date: Tue, 17 Oct 2017 16:10:16 +0200 Subject: [PATCH 14/15] Update application_owner_generator.rb --- lib/generators/doorkeeper/application_owner_generator.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/generators/doorkeeper/application_owner_generator.rb b/lib/generators/doorkeeper/application_owner_generator.rb index 0db39ea47..991090770 100644 --- a/lib/generators/doorkeeper/application_owner_generator.rb +++ b/lib/generators/doorkeeper/application_owner_generator.rb @@ -18,7 +18,7 @@ def self.next_migration_number(dirname) end def migration_version - if Rails.version >= "5.0.0" + if Rails.version >= 5 "[#{Rails::VERSION::MAJOR}.#{Rails::VERSION::MINOR}]" end end From bfc00b3087f54aa641b367f21f49b19918b1fa98 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20H=C3=BCbotter?= Date: Tue, 17 Oct 2017 18:39:11 +0200 Subject: [PATCH 15/15] Update application_owner_generator.rb --- lib/generators/doorkeeper/application_owner_generator.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/generators/doorkeeper/application_owner_generator.rb b/lib/generators/doorkeeper/application_owner_generator.rb index 991090770..0db39ea47 100644 --- a/lib/generators/doorkeeper/application_owner_generator.rb +++ b/lib/generators/doorkeeper/application_owner_generator.rb @@ -18,7 +18,7 @@ def self.next_migration_number(dirname) end def migration_version - if Rails.version >= 5 + if Rails.version >= "5.0.0" "[#{Rails::VERSION::MAJOR}.#{Rails::VERSION::MINOR}]" end end