blob: cbb88d571d1765ac3869896f83d3fd9e54980a04 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
# 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
|