File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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
Original file line number Diff line number Diff line change 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
You can’t perform that action at this time.
0 commit comments