aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/migration
diff options
context:
space:
mode:
authorRafael Mendonça França <rafaelmfranca@gmail.com>2016-12-29 11:57:45 -0500
committerRafael Mendonça França <rafaelmfranca@gmail.com>2016-12-29 17:53:04 -0500
commit249f71a22ab21c03915da5606a063d321f04d4d3 (patch)
tree2a881b813d454ac7c5aaff13bb6de32661607892 /activerecord/lib/active_record/migration
parentbc6c5df4699d3f6b4a61dd12328f9e0f1bd6cf46 (diff)
downloadrails-249f71a22ab21c03915da5606a063d321f04d4d3.tar.gz
rails-249f71a22ab21c03915da5606a063d321f04d4d3.tar.bz2
rails-249f71a22ab21c03915da5606a063d321f04d4d3.zip
Raises when `ActiveRecord::Migration` is inherited directly.
Diffstat (limited to 'activerecord/lib/active_record/migration')
-rw-r--r--activerecord/lib/active_record/migration/compatibility.rb62
1 files changed, 21 insertions, 41 deletions
diff --git a/activerecord/lib/active_record/migration/compatibility.rb b/activerecord/lib/active_record/migration/compatibility.rb
index 9c357e1604..2904634eb7 100644
--- a/activerecord/lib/active_record/migration/compatibility.rb
+++ b/activerecord/lib/active_record/migration/compatibility.rb
@@ -13,7 +13,27 @@ module ActiveRecord
V5_1 = Current
- module FourTwoShared
+ class V5_0 < V5_1
+ def create_table(table_name, options = {})
+ if adapter_name == "PostgreSQL"
+ if options[:id] == :uuid && !options[:default]
+ options[:default] = "uuid_generate_v4()"
+ end
+ end
+
+ # Since 5.1 Postgres adapter uses bigserial type for primary
+ # keys by default and MySQL uses bigint. This compat layer makes old migrations utilize
+ # serial/int type instead -- the way it used to work before 5.1.
+ if options[:id].blank?
+ options[:id] = :integer
+ options[:auto_increment] = true
+ end
+
+ super
+ end
+ end
+
+ class V4_2 < V5_0
module TableDefinition
def references(*, **options)
options[:index] ||= false
@@ -101,46 +121,6 @@ module ActiveRecord
index_name
end
end
-
- class V5_0 < V5_1
- def create_table(table_name, options = {})
- if adapter_name == "PostgreSQL"
- if options[:id] == :uuid && !options[:default]
- options[:default] = "uuid_generate_v4()"
- end
- end
-
- # Since 5.1 Postgres adapter uses bigserial type for primary
- # keys by default and MySQL uses bigint. This compat layer makes old migrations utilize
- # serial/int type instead -- the way it used to work before 5.1.
- if options[:id].blank?
- options[:id] = :integer
- options[:auto_increment] = true
- end
-
- super
- end
- end
-
- class V4_2 < V5_0
- # 4.2 is defined as a module because it needs to be shared with
- # Legacy. When the time comes, V5_0 should be defined straight
- # in its class.
- include FourTwoShared
- end
-
- module Legacy
- include FourTwoShared
-
- def migrate(*)
- ActiveSupport::Deprecation.warn \
- "Directly inheriting from ActiveRecord::Migration is deprecated. " \
- "Please specify the Rails release the migration was written for:\n" \
- "\n" \
- " class #{self.class.name} < ActiveRecord::Migration[4.2]"
- super
- end
- end
end
end
end