From 77b549706a6fe7689c371f10360def838a042c99 Mon Sep 17 00:00:00 2001 From: Joey Perry Date: Wed, 9 Feb 2022 12:37:23 -0600 Subject: [PATCH 1/3] Allow overriding system user on db create. #2257 --- .../connection_adapters/oracle_enhanced/database_tasks.rb | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib/active_record/connection_adapters/oracle_enhanced/database_tasks.rb b/lib/active_record/connection_adapters/oracle_enhanced/database_tasks.rb index 14708adcb..3faafca09 100644 --- a/lib/active_record/connection_adapters/oracle_enhanced/database_tasks.rb +++ b/lib/active_record/connection_adapters/oracle_enhanced/database_tasks.rb @@ -13,6 +13,13 @@ def initialize(config) end def create + if ENV["ORACLE_SYSTEM_USER"] + system_user = ENV["ORACLE_SYSTEM_USER"] + else + system_user = "SYSTEM" + $stdout.puts "Using system user '#{system_user}' (set ORACLE_SYSTEM_USER to override)" + end + system_password = ENV.fetch("ORACLE_SYSTEM_PASSWORD") { print "Please provide the SYSTEM password for your Oracle installation (set ORACLE_SYSTEM_PASSWORD to avoid this prompt)\n>" $stdin.gets.strip From 7c7f2f96969905bf587fbc03d784e8d830a82952 Mon Sep 17 00:00:00 2001 From: Joey Perry Date: Thu, 24 Feb 2022 13:06:42 -0600 Subject: [PATCH 2/3] Tweak allow overriding system user on db create. #2257 --- .../oracle_enhanced/database_tasks.rb | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/lib/active_record/connection_adapters/oracle_enhanced/database_tasks.rb b/lib/active_record/connection_adapters/oracle_enhanced/database_tasks.rb index 3faafca09..f62402d55 100644 --- a/lib/active_record/connection_adapters/oracle_enhanced/database_tasks.rb +++ b/lib/active_record/connection_adapters/oracle_enhanced/database_tasks.rb @@ -13,18 +13,14 @@ def initialize(config) end def create - if ENV["ORACLE_SYSTEM_USER"] - system_user = ENV["ORACLE_SYSTEM_USER"] - else - system_user = "SYSTEM" - $stdout.puts "Using system user '#{system_user}' (set ORACLE_SYSTEM_USER to override)" - end + system_username = ENV["ORACLE_SYSTEM_USER"] || 'SYSTEM' + $stdout.puts "System user: '#{system_username}' (set ORACLE_SYSTEM_USER to override)" unless ENV["ORACLE_SYSTEM_USER"] system_password = ENV.fetch("ORACLE_SYSTEM_PASSWORD") { - print "Please provide the SYSTEM password for your Oracle installation (set ORACLE_SYSTEM_PASSWORD to avoid this prompt)\n>" + print "Please provide the '#{system_username}' password for your Oracle installation (set ORACLE_SYSTEM_PASSWORD to avoid this prompt)\n>" $stdin.gets.strip } - establish_connection(@config.merge(username: "SYSTEM", password: system_password)) + establish_connection(@config.merge(username: system_username, password: system_password)) begin connection.execute "CREATE USER #{@config[:username]} IDENTIFIED BY #{@config[:password]}" rescue => e From d7982b0e031b2e30b9e58c0927d914d1c489b80b Mon Sep 17 00:00:00 2001 From: Joey Perry Date: Thu, 11 May 2023 11:51:47 -0500 Subject: [PATCH 3/3] Use double quotes for system username. --- .../connection_adapters/oracle_enhanced/database_tasks.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/active_record/connection_adapters/oracle_enhanced/database_tasks.rb b/lib/active_record/connection_adapters/oracle_enhanced/database_tasks.rb index f62402d55..d02a59215 100644 --- a/lib/active_record/connection_adapters/oracle_enhanced/database_tasks.rb +++ b/lib/active_record/connection_adapters/oracle_enhanced/database_tasks.rb @@ -13,7 +13,7 @@ def initialize(config) end def create - system_username = ENV["ORACLE_SYSTEM_USER"] || 'SYSTEM' + system_username = ENV["ORACLE_SYSTEM_USER"] || "SYSTEM" $stdout.puts "System user: '#{system_username}' (set ORACLE_SYSTEM_USER to override)" unless ENV["ORACLE_SYSTEM_USER"] system_password = ENV.fetch("ORACLE_SYSTEM_PASSWORD") {