Skip to content

Commit cb1c789

Browse files
authored
Merge pull request rails#51765 from Shopify/refactor-devcontainer-implementation
Clean up database generators implementation
2 parents 5c933a3 + c1bc7ee commit cb1c789

File tree

14 files changed

+334
-342
lines changed

14 files changed

+334
-342
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/app_base.rb

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
module Rails
1313
module Generators
1414
class AppBase < Base # :nodoc:
15-
include Database
1615
include Devcontainer
1716
include AppName
1817

@@ -40,7 +39,7 @@ def self.add_shared_options_for(name)
4039
desc: "Path to some #{name} template (can be a filesystem path or URL)"
4140

4241
class_option :database, type: :string, aliases: "-d", default: "sqlite3",
43-
enum: DATABASES,
42+
enum: Database::DATABASES,
4443
desc: "Preconfigure for selected database"
4544

4645
class_option :skip_git, type: :boolean, aliases: "-G", default: nil,
@@ -279,7 +278,7 @@ def set_default_accessors! # :doc:
279278
def database_gemfile_entry # :doc:
280279
return if options[:skip_active_record]
281280

282-
gem_name, gem_version = gem_for_database
281+
gem_name, gem_version = database.gem
283282
GemfileEntry.version gem_name, gem_version,
284283
"Use #{options[:database]} as the database for Active Record"
285284
end
@@ -574,7 +573,7 @@ def dockerfile_base_packages
574573
packages = ["curl"]
575574

576575
# ActiveRecord databases
577-
packages << base_package_for_database unless skip_active_record?
576+
packages << database.base_package unless skip_active_record?
578577

579578
# ActiveStorage preview support
580579
packages << "libvips" unless skip_active_storage?
@@ -590,7 +589,7 @@ def dockerfile_build_packages
590589
packages = %w(build-essential git pkg-config)
591590

592591
# add database support
593-
packages << build_package_for_database unless skip_active_record?
592+
packages << database.build_package unless skip_active_record?
594593

595594
packages << "unzip" if using_bun?
596595

@@ -772,6 +771,10 @@ def dockerfile_chown_directories
772771

773772
directories.sort
774773
end
774+
775+
def database
776+
@database ||= Database.build(options[:database])
777+
end
775778
end
776779
end
777780
end

0 commit comments

Comments
 (0)