File tree Expand file tree Collapse file tree 4 files changed +11
-3
lines changed Expand file tree Collapse file tree 4 files changed +11
-3
lines changed Original file line number Diff line number Diff line change @@ -641,6 +641,14 @@ def database_version # :nodoc:
641
641
def check_version # :nodoc:
642
642
end
643
643
644
+ # Returns the version identifier of the schema currently available in
645
+ # the database. This is generally equal to the number of the highest-
646
+ # numbered migration that has been executed, or 0 if no schema
647
+ # information is present / the database is empty.
648
+ def schema_version
649
+ migration_context . current_version
650
+ end
651
+
644
652
def field_ordered_value ( column , values ) # :nodoc:
645
653
node = Arel ::Nodes ::Case . new ( column )
646
654
values . each . with_index ( 1 ) do |value , order |
Original file line number Diff line number Diff line change @@ -208,7 +208,7 @@ def ignored_table?(table_name)
208
208
end
209
209
210
210
def reset_version!
211
- @version = connection . migration_context . current_version
211
+ @version = connection . schema_version
212
212
end
213
213
214
214
def derive_columns_hash_and_deduplicate_values
Original file line number Diff line number Diff line change @@ -332,7 +332,7 @@ db_namespace = namespace :db do
332
332
333
333
desc "Retrieves the current schema version number"
334
334
task version : :load_config do
335
- puts "Current version: #{ ActiveRecord ::Base . connection . migration_context . current_version } "
335
+ puts "Current version: #{ ActiveRecord ::Base . connection . schema_version } "
336
336
end
337
337
338
338
# desc "Raises an error if there are pending migrations"
Original file line number Diff line number Diff line change @@ -49,7 +49,7 @@ def test_schema_define
49
49
50
50
assert_nothing_raised { @connection . select_all "SELECT * FROM fruits" }
51
51
assert_nothing_raised { @connection . select_all "SELECT * FROM schema_migrations" }
52
- assert_equal 7 , @connection . migration_context . current_version
52
+ assert_equal 7 , @connection . schema_version
53
53
end
54
54
55
55
def test_schema_define_with_table_name_prefix
You can’t perform that action at this time.
0 commit comments