mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Merge pull request #28172 from kamipo/deprecate_supports_migrations
Deprecate `supports_migrations?` on connection adapters
This commit is contained in:
commit
7888f4fae0
13 changed files with 336 additions and 368 deletions
|
@ -1,3 +1,7 @@
|
|||
* Deprecate `supports_migrations?` on connection adapters.
|
||||
|
||||
*Ryuta Kamizono*
|
||||
|
||||
* Fix regression of #1969 with SELECT aliases in HAVING clause.
|
||||
|
||||
*Eugene Kenny*
|
||||
|
|
|
@ -232,10 +232,10 @@ module ActiveRecord
|
|||
self.class::ADAPTER_NAME
|
||||
end
|
||||
|
||||
# Does this adapter support migrations?
|
||||
def supports_migrations?
|
||||
false
|
||||
def supports_migrations? # :nodoc:
|
||||
true
|
||||
end
|
||||
deprecate :supports_migrations?
|
||||
|
||||
def supports_primary_key? # :nodoc:
|
||||
true
|
||||
|
|
|
@ -89,11 +89,6 @@ module ActiveRecord
|
|||
/mariadb/i.match?(full_version)
|
||||
end
|
||||
|
||||
# Returns true, since this connection adapter supports migrations.
|
||||
def supports_migrations?
|
||||
true
|
||||
end
|
||||
|
||||
def supports_bulk_alter? #:nodoc:
|
||||
true
|
||||
end
|
||||
|
|
|
@ -281,11 +281,6 @@ module ActiveRecord
|
|||
NATIVE_DATABASE_TYPES
|
||||
end
|
||||
|
||||
# Returns true, since this connection adapter supports migrations.
|
||||
def supports_migrations?
|
||||
true
|
||||
end
|
||||
|
||||
def set_standard_conforming_strings
|
||||
execute("SET standard_conforming_strings = on", "SCHEMA")
|
||||
end
|
||||
|
|
|
@ -117,11 +117,6 @@ module ActiveRecord
|
|||
true
|
||||
end
|
||||
|
||||
# Returns true, since this connection adapter supports migrations.
|
||||
def supports_migrations? #:nodoc:
|
||||
true
|
||||
end
|
||||
|
||||
def requires_reloading?
|
||||
true
|
||||
end
|
||||
|
|
|
@ -548,13 +548,11 @@ module ActiveRecord
|
|||
end
|
||||
|
||||
def call(env)
|
||||
if connection.supports_migrations?
|
||||
mtime = ActiveRecord::Migrator.last_migration.mtime.to_i
|
||||
if @last_check < mtime
|
||||
ActiveRecord::Migration.check_pending!(connection)
|
||||
@last_check = mtime
|
||||
end
|
||||
end
|
||||
@app.call(env)
|
||||
end
|
||||
|
||||
|
@ -1098,8 +1096,6 @@ module ActiveRecord
|
|||
end
|
||||
|
||||
def initialize(direction, migrations, target_version = nil)
|
||||
raise StandardError.new("This database does not yet support migrations") unless Base.connection.supports_migrations?
|
||||
|
||||
@direction = direction
|
||||
@target_version = target_version
|
||||
@migrated_versions = nil
|
||||
|
|
|
@ -288,8 +288,7 @@ db_namespace = namespace :db do
|
|||
current_config = ActiveRecord::Tasks::DatabaseTasks.current_config
|
||||
ActiveRecord::Tasks::DatabaseTasks.structure_dump(current_config, filename)
|
||||
|
||||
if ActiveRecord::Base.connection.supports_migrations? &&
|
||||
ActiveRecord::SchemaMigration.table_exists?
|
||||
if ActiveRecord::SchemaMigration.table_exists?
|
||||
File.open(filename, "a") do |f|
|
||||
f.puts ActiveRecord::Base.connection.dump_schema_information
|
||||
f.print "\n"
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
require "cases/helper"
|
||||
|
||||
if ActiveRecord::Base.connection.supports_migrations?
|
||||
|
||||
class ActiveRecordSchemaTest < ActiveRecord::TestCase
|
||||
self.use_transactional_tests = false
|
||||
|
||||
|
@ -143,4 +141,3 @@ if ActiveRecord::Base.connection.supports_migrations?
|
|||
assert !@connection.columns(:has_timestamps).find { |c| c.name == "updated_at" }.null
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
require "cases/helper"
|
||||
|
||||
if ActiveRecord::Base.connection.supports_migrations?
|
||||
class EagerSingularizationTest < ActiveRecord::TestCase
|
||||
class Virus < ActiveRecord::Base
|
||||
belongs_to :octopus
|
||||
|
@ -103,10 +102,6 @@ if ActiveRecord::Base.connection.supports_migrations?
|
|||
connection.drop_table :compresses
|
||||
end
|
||||
|
||||
def connection
|
||||
ActiveRecord::Base.connection
|
||||
end
|
||||
|
||||
def test_eager_no_extra_singularization_belongs_to
|
||||
assert_nothing_raised do
|
||||
Virus.all.merge!(includes: :octopus).to_a
|
||||
|
@ -143,5 +138,9 @@ if ActiveRecord::Base.connection.supports_migrations?
|
|||
Crisis.all.merge!(includes: :compresses).to_a
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
def connection
|
||||
ActiveRecord::Base.connection
|
||||
end
|
||||
end
|
||||
|
|
|
@ -566,7 +566,6 @@ class DirtyTest < ActiveRecord::TestCase
|
|||
travel_back
|
||||
end
|
||||
|
||||
if ActiveRecord::Base.connection.supports_migrations?
|
||||
class Testings < ActiveRecord::Base; end
|
||||
def test_field_named_field
|
||||
ActiveRecord::Base.connection.create_table :testings do |t|
|
||||
|
@ -579,7 +578,6 @@ class DirtyTest < ActiveRecord::TestCase
|
|||
ActiveRecord::Base.connection.drop_table :testings rescue nil
|
||||
ActiveRecord::Base.clear_cache!
|
||||
end
|
||||
end
|
||||
|
||||
def test_datetime_attribute_can_be_updated_with_fractional_seconds
|
||||
skip "Fractional seconds are not supported" unless subsecond_precision_supported?
|
||||
|
|
|
@ -104,7 +104,6 @@ class FixturesTest < ActiveRecord::TestCase
|
|||
assert_nil(second_row["author_email_address"])
|
||||
end
|
||||
|
||||
if ActiveRecord::Base.connection.supports_migrations?
|
||||
def test_inserts_with_pre_and_suffix
|
||||
# Reset cache to make finds on the new table work
|
||||
ActiveRecord::FixtureSet.reset_cache
|
||||
|
@ -162,7 +161,6 @@ class FixturesTest < ActiveRecord::TestCase
|
|||
|
||||
ActiveRecord::Base.connection.drop_table :prefix_other_topics_suffix rescue nil
|
||||
end
|
||||
end
|
||||
|
||||
def test_insert_with_datetime
|
||||
create_fixtures("tasks")
|
||||
|
|
|
@ -21,8 +21,6 @@ module ActiveRecord
|
|||
end
|
||||
|
||||
def test_errors_if_pending
|
||||
@connection.expect :supports_migrations?, true
|
||||
|
||||
ActiveRecord::Migrator.stub :needs_migration?, true do
|
||||
assert_raise ActiveRecord::PendingMigrationError do
|
||||
@pending.call(nil)
|
||||
|
@ -31,22 +29,12 @@ module ActiveRecord
|
|||
end
|
||||
|
||||
def test_checks_if_supported
|
||||
@connection.expect :supports_migrations?, true
|
||||
@app.expect :call, nil, [:foo]
|
||||
|
||||
ActiveRecord::Migrator.stub :needs_migration?, false do
|
||||
@pending.call(:foo)
|
||||
end
|
||||
end
|
||||
|
||||
def test_doesnt_check_if_unsupported
|
||||
@connection.expect :supports_migrations?, false
|
||||
@app.expect :call, nil, [:foo]
|
||||
|
||||
ActiveRecord::Migrator.stub :needs_migration?, true do
|
||||
@pending.call(:foo)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1142,4 +1142,8 @@ class CopyMigrationsTest < ActiveRecord::TestCase
|
|||
def test_deprecate_migration_keys
|
||||
assert_deprecated { ActiveRecord::Base.connection.migration_keys }
|
||||
end
|
||||
|
||||
def test_deprecate_supports_migrations
|
||||
assert_deprecated { ActiveRecord::Base.connection.supports_migrations? }
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue