Sha256: 0a14249f539e3bf2d650186a0d92fd4fe389fd497bf4a83df6acb6b08b2bb9d6

Contents?: true

Size: 1.29 KB

Versions: 17

Compression:

Stored size: 1.29 KB

Contents

# frozen_string_literal: true

require "rails/generators/migration"

module ActiveRecord
  module Generators # :nodoc:
    module Migration
      extend ActiveSupport::Concern
      include Rails::Generators::Migration

      module ClassMethods
        # Implement the required interface for Rails::Generators::Migration.
        def next_migration_number(dirname)
          next_migration_number = current_migration_number(dirname) + 1
          ActiveRecord::Migration.next_migration_number(next_migration_number)
        end
      end

      private

        def primary_key_type
          key_type = options[:primary_key_type]
          ", id: :#{key_type}" if key_type
        end

        def db_migrate_path
          if defined?(Rails.application) && Rails.application
            configured_migrate_path || default_migrate_path
          else
            "db/migrate"
          end
        end

        def default_migrate_path
          Rails.application.config.paths["db/migrate"].to_ary.first
        end

        def configured_migrate_path
          return unless database = options[:database]
          config = ActiveRecord::Base.configurations.configs_for(
            env_name: Rails.env,
            spec_name: database,
          )
          config&.migrations_paths
        end
    end
  end
end

Version data entries

17 entries across 17 versions & 4 rubygems

Version Path
activerecord-6.0.2.2 lib/rails/generators/active_record/migration.rb
argon-1.3.1 vendor/bundle/ruby/2.7.0/gems/activerecord-6.0.2.1/lib/rails/generators/active_record/migration.rb
symbolic_enum-1.1.5 vendor/bundle/ruby/2.7.0/gems/activerecord-6.0.2.1/lib/rails/generators/active_record/migration.rb
activerecord-6.0.2.1 lib/rails/generators/active_record/migration.rb
activerecord-6.0.2 lib/rails/generators/active_record/migration.rb
activerecord-6.0.2.rc2 lib/rails/generators/active_record/migration.rb
activerecord-6.0.2.rc1 lib/rails/generators/active_record/migration.rb
activerecord-6.0.1 lib/rails/generators/active_record/migration.rb
chatops-rpc-0.0.2 fixtures/chatops-controller-example/vendor/bundle/ruby/2.5.0/gems/activerecord-6.0.0/lib/rails/generators/active_record/migration.rb
activerecord-6.0.1.rc1 lib/rails/generators/active_record/migration.rb
chatops-rpc-0.0.1 fixtures/chatops-controller-example/vendor/bundle/ruby/2.5.0/gems/activerecord-6.0.0/lib/rails/generators/active_record/migration.rb
activerecord-6.0.0 lib/rails/generators/active_record/migration.rb
activerecord-6.0.0.rc2 lib/rails/generators/active_record/migration.rb
activerecord-6.0.0.rc1 lib/rails/generators/active_record/migration.rb
activerecord-6.0.0.beta3 lib/rails/generators/active_record/migration.rb
activerecord-6.0.0.beta2 lib/rails/generators/active_record/migration.rb
activerecord-6.0.0.beta1 lib/rails/generators/active_record/migration.rb