Skip to content

Commit 5b91084

Browse files
committed
Remove support for oracle, sqlserver and JRuby specific database adapters from the new and db:system:change commands. The supported options are sqlite3, mysql, postgresql and trilogy.
1 parent 3e08223 commit 5b91084

File tree

9 files changed

+15
-126
lines changed

9 files changed

+15
-126
lines changed

actionview/test/active_record_unit.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,7 @@ def reconnect
5252
def setup_connection
5353
if Object.const_defined?(:ActiveRecord)
5454
defaults = { database: ":memory:" }
55-
adapter = defined?(JRUBY_VERSION) ? "jdbcsqlite3" : "sqlite3"
56-
options = defaults.merge adapter: adapter, timeout: 500
55+
options = defaults.merge adapter: "sqlite3", timeout: 500
5756
ActiveRecord::Base.establish_connection(options)
5857
ActiveRecord::Base.configurations = { "sqlite3_ar_integration" => options }
5958
ActiveRecord::Base.lease_connection

activerecord/test/schema/oracle_specific_schema.rb

Lines changed: 0 additions & 38 deletions
This file was deleted.

railties/CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,7 @@
1+
* Remove support for `oracle`, `sqlserver` and JRuby specific database adapters from the
2+
`rails new` and `rails db:system:change` commands. The supported options are `sqlite3`,
3+
`mysql`, `postgresql` and `trilogy`.
4+
5+
*Andrew Novoselac*
16

27
Please check [7-2-stable](https://github.com/rails/rails/blob/7-2-stable/railties/CHANGELOG.md) for previous changes.

railties/lib/rails/generators/database.rb

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -3,26 +3,14 @@
33
module Rails
44
module Generators
55
module Database # :nodoc:
6-
JDBC_DATABASES = %w( jdbcmysql jdbcsqlite3 jdbcpostgresql jdbc )
7-
DATABASES = %w( mysql trilogy postgresql sqlite3 oracle sqlserver ) + JDBC_DATABASES
8-
9-
def initialize(*)
10-
super
11-
convert_database_option_for_jruby
12-
end
6+
DATABASES = %w( mysql trilogy postgresql sqlite3 )
137

148
def gem_for_database(database = options[:database])
159
case database
1610
when "mysql" then ["mysql2", ["~> 0.5"]]
1711
when "trilogy" then ["trilogy", ["~> 2.7"]]
1812
when "postgresql" then ["pg", ["~> 1.1"]]
1913
when "sqlite3" then ["sqlite3", [">= 1.4"]]
20-
when "oracle" then ["activerecord-oracle_enhanced-adapter", nil]
21-
when "sqlserver" then ["activerecord-sqlserver-adapter", nil]
22-
when "jdbcmysql" then ["activerecord-jdbcmysql-adapter", nil]
23-
when "jdbcsqlite3" then ["activerecord-jdbcsqlite3-adapter", nil]
24-
when "jdbcpostgresql" then ["activerecord-jdbcpostgresql-adapter", nil]
25-
when "jdbc" then ["activerecord-jdbc-adapter", nil]
2614
else [database, nil]
2715
end
2816
end
@@ -47,18 +35,6 @@ def docker_for_database_build(database = options[:database])
4735
end
4836
end
4937

50-
def convert_database_option_for_jruby
51-
if defined?(JRUBY_VERSION)
52-
opt = options.dup
53-
case opt[:database]
54-
when "postgresql" then opt[:database] = "jdbcpostgresql"
55-
when "mysql" then opt[:database] = "jdbcmysql"
56-
when "sqlite3" then opt[:database] = "jdbcsqlite3"
57-
end
58-
self.options = opt.freeze
59-
end
60-
end
61-
6238
def base_package_for_database(database = options[:database])
6339
case database
6440
when "mysql" then "default-mysql-client"

railties/lib/rails/generators/rails/db/system/change/change_generator.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,11 @@ def all_database_gems
7171
end
7272

7373
def all_docker_bases
74-
DATABASES.map { |database| docker_for_database_base(database).nil? ? nil : docker_for_database_base(database) }.compact!
74+
DATABASES.filter_map { |database| docker_for_database_base(database) }
7575
end
7676

7777
def all_docker_builds
78-
DATABASES.map { |database| docker_for_database_build(database).nil? ? nil : docker_for_database_build(database) }.compact!
78+
DATABASES.filter_map { |database| docker_for_database_build(database) }
7979
end
8080

8181
def all_database_gems_regex

railties/test/commands/db_system_change_test.rb

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,7 @@ class Rails::Command::DbSystemChangeTest < ActiveSupport::TestCase
2525
assert_match <<~MSG.squish, output
2626
Invalid value for --to option.
2727
Supported preconfigurations are:
28-
mysql, trilogy, postgresql, sqlite3,
29-
oracle, sqlserver, jdbcmysql,
30-
jdbcsqlite3, jdbcpostgresql, jdbc.
28+
mysql, trilogy, postgresql, sqlite3.
3129
MSG
3230
end
3331

railties/test/generators/app_generator_test.rb

Lines changed: 3 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -477,21 +477,13 @@ def test_gemfile_has_no_whitespace_errors
477477
def test_config_database_is_added_by_default
478478
run_generator
479479
assert_file "config/database.yml", /sqlite3/
480-
if defined?(JRUBY_VERSION)
481-
assert_gem "activerecord-jdbcsqlite3-adapter"
482-
else
483-
assert_gem "sqlite3", '">= 1.4"'
484-
end
480+
assert_gem "sqlite3", '">= 1.4"'
485481
end
486482

487483
def test_config_mysql_database
488484
run_generator([destination_root, "-d", "mysql"])
489485
assert_file "config/database.yml", /mysql/
490-
if defined?(JRUBY_VERSION)
491-
assert_gem "activerecord-jdbcmysql-adapter"
492-
else
493-
assert_gem "mysql2", '"~> 0.5"'
494-
end
486+
assert_gem "mysql2", '"~> 0.5"'
495487
end
496488

497489
def test_config_database_app_name_with_period
@@ -502,44 +494,7 @@ def test_config_database_app_name_with_period
502494
def test_config_postgresql_database
503495
run_generator([destination_root, "-d", "postgresql"])
504496
assert_file "config/database.yml", /postgresql/
505-
if defined?(JRUBY_VERSION)
506-
assert_gem "activerecord-jdbcpostgresql-adapter"
507-
else
508-
assert_gem "pg", '"~> 1.1"'
509-
end
510-
end
511-
512-
def test_config_jdbcmysql_database
513-
run_generator([destination_root, "-d", "jdbcmysql"])
514-
assert_file "config/database.yml", /mysql/
515-
assert_gem "activerecord-jdbcmysql-adapter"
516-
end
517-
518-
def test_config_jdbcsqlite3_database
519-
run_generator([destination_root, "-d", "jdbcsqlite3"])
520-
assert_file "config/database.yml", /sqlite3/
521-
assert_gem "activerecord-jdbcsqlite3-adapter"
522-
end
523-
524-
def test_config_jdbcpostgresql_database
525-
run_generator([destination_root, "-d", "jdbcpostgresql"])
526-
assert_file "config/database.yml", /postgresql/
527-
assert_gem "activerecord-jdbcpostgresql-adapter"
528-
end
529-
530-
def test_config_jdbc_database
531-
run_generator([destination_root, "-d", "jdbc"])
532-
assert_file "config/database.yml", /jdbc/
533-
assert_file "config/database.yml", /mssql/
534-
assert_gem "activerecord-jdbc-adapter"
535-
end
536-
537-
if defined?(JRUBY_VERSION)
538-
def test_config_jdbc_database_when_no_option_given
539-
run_generator
540-
assert_file "config/database.yml", /sqlite3/
541-
assert_gem "activerecord-jdbcsqlite3-adapter"
542-
end
497+
assert_gem "pg", '"~> 1.1"'
543498
end
544499

545500
def test_generator_defaults_to_puma_version

railties/test/generators/db_system_change_generator_test.rb

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,7 @@ class ChangeGeneratorTest < Rails::Generators::TestCase
2828
assert_match <<~MSG.squish, output
2929
Invalid value for --to option.
3030
Supported preconfigurations are:
31-
mysql, trilogy, postgresql, sqlite3,
32-
oracle, sqlserver, jdbcmysql,
33-
jdbcsqlite3, jdbcpostgresql, jdbc.
31+
mysql, trilogy, postgresql, sqlite3.
3432
MSG
3533
end
3634

railties/test/generators/plugin_generator_test.rb

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -235,11 +235,7 @@ def test_no_development_dependencies_in_gemspec
235235
def test_default_database_dependency_is_sqlite
236236
run_generator
237237
assert_file "test/dummy/config/database.yml", /sqlite/
238-
if defined?(JRUBY_VERSION)
239-
assert_gem "activerecord-jdbcsqlite3-adapter"
240-
else
241-
assert_gem "sqlite3"
242-
end
238+
assert_gem "sqlite3"
243239
end
244240

245241
def test_custom_database_dependency

0 commit comments

Comments
 (0)