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.
This commit is contained in:
parent
3e08223ece
commit
5b91084f20
@ -52,8 +52,7 @@ def reconnect
|
||||
def setup_connection
|
||||
if Object.const_defined?(:ActiveRecord)
|
||||
defaults = { database: ":memory:" }
|
||||
adapter = defined?(JRUBY_VERSION) ? "jdbcsqlite3" : "sqlite3"
|
||||
options = defaults.merge adapter: adapter, timeout: 500
|
||||
options = defaults.merge adapter: "sqlite3", timeout: 500
|
||||
ActiveRecord::Base.establish_connection(options)
|
||||
ActiveRecord::Base.configurations = { "sqlite3_ar_integration" => options }
|
||||
ActiveRecord::Base.lease_connection
|
||||
|
@ -1,38 +0,0 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
ActiveRecord::Schema.define do
|
||||
execute "drop table test_oracle_defaults" rescue nil
|
||||
execute "drop sequence test_oracle_defaults_seq" rescue nil
|
||||
execute "drop sequence companies_nonstd_seq" rescue nil
|
||||
execute "drop table defaults" rescue nil
|
||||
execute "drop sequence defaults_seq" rescue nil
|
||||
|
||||
execute <<~SQL
|
||||
create table test_oracle_defaults (
|
||||
id integer not null primary key,
|
||||
test_char char(1) default 'X' not null,
|
||||
test_string varchar2(20) default 'hello' not null,
|
||||
test_int integer default 3 not null
|
||||
)
|
||||
SQL
|
||||
|
||||
execute "create sequence test_oracle_defaults_seq minvalue 10000"
|
||||
|
||||
execute "create sequence companies_nonstd_seq minvalue 10000"
|
||||
|
||||
execute <<~SQL
|
||||
CREATE TABLE defaults (
|
||||
id integer not null,
|
||||
modified_date date default sysdate,
|
||||
modified_date_function date default sysdate,
|
||||
fixed_date date default to_date('2004-01-01', 'YYYY-MM-DD'),
|
||||
modified_time date default sysdate,
|
||||
modified_time_function date default sysdate,
|
||||
fixed_time date default TO_DATE('2004-01-01 00:00:00', 'YYYY-MM-DD HH24:MI:SS'),
|
||||
char1 varchar2(1) default 'Y',
|
||||
char2 varchar2(50) default 'a varchar field',
|
||||
char3 clob default 'a text field'
|
||||
)
|
||||
SQL
|
||||
execute "create sequence defaults_seq minvalue 10000"
|
||||
end
|
@ -1,2 +1,7 @@
|
||||
* Remove support for `oracle`, `sqlserver` and JRuby specific database adapters from the
|
||||
`rails new` and `rails db:system:change` commands. The supported options are `sqlite3`,
|
||||
`mysql`, `postgresql` and `trilogy`.
|
||||
|
||||
*Andrew Novoselac*
|
||||
|
||||
Please check [7-2-stable](https://github.com/rails/rails/blob/7-2-stable/railties/CHANGELOG.md) for previous changes.
|
||||
|
@ -3,13 +3,7 @@
|
||||
module Rails
|
||||
module Generators
|
||||
module Database # :nodoc:
|
||||
JDBC_DATABASES = %w( jdbcmysql jdbcsqlite3 jdbcpostgresql jdbc )
|
||||
DATABASES = %w( mysql trilogy postgresql sqlite3 oracle sqlserver ) + JDBC_DATABASES
|
||||
|
||||
def initialize(*)
|
||||
super
|
||||
convert_database_option_for_jruby
|
||||
end
|
||||
DATABASES = %w( mysql trilogy postgresql sqlite3 )
|
||||
|
||||
def gem_for_database(database = options[:database])
|
||||
case database
|
||||
@ -17,12 +11,6 @@ def gem_for_database(database = options[:database])
|
||||
when "trilogy" then ["trilogy", ["~> 2.7"]]
|
||||
when "postgresql" then ["pg", ["~> 1.1"]]
|
||||
when "sqlite3" then ["sqlite3", [">= 1.4"]]
|
||||
when "oracle" then ["activerecord-oracle_enhanced-adapter", nil]
|
||||
when "sqlserver" then ["activerecord-sqlserver-adapter", nil]
|
||||
when "jdbcmysql" then ["activerecord-jdbcmysql-adapter", nil]
|
||||
when "jdbcsqlite3" then ["activerecord-jdbcsqlite3-adapter", nil]
|
||||
when "jdbcpostgresql" then ["activerecord-jdbcpostgresql-adapter", nil]
|
||||
when "jdbc" then ["activerecord-jdbc-adapter", nil]
|
||||
else [database, nil]
|
||||
end
|
||||
end
|
||||
@ -47,18 +35,6 @@ def docker_for_database_build(database = options[:database])
|
||||
end
|
||||
end
|
||||
|
||||
def convert_database_option_for_jruby
|
||||
if defined?(JRUBY_VERSION)
|
||||
opt = options.dup
|
||||
case opt[:database]
|
||||
when "postgresql" then opt[:database] = "jdbcpostgresql"
|
||||
when "mysql" then opt[:database] = "jdbcmysql"
|
||||
when "sqlite3" then opt[:database] = "jdbcsqlite3"
|
||||
end
|
||||
self.options = opt.freeze
|
||||
end
|
||||
end
|
||||
|
||||
def base_package_for_database(database = options[:database])
|
||||
case database
|
||||
when "mysql" then "default-mysql-client"
|
||||
|
@ -71,11 +71,11 @@ def all_database_gems
|
||||
end
|
||||
|
||||
def all_docker_bases
|
||||
DATABASES.map { |database| docker_for_database_base(database).nil? ? nil : docker_for_database_base(database) }.compact!
|
||||
DATABASES.filter_map { |database| docker_for_database_base(database) }
|
||||
end
|
||||
|
||||
def all_docker_builds
|
||||
DATABASES.map { |database| docker_for_database_build(database).nil? ? nil : docker_for_database_build(database) }.compact!
|
||||
DATABASES.filter_map { |database| docker_for_database_build(database) }
|
||||
end
|
||||
|
||||
def all_database_gems_regex
|
||||
|
@ -25,9 +25,7 @@ class Rails::Command::DbSystemChangeTest < ActiveSupport::TestCase
|
||||
assert_match <<~MSG.squish, output
|
||||
Invalid value for --to option.
|
||||
Supported preconfigurations are:
|
||||
mysql, trilogy, postgresql, sqlite3,
|
||||
oracle, sqlserver, jdbcmysql,
|
||||
jdbcsqlite3, jdbcpostgresql, jdbc.
|
||||
mysql, trilogy, postgresql, sqlite3.
|
||||
MSG
|
||||
end
|
||||
|
||||
|
@ -477,21 +477,13 @@ def test_gemfile_has_no_whitespace_errors
|
||||
def test_config_database_is_added_by_default
|
||||
run_generator
|
||||
assert_file "config/database.yml", /sqlite3/
|
||||
if defined?(JRUBY_VERSION)
|
||||
assert_gem "activerecord-jdbcsqlite3-adapter"
|
||||
else
|
||||
assert_gem "sqlite3", '">= 1.4"'
|
||||
end
|
||||
assert_gem "sqlite3", '">= 1.4"'
|
||||
end
|
||||
|
||||
def test_config_mysql_database
|
||||
run_generator([destination_root, "-d", "mysql"])
|
||||
assert_file "config/database.yml", /mysql/
|
||||
if defined?(JRUBY_VERSION)
|
||||
assert_gem "activerecord-jdbcmysql-adapter"
|
||||
else
|
||||
assert_gem "mysql2", '"~> 0.5"'
|
||||
end
|
||||
assert_gem "mysql2", '"~> 0.5"'
|
||||
end
|
||||
|
||||
def test_config_database_app_name_with_period
|
||||
@ -502,44 +494,7 @@ def test_config_database_app_name_with_period
|
||||
def test_config_postgresql_database
|
||||
run_generator([destination_root, "-d", "postgresql"])
|
||||
assert_file "config/database.yml", /postgresql/
|
||||
if defined?(JRUBY_VERSION)
|
||||
assert_gem "activerecord-jdbcpostgresql-adapter"
|
||||
else
|
||||
assert_gem "pg", '"~> 1.1"'
|
||||
end
|
||||
end
|
||||
|
||||
def test_config_jdbcmysql_database
|
||||
run_generator([destination_root, "-d", "jdbcmysql"])
|
||||
assert_file "config/database.yml", /mysql/
|
||||
assert_gem "activerecord-jdbcmysql-adapter"
|
||||
end
|
||||
|
||||
def test_config_jdbcsqlite3_database
|
||||
run_generator([destination_root, "-d", "jdbcsqlite3"])
|
||||
assert_file "config/database.yml", /sqlite3/
|
||||
assert_gem "activerecord-jdbcsqlite3-adapter"
|
||||
end
|
||||
|
||||
def test_config_jdbcpostgresql_database
|
||||
run_generator([destination_root, "-d", "jdbcpostgresql"])
|
||||
assert_file "config/database.yml", /postgresql/
|
||||
assert_gem "activerecord-jdbcpostgresql-adapter"
|
||||
end
|
||||
|
||||
def test_config_jdbc_database
|
||||
run_generator([destination_root, "-d", "jdbc"])
|
||||
assert_file "config/database.yml", /jdbc/
|
||||
assert_file "config/database.yml", /mssql/
|
||||
assert_gem "activerecord-jdbc-adapter"
|
||||
end
|
||||
|
||||
if defined?(JRUBY_VERSION)
|
||||
def test_config_jdbc_database_when_no_option_given
|
||||
run_generator
|
||||
assert_file "config/database.yml", /sqlite3/
|
||||
assert_gem "activerecord-jdbcsqlite3-adapter"
|
||||
end
|
||||
assert_gem "pg", '"~> 1.1"'
|
||||
end
|
||||
|
||||
def test_generator_defaults_to_puma_version
|
||||
|
@ -28,9 +28,7 @@ class ChangeGeneratorTest < Rails::Generators::TestCase
|
||||
assert_match <<~MSG.squish, output
|
||||
Invalid value for --to option.
|
||||
Supported preconfigurations are:
|
||||
mysql, trilogy, postgresql, sqlite3,
|
||||
oracle, sqlserver, jdbcmysql,
|
||||
jdbcsqlite3, jdbcpostgresql, jdbc.
|
||||
mysql, trilogy, postgresql, sqlite3.
|
||||
MSG
|
||||
end
|
||||
|
||||
|
@ -235,11 +235,7 @@ def test_no_development_dependencies_in_gemspec
|
||||
def test_default_database_dependency_is_sqlite
|
||||
run_generator
|
||||
assert_file "test/dummy/config/database.yml", /sqlite/
|
||||
if defined?(JRUBY_VERSION)
|
||||
assert_gem "activerecord-jdbcsqlite3-adapter"
|
||||
else
|
||||
assert_gem "sqlite3"
|
||||
end
|
||||
assert_gem "sqlite3"
|
||||
end
|
||||
|
||||
def test_custom_database_dependency
|
||||
|
Loading…
Reference in New Issue
Block a user