Sha256: 7bc239ed66a1bcb7d890bdad47e101b9d9a0882108edaf877386e03db1d1b03e

Contents?: true

Size: 1.41 KB

Versions: 80

Compression:

Stored size: 1.41 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 foreign_key_type
          key_type = options[:primary_key_type]
          ", type: :#{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,
            name: database
          )
          config&.migrations_paths
        end
    end
  end
end

Version data entries

80 entries across 76 versions & 8 rubygems

Version Path
trusty-cms-7.0.9.1 vendor/bundle/ruby/3.3.0/gems/activerecord-7.0.8.7/lib/rails/generators/active_record/migration.rb
activerecord-7.0.8.7 lib/rails/generators/active_record/migration.rb
activerecord-7.0.8.6 lib/rails/generators/active_record/migration.rb
activerecord-6.1.7.10 lib/rails/generators/active_record/migration.rb
activerecord-6.1.7.9 lib/rails/generators/active_record/migration.rb
activerecord-7.0.8.5 lib/rails/generators/active_record/migration.rb
blacklight-spotlight-3.6.0.beta8 vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.8.4/lib/rails/generators/active_record/migration.rb
cm-admin-1.5.22 vendor/bundle/ruby/3.3.0/gems/activerecord-7.0.5.1/lib/rails/generators/active_record/migration.rb
cm-admin-1.5.21 vendor/bundle/ruby/3.3.0/gems/activerecord-7.0.5.1/lib/rails/generators/active_record/migration.rb
cm-admin-1.5.20 vendor/bundle/ruby/3.3.0/gems/activerecord-7.0.5.1/lib/rails/generators/active_record/migration.rb
activerecord-7.0.8.4 lib/rails/generators/active_record/migration.rb
activerecord-6.1.7.8 lib/rails/generators/active_record/migration.rb
activerecord-7.0.8.1 lib/rails/generators/active_record/migration.rb
activerecord-6.1.7.7 lib/rails/generators/active_record/migration.rb
scrapbook-0.3.2 vendor/ruby/2.7.0/gems/activerecord-7.0.2.3/lib/rails/generators/active_record/migration.rb
scrapbook-0.3.2 vendor/ruby/2.7.0/gems/activerecord-6.1.6.1/lib/rails/generators/active_record/migration.rb
scrapbook-0.3.2 vendor/ruby/2.7.0/gems/activerecord-7.0.3.1/lib/rails/generators/active_record/migration.rb
activerecord-7.0.8 lib/rails/generators/active_record/migration.rb
activerecord-7.0.7.2 lib/rails/generators/active_record/migration.rb
activerecord-6.1.7.6 lib/rails/generators/active_record/migration.rb