Skip to content

Commit 6862e7f

Browse files
committed
fix: configure initializers
override configuration
1 parent 05e374d commit 6862e7f

2 files changed

Lines changed: 15 additions & 1 deletion

File tree

config/database.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,8 @@ production:
9696
<<: *default
9797
<%
9898
# Use SUPABASE_DB_URL to avoid Rails auto-parsing DATABASE_URL with special chars
99-
db_url = ENV['SUPABASE_DB_URL'] || ENV['DATABASE_URL']
99+
# _ORIGINAL_DATABASE_URL is set by initializers/database_url_override.rb
100+
db_url = ENV['SUPABASE_DB_URL'] || ENV['_ORIGINAL_DATABASE_URL'] || ENV['DATABASE_URL']
100101
if db_url
101102
begin
102103
# Parse database URL manually to handle special characters in password
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Prevent Rails from auto-parsing DATABASE_URL when it contains special characters
2+
# This initializer runs BEFORE database configuration is loaded
3+
#
4+
# We use SUPABASE_DB_URL instead and parse it manually in database.yml
5+
# to handle passwords with special characters like @ symbols
6+
7+
if ENV['DATABASE_URL'].present? && ENV['DATABASE_URL'].include?('@@')
8+
Rails.logger.info "DATABASE_URL contains special characters - will be ignored in favor of manual parsing"
9+
10+
# Store the original and clear it so Rails doesn't try to parse it
11+
ENV['_ORIGINAL_DATABASE_URL'] = ENV['DATABASE_URL']
12+
ENV.delete('DATABASE_URL')
13+
end

0 commit comments

Comments
 (0)