activerecord 5.1.0.beta1 → 5.1.0.rc1

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of activerecord might be problematic. Click here for more details.

Files changed (46) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +93 -6
  3. data/lib/active_record/associations.rb +4 -0
  4. data/lib/active_record/associations/association_scope.rb +8 -8
  5. data/lib/active_record/associations/belongs_to_association.rb +4 -0
  6. data/lib/active_record/associations/builder/belongs_to.rb +8 -1
  7. data/lib/active_record/associations/collection_proxy.rb +5 -4
  8. data/lib/active_record/associations/join_dependency.rb +1 -1
  9. data/lib/active_record/associations/join_dependency/join_association.rb +4 -23
  10. data/lib/active_record/attribute_methods/dirty.rb +3 -3
  11. data/lib/active_record/connection_adapters/abstract/quoting.rb +20 -3
  12. data/lib/active_record/connection_adapters/abstract/schema_definitions.rb +3 -7
  13. data/lib/active_record/connection_adapters/abstract/schema_statements.rb +30 -16
  14. data/lib/active_record/connection_adapters/abstract_adapter.rb +8 -5
  15. data/lib/active_record/connection_adapters/abstract_mysql_adapter.rb +16 -80
  16. data/lib/active_record/connection_adapters/mysql/schema_statements.rb +33 -0
  17. data/lib/active_record/connection_adapters/mysql/type_metadata.rb +2 -0
  18. data/lib/active_record/connection_adapters/postgresql/oid/array.rb +1 -1
  19. data/lib/active_record/connection_adapters/postgresql/schema_statements.rb +56 -96
  20. data/lib/active_record/connection_adapters/postgresql/type_metadata.rb +2 -0
  21. data/lib/active_record/connection_adapters/postgresql_adapter.rb +4 -12
  22. data/lib/active_record/connection_adapters/sqlite3/schema_statements.rb +32 -0
  23. data/lib/active_record/connection_adapters/sqlite3_adapter.rb +4 -51
  24. data/lib/active_record/core.rb +0 -1
  25. data/lib/active_record/gem_version.rb +1 -1
  26. data/lib/active_record/locking/optimistic.rb +2 -6
  27. data/lib/active_record/migration.rb +32 -17
  28. data/lib/active_record/null_relation.rb +1 -1
  29. data/lib/active_record/querying.rb +1 -1
  30. data/lib/active_record/railties/databases.rake +3 -19
  31. data/lib/active_record/reflection.rb +67 -16
  32. data/lib/active_record/relation.rb +0 -4
  33. data/lib/active_record/relation/calculations.rb +7 -10
  34. data/lib/active_record/relation/delegation.rb +2 -2
  35. data/lib/active_record/relation/finder_methods.rb +102 -100
  36. data/lib/active_record/relation/query_methods.rb +6 -1
  37. data/lib/active_record/result.rb +12 -1
  38. data/lib/active_record/sanitization.rb +1 -2
  39. data/lib/active_record/schema_dumper.rb +1 -1
  40. data/lib/active_record/schema_migration.rb +5 -1
  41. data/lib/active_record/tasks/postgresql_database_tasks.rb +20 -0
  42. data/lib/active_record/transactions.rb +1 -1
  43. data/lib/active_record/type/decimal_without_scale.rb +4 -0
  44. data/lib/active_record/type/serialized.rb +2 -0
  45. data/lib/rails/generators/active_record/migration.rb +1 -1
  46. metadata +8 -6
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: bd07c0f82a72c8cbf4c63768b7dbe9616b603c33
4
- data.tar.gz: 4ad0f6c9b287b3a286f9c6663fd95d73592c33bf
3
+ metadata.gz: 56124430c2b0a3ea8b0d63b972a18f7818d5f044
4
+ data.tar.gz: 2b59776ce9564b180d0107fd7acd2155519d3058
5
5
  SHA512:
6
- metadata.gz: 2fa5d70bb93030107254cf60cafa091b242b721517306afb16c4168cee02a989419a75fc84c774ab1ca8aaa01f639daf12d9e4137bcc3edc4fa48a9120fd373b
7
- data.tar.gz: 912c2dfb632f8d0488c9cf3f06cf0b9f5d2a8dee2a0b26416b60c06016112383bf248a5ad1d2bdda082f3a3365ebd944b80e1484761b1d415814aba11e8b6b39
6
+ metadata.gz: 06e06443ed8dc3bfb78b8685ac892b032f065d06712570ba8c318f670f2b489efc2b2c2500fb68eea55d661077a1b626aa6135413b84d1e7ee18909dadbbc3d3
7
+ data.tar.gz: d37ce0bce1c266f7b5c283d203fc3466478a572067b104dd239d528c33cc50929ed8b7bee61365e00eb0e051081741ff014f1ead3983fbe1d26a40321a861d53
@@ -1,3 +1,95 @@
1
+ ## Rails 5.1.0.rc1 (March 20, 2017) ##
2
+
3
+ * Remove comments from structure.sql when using postgresql adapter to avoid
4
+ version-specific parts of the file.
5
+
6
+ Fixes #28153.
7
+
8
+ *Ari Pollak*
9
+
10
+ * Add `:default` option to `belongs_to`.
11
+
12
+ Use it to specify that an association should be initialized with a particular
13
+ record before validation. For example:
14
+
15
+ # Before
16
+ belongs_to :account
17
+ before_validation -> { self.account ||= Current.account }
18
+
19
+ # After
20
+ belongs_to :account, default: -> { Current.account }
21
+
22
+ *George Claghorn*
23
+
24
+ * Deprecate `Migrator.schema_migrations_table_name`.
25
+
26
+ *Ryuta Kamizono*
27
+
28
+ * Fix select with block doesn't return newly built records in has_many association.
29
+
30
+ Fixes #28348.
31
+
32
+ *Ryuta Kamizono*
33
+
34
+ * Check whether `Rails.application` defined before calling it
35
+
36
+ In #27674 we changed the migration generator to generate migrations at the
37
+ path defined in `Rails.application.config.paths` however the code checked
38
+ for the presence of the `Rails` constant but not the `Rails.application`
39
+ method which caused problems when using Active Record and generators outside
40
+ of the context of a Rails application.
41
+
42
+ Fixes #28325.
43
+
44
+ *Andrew White*
45
+
46
+ * Fix `deserialize` with JSON array.
47
+
48
+ Fixes #28285.
49
+
50
+ *Ryuta Kamizono*
51
+
52
+ * Fix `rake db:schema:load` with subdirectories.
53
+
54
+ *Ryuta Kamizono*
55
+
56
+ * Fix `rake db:migrate:status` with subdirectories.
57
+
58
+ *Ryuta Kamizono*
59
+
60
+ * Don't share options between reference id and type columns
61
+
62
+ When using a polymorphic reference column in a migration, sharing options
63
+ between the two columns doesn't make sense since they are different types.
64
+ The `reference_id` column is usually an integer and the `reference_type`
65
+ column a string so options like `unsigned: true` will result in an invalid
66
+ table definition.
67
+
68
+ *Ryuta Kamizono*
69
+
70
+ * Use `max_identifier_length` for `index_name_length` in PostgreSQL adapter.
71
+
72
+ *Ryuta Kamizono*
73
+
74
+ * Deprecate `supports_migrations?` on connection adapters.
75
+
76
+ *Ryuta Kamizono*
77
+
78
+ * Fix regression of #1969 with SELECT aliases in HAVING clause.
79
+
80
+ *Eugene Kenny*
81
+
82
+ * Deprecate using `#quoted_id` in quoting.
83
+
84
+ *Ryuta Kamizono*
85
+
86
+ * Fix `wait_timeout` to configurable for mysql2 adapter.
87
+
88
+ Fixes #26556.
89
+
90
+ *Ryuta Kamizono*
91
+
92
+
1
93
  ## Rails 5.1.0.beta1 (February 23, 2017) ##
2
94
 
3
95
  * Correctly dump native timestamp types for MySQL.
@@ -426,11 +518,6 @@
426
518
 
427
519
  *Prathamesh Sonpatki*
428
520
 
429
- * Optimistic locking: Added ability to update `locking_column` value.
430
- Ignore optimistic locking if trying to update with new `locking_column` value.
431
-
432
- *bogdanvlviv*
433
-
434
521
  * Fixed: Optimistic locking does not work well with `null` in the database.
435
522
 
436
523
  Fixes #26024.
@@ -664,7 +751,7 @@
664
751
 
665
752
  *Johannes Opper*
666
753
 
667
- * Introduce `ActiveRecord::TransactionSerializationError` for catching
754
+ * Introduce new Active Record transaction error classes for catching
668
755
  transaction serialization failures or deadlocks.
669
756
 
670
757
  *Erol Fornoles*
@@ -1647,6 +1647,9 @@ module ActiveRecord
1647
1647
  # +:inverse_of+ to avoid an extra query during validation.
1648
1648
  # NOTE: <tt>required</tt> is set to <tt>true</tt> by default and is deprecated. If
1649
1649
  # you don't want to have association presence validated, use <tt>optional: true</tt>.
1650
+ # [:default]
1651
+ # Provide a callable (i.e. proc or lambda) to specify that the association should
1652
+ # be initialized with a particular record before validation.
1650
1653
  #
1651
1654
  # Option examples:
1652
1655
  # belongs_to :firm, foreign_key: "client_of"
@@ -1660,6 +1663,7 @@ module ActiveRecord
1660
1663
  # belongs_to :comment, touch: true
1661
1664
  # belongs_to :company, touch: :employees_last_updated_at
1662
1665
  # belongs_to :user, optional: true
1666
+ # belongs_to :account, default: -> { company.account }
1663
1667
  def belongs_to(name, scope = nil, options = {})
1664
1668
  reflection = Builder::BelongsTo.build(self, name, scope, options)
1665
1669
  Reflection.add_reflection self, name, reflection
@@ -25,7 +25,7 @@ module ActiveRecord
25
25
  chain_head, chain_tail = get_chain(reflection, association, alias_tracker)
26
26
 
27
27
  scope.extending! Array(reflection.options[:extend])
28
- add_constraints(scope, owner, klass, reflection, chain_head, chain_tail)
28
+ add_constraints(scope, owner, reflection, chain_head, chain_tail)
29
29
  end
30
30
 
31
31
  def join_type
@@ -60,8 +60,8 @@ module ActiveRecord
60
60
  table.create_join(table, table.create_on(constraint), join_type)
61
61
  end
62
62
 
63
- def last_chain_scope(scope, table, reflection, owner, association_klass)
64
- join_keys = reflection.join_keys(association_klass)
63
+ def last_chain_scope(scope, table, reflection, owner)
64
+ join_keys = reflection.join_keys
65
65
  key = join_keys.key
66
66
  foreign_key = join_keys.foreign_key
67
67
 
@@ -80,8 +80,8 @@ module ActiveRecord
80
80
  value_transformation.call(value)
81
81
  end
82
82
 
83
- def next_chain_scope(scope, table, reflection, association_klass, foreign_table, next_reflection)
84
- join_keys = reflection.join_keys(association_klass)
83
+ def next_chain_scope(scope, table, reflection, foreign_table, next_reflection)
84
+ join_keys = reflection.join_keys
85
85
  key = join_keys.key
86
86
  foreign_key = join_keys.foreign_key
87
87
 
@@ -120,10 +120,10 @@ module ActiveRecord
120
120
  [runtime_reflection, previous_reflection]
121
121
  end
122
122
 
123
- def add_constraints(scope, owner, association_klass, refl, chain_head, chain_tail)
123
+ def add_constraints(scope, owner, refl, chain_head, chain_tail)
124
124
  owner_reflection = chain_tail
125
125
  table = owner_reflection.alias_name
126
- scope = last_chain_scope(scope, table, owner_reflection, owner, association_klass)
126
+ scope = last_chain_scope(scope, table, owner_reflection, owner)
127
127
 
128
128
  reflection = chain_head
129
129
  while reflection
@@ -132,7 +132,7 @@ module ActiveRecord
132
132
 
133
133
  unless reflection == chain_tail
134
134
  foreign_table = next_reflection.alias_name
135
- scope = next_chain_scope(scope, table, reflection, association_klass, foreign_table, next_reflection)
135
+ scope = next_chain_scope(scope, table, reflection, foreign_table, next_reflection)
136
136
  end
137
137
 
138
138
  # Exclude the scope of the association itself, because that
@@ -21,6 +21,10 @@ module ActiveRecord
21
21
  self.target = record
22
22
  end
23
23
 
24
+ def default(&block)
25
+ writer(instance_exec(&block)) if reader.nil?
26
+ end
27
+
24
28
  def reset
25
29
  super
26
30
  @updated = false
@@ -5,7 +5,7 @@ module ActiveRecord::Associations::Builder # :nodoc:
5
5
  end
6
6
 
7
7
  def self.valid_options(options)
8
- super + [:polymorphic, :touch, :counter_cache, :optional]
8
+ super + [:polymorphic, :touch, :counter_cache, :optional, :default]
9
9
  end
10
10
 
11
11
  def self.valid_dependent_options
@@ -16,6 +16,7 @@ module ActiveRecord::Associations::Builder # :nodoc:
16
16
  super
17
17
  add_counter_cache_callbacks(model, reflection) if reflection.options[:counter_cache]
18
18
  add_touch_callbacks(model, reflection) if reflection.options[:touch]
19
+ add_default_callbacks(model, reflection) if reflection.options[:default]
19
20
  end
20
21
 
21
22
  def self.define_accessors(mixin, reflection)
@@ -118,6 +119,12 @@ module ActiveRecord::Associations::Builder # :nodoc:
118
119
  model.after_destroy callback.(:changes_to_save)
119
120
  end
120
121
 
122
+ def self.add_default_callbacks(model, reflection)
123
+ model.before_validation lambda { |o|
124
+ o.association(reflection.name).default(&reflection.options[:default])
125
+ }
126
+ end
127
+
121
128
  def self.add_destroy_callbacks(model, reflection)
122
129
  model.after_destroy lambda { |o| o.association(reflection.name).handle_dependency }
123
130
  end
@@ -78,7 +78,7 @@ module ActiveRecord
78
78
  # # #<Pet id: nil, name: "Choo-Choo">
79
79
  # # ]
80
80
  #
81
- # person.pets.select(:id, :name )
81
+ # person.pets.select(:id, :name)
82
82
  # # => [
83
83
  # # #<Pet id: 1, name: "Fancy-Fancy">,
84
84
  # # #<Pet id: 2, name: "Spook">,
@@ -1121,7 +1121,7 @@ module ActiveRecord
1121
1121
  SpawnMethods,
1122
1122
  ].flat_map { |klass|
1123
1123
  klass.public_instance_methods(false)
1124
- } - self.public_instance_methods(false) + [:scoping]
1124
+ } - self.public_instance_methods(false) - [:select] + [:scoping]
1125
1125
 
1126
1126
  delegate(*delegate_methods, to: :scope)
1127
1127
 
@@ -1154,8 +1154,9 @@ module ActiveRecord
1154
1154
  end
1155
1155
 
1156
1156
  def method_missing(method, *args, &block)
1157
- if scope.respond_to?(method)
1158
- scope.public_send(method, *args, &block)
1157
+ if scope.respond_to?(method) && scope.extending_values.any?
1158
+ extend(*scope.extending_values)
1159
+ public_send(method, *args, &block)
1159
1160
  else
1160
1161
  super
1161
1162
  end
@@ -171,7 +171,7 @@ module ActiveRecord
171
171
  chain = child.reflection.chain
172
172
  foreign_table = parent.table
173
173
  foreign_klass = parent.base_klass
174
- child.join_constraints(foreign_table, foreign_klass, child, join_type, tables, chain)
174
+ child.join_constraints(foreign_table, foreign_klass, join_type, tables, chain)
175
175
  end
176
176
 
177
177
  def make_outer_joins(parent, child)
@@ -23,7 +23,7 @@ module ActiveRecord
23
23
 
24
24
  JoinInformation = Struct.new :joins, :binds
25
25
 
26
- def join_constraints(foreign_table, foreign_klass, node, join_type, tables, chain)
26
+ def join_constraints(foreign_table, foreign_klass, join_type, tables, chain)
27
27
  joins = []
28
28
  binds = []
29
29
  tables = tables.reverse
@@ -34,35 +34,16 @@ module ActiveRecord
34
34
  table = tables.shift
35
35
  klass = reflection.klass
36
36
 
37
- join_keys = reflection.join_keys(klass)
37
+ join_keys = reflection.join_keys
38
38
  key = join_keys.key
39
39
  foreign_key = join_keys.foreign_key
40
40
 
41
41
  constraint = build_constraint(klass, table, key, foreign_table, foreign_key)
42
42
 
43
43
  predicate_builder = PredicateBuilder.new(TableMetadata.new(klass, table))
44
- scope_chain_items = reflection.scopes.map do |item|
45
- if item.is_a?(Relation)
46
- item
47
- else
48
- ActiveRecord::Relation.create(klass, table, predicate_builder)
49
- .instance_exec(node, &item)
50
- end
51
- end
44
+ scope_chain_items = reflection.join_scopes(table, predicate_builder)
45
+ klass_scope = reflection.klass_join_scope(table, predicate_builder)
52
46
 
53
- klass_scope =
54
- if klass.current_scope
55
- klass.current_scope.clone.tap { |scope|
56
- scope.joins_values = []
57
- }
58
- else
59
- relation = ActiveRecord::Relation.create(
60
- klass,
61
- table,
62
- predicate_builder,
63
- )
64
- klass.send(:build_default_scope, relation)
65
- end
66
47
  scope_chain_items.concat [klass_scope].compact
67
48
 
68
49
  rel = scope_chain_items.inject(scope_chain_items.shift) do |left, right|
@@ -50,7 +50,7 @@ module ActiveRecord
50
50
  super.tap do
51
51
  @previous_mutation_tracker = nil
52
52
  clear_mutation_trackers
53
- @changed_attributes = HashWithIndifferentAccess.new
53
+ @changed_attributes = ActiveSupport::HashWithIndifferentAccess.new
54
54
  end
55
55
  end
56
56
 
@@ -70,13 +70,13 @@ module ActiveRecord
70
70
 
71
71
  def changes_applied
72
72
  @previous_mutation_tracker = mutation_tracker
73
- @changed_attributes = HashWithIndifferentAccess.new
73
+ @changed_attributes = ActiveSupport::HashWithIndifferentAccess.new
74
74
  clear_mutation_trackers
75
75
  end
76
76
 
77
77
  def clear_changes_information
78
78
  @previous_mutation_tracker = nil
79
- @changed_attributes = HashWithIndifferentAccess.new
79
+ @changed_attributes = ActiveSupport::HashWithIndifferentAccess.new
80
80
  forget_attribute_assignments
81
81
  clear_mutation_trackers
82
82
  end
@@ -7,8 +7,13 @@ module ActiveRecord
7
7
  # Quotes the column value to help prevent
8
8
  # {SQL injection attacks}[http://en.wikipedia.org/wiki/SQL_injection].
9
9
  def quote(value)
10
- # records are quoted as their primary key
11
- return value.quoted_id if value.respond_to?(:quoted_id)
10
+ value = id_value_for_database(value) if value.is_a?(Base)
11
+
12
+ if value.respond_to?(:quoted_id)
13
+ ActiveSupport::Deprecation.warn \
14
+ "Using #quoted_id is deprecated and will be removed in Rails 5.2."
15
+ return value.quoted_id
16
+ end
12
17
 
13
18
  _quote(value)
14
19
  end
@@ -17,6 +22,8 @@ module ActiveRecord
17
22
  # SQLite does not understand dates, so this method will convert a Date
18
23
  # to a String.
19
24
  def type_cast(value, column = nil)
25
+ value = id_value_for_database(value) if value.is_a?(Base)
26
+
20
27
  if value.respond_to?(:quoted_id) && value.respond_to?(:id)
21
28
  return value.id
22
29
  end
@@ -148,7 +155,17 @@ module ActiveRecord
148
155
  private
149
156
 
150
157
  def type_casted_binds(binds)
151
- binds.map { |attr| type_cast(attr.value_for_database) }
158
+ if binds.first.is_a?(Array)
159
+ binds.map { |column, value| type_cast(value, column) }
160
+ else
161
+ binds.map { |attr| type_cast(attr.value_for_database) }
162
+ end
163
+ end
164
+
165
+ def id_value_for_database(value)
166
+ if primary_key = value.class.primary_key
167
+ value.instance_variable_get(:@attributes)[primary_key].value_for_database
168
+ end
152
169
  end
153
170
 
154
171
  def types_which_need_no_typecasting
@@ -116,16 +116,12 @@ module ActiveRecord
116
116
 
117
117
  private
118
118
 
119
- def as_options(value, default = {})
120
- if value.is_a?(Hash)
121
- value
122
- else
123
- default
124
- end
119
+ def as_options(value)
120
+ value.is_a?(Hash) ? value : {}
125
121
  end
126
122
 
127
123
  def polymorphic_options
128
- as_options(polymorphic, options)
124
+ as_options(polymorphic)
129
125
  end
130
126
 
131
127
  def index_options
@@ -31,6 +31,8 @@ module ActiveRecord
31
31
  # Returns the relation names useable to back Active Record models.
32
32
  # For most adapters this means all #tables and #views.
33
33
  def data_sources
34
+ select_values(data_source_sql, "SCHEMA")
35
+ rescue NotImplementedError
34
36
  tables | views
35
37
  end
36
38
 
@@ -39,12 +41,14 @@ module ActiveRecord
39
41
  # data_source_exists?(:ebooks)
40
42
  #
41
43
  def data_source_exists?(name)
44
+ select_values(data_source_sql(name), "SCHEMA").any? if name.present?
45
+ rescue NotImplementedError
42
46
  data_sources.include?(name.to_s)
43
47
  end
44
48
 
45
49
  # Returns an array of table names defined in the database.
46
50
  def tables
47
- raise NotImplementedError, "#tables is not implemented"
51
+ select_values(data_source_sql(type: "BASE TABLE"), "SCHEMA")
48
52
  end
49
53
 
50
54
  # Checks to see if the table +table_name+ exists on the database.
@@ -52,12 +56,14 @@ module ActiveRecord
52
56
  # table_exists?(:developers)
53
57
  #
54
58
  def table_exists?(table_name)
59
+ select_values(data_source_sql(table_name, type: "BASE TABLE"), "SCHEMA").any? if table_name.present?
60
+ rescue NotImplementedError
55
61
  tables.include?(table_name.to_s)
56
62
  end
57
63
 
58
64
  # Returns an array of view names defined in the database.
59
65
  def views
60
- raise NotImplementedError, "#views is not implemented"
66
+ select_values(data_source_sql(type: "VIEW"), "SCHEMA")
61
67
  end
62
68
 
63
69
  # Checks to see if the view +view_name+ exists on the database.
@@ -65,6 +71,8 @@ module ActiveRecord
65
71
  # view_exists?(:ebooks)
66
72
  #
67
73
  def view_exists?(view_name)
74
+ select_values(data_source_sql(view_name, type: "VIEW"), "SCHEMA").any? if view_name.present?
75
+ rescue NotImplementedError
68
76
  views.include?(view_name.to_s)
69
77
  end
70
78
 
@@ -334,18 +342,16 @@ module ActiveRecord
334
342
  # part_id int NOT NULL,
335
343
  # ) ENGINE=InnoDB DEFAULT CHARSET=utf8
336
344
  #
337
- def create_join_table(table_1, table_2, options = {})
345
+ def create_join_table(table_1, table_2, column_options: {}, **options)
338
346
  join_table_name = find_join_table_name(table_1, table_2, options)
339
347
 
340
- column_options = options.delete(:column_options) || {}
341
- column_options.reverse_merge!(null: false)
342
- type = column_options.delete(:type) || :integer
348
+ column_options.reverse_merge!(null: false, index: false)
343
349
 
344
- t1_column, t2_column = [table_1, table_2].map { |t| t.to_s.singularize.foreign_key }
350
+ t1_ref, t2_ref = [table_1, table_2].map { |t| t.to_s.singularize }
345
351
 
346
352
  create_table(join_table_name, options.merge!(id: false)) do |td|
347
- td.send type, t1_column, column_options
348
- td.send type, t2_column, column_options
353
+ td.references t1_ref, column_options
354
+ td.references t2_ref, column_options
349
355
  yield td if block_given?
350
356
  end
351
357
  end
@@ -857,6 +863,7 @@ module ActiveRecord
857
863
  else
858
864
  foreign_key_options = { to_table: reference_name }
859
865
  end
866
+ foreign_key_options[:column] ||= "#{ref_name}_id"
860
867
  remove_foreign_key(table_name, **foreign_key_options)
861
868
  end
862
869
 
@@ -992,12 +999,12 @@ module ActiveRecord
992
999
  end
993
1000
 
994
1001
  def dump_schema_information #:nodoc:
995
- versions = ActiveRecord::SchemaMigration.order("version").pluck(:version)
1002
+ versions = ActiveRecord::SchemaMigration.all_versions
996
1003
  insert_versions_sql(versions)
997
1004
  end
998
1005
 
999
1006
  def insert_versions_sql(versions) # :nodoc:
1000
- sm_table = quote_table_name(ActiveRecord::Migrator.schema_migrations_table_name)
1007
+ sm_table = quote_table_name(ActiveRecord::SchemaMigration.table_name)
1001
1008
 
1002
1009
  if versions.is_a?(Array)
1003
1010
  sql = "INSERT INTO #{sm_table} (version) VALUES\n"
@@ -1026,12 +1033,11 @@ module ActiveRecord
1026
1033
  def assume_migrated_upto_version(version, migrations_paths)
1027
1034
  migrations_paths = Array(migrations_paths)
1028
1035
  version = version.to_i
1029
- sm_table = quote_table_name(ActiveRecord::Migrator.schema_migrations_table_name)
1036
+ sm_table = quote_table_name(ActiveRecord::SchemaMigration.table_name)
1030
1037
 
1031
- migrated = select_values("SELECT version FROM #{sm_table}").map(&:to_i)
1032
- paths = migrations_paths.map { |p| "#{p}/[0-9]*_*.rb" }
1033
- versions = Dir[*paths].map do |filename|
1034
- filename.split("/").last.split("_").first.to_i
1038
+ migrated = ActiveRecord::SchemaMigration.all_versions.map(&:to_i)
1039
+ versions = ActiveRecord::Migrator.migration_files(migrations_paths).map do |file|
1040
+ ActiveRecord::Migrator.parse_migration_filename(file).first.to_i
1035
1041
  end
1036
1042
 
1037
1043
  unless migrated.include?(version)
@@ -1306,6 +1312,14 @@ module ActiveRecord
1306
1312
  def can_remove_index_by_name?(options)
1307
1313
  options.is_a?(Hash) && options.key?(:name) && options.except(:name, :algorithm).empty?
1308
1314
  end
1315
+
1316
+ def data_source_sql(name = nil, type: nil)
1317
+ raise NotImplementedError
1318
+ end
1319
+
1320
+ def quoted_scope(name = nil, type: nil)
1321
+ raise NotImplementedError
1322
+ end
1309
1323
  end
1310
1324
  end
1311
1325
  end