Sha256: 96066e582eb13f5e5ef58f614c9e1650c74134dbbfc52bf00db281fdb212f990

Contents?: true

Size: 1.11 KB

Versions: 29

Compression:

Stored size: 1.11 KB

Contents

# frozen_string_literal: true

require "rails/generators"
require "rails/generators/active_record"

module Doorkeeper
  # Generates migration to add previous refresh token column to the
  # database for Doorkeeper tables.
  #
  class PreviousRefreshTokenGenerator < ::Rails::Generators::Base
    include ::Rails::Generators::Migration
    source_root File.expand_path("templates", __dir__)
    desc "Support revoke refresh token on access token use"

    def self.next_migration_number(path)
      ActiveRecord::Generators::Base.next_migration_number(path)
    end

    def previous_refresh_token
      return unless 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",
      )
    end

    private

    def migration_version
      "[#{ActiveRecord::VERSION::MAJOR}.#{ActiveRecord::VERSION::MINOR}]"
    end

    def no_previous_refresh_token_column?
      !ActiveRecord::Base.connection.column_exists?(
        :oauth_access_tokens,
        :previous_refresh_token,
      )
    end
  end
end

Version data entries

29 entries across 29 versions & 1 rubygems

Version Path
doorkeeper-5.8.0 lib/generators/doorkeeper/previous_refresh_token_generator.rb
doorkeeper-5.7.1 lib/generators/doorkeeper/previous_refresh_token_generator.rb
doorkeeper-5.7.0 lib/generators/doorkeeper/previous_refresh_token_generator.rb
doorkeeper-5.6.9 lib/generators/doorkeeper/previous_refresh_token_generator.rb
doorkeeper-5.6.8 lib/generators/doorkeeper/previous_refresh_token_generator.rb
doorkeeper-5.6.7 lib/generators/doorkeeper/previous_refresh_token_generator.rb
doorkeeper-5.6.6 lib/generators/doorkeeper/previous_refresh_token_generator.rb
doorkeeper-5.6.5 lib/generators/doorkeeper/previous_refresh_token_generator.rb
doorkeeper-5.6.4 lib/generators/doorkeeper/previous_refresh_token_generator.rb
doorkeeper-5.6.3 lib/generators/doorkeeper/previous_refresh_token_generator.rb
doorkeeper-5.6.2 lib/generators/doorkeeper/previous_refresh_token_generator.rb
doorkeeper-5.6.1 lib/generators/doorkeeper/previous_refresh_token_generator.rb
doorkeeper-5.6.0 lib/generators/doorkeeper/previous_refresh_token_generator.rb
doorkeeper-5.6.0.rc2 lib/generators/doorkeeper/previous_refresh_token_generator.rb
doorkeeper-5.6.0.rc1 lib/generators/doorkeeper/previous_refresh_token_generator.rb
doorkeeper-5.5.4 lib/generators/doorkeeper/previous_refresh_token_generator.rb
doorkeeper-5.5.3 lib/generators/doorkeeper/previous_refresh_token_generator.rb
doorkeeper-5.5.2 lib/generators/doorkeeper/previous_refresh_token_generator.rb
doorkeeper-5.5.1 lib/generators/doorkeeper/previous_refresh_token_generator.rb
doorkeeper-5.5.0 lib/generators/doorkeeper/previous_refresh_token_generator.rb