File tree Expand file tree Collapse file tree 1 file changed +13
-1
lines changed Expand file tree Collapse file tree 1 file changed +13
-1
lines changed Original file line number Diff line number Diff line change 2828 db_file = File . join ( Dir . tmpdir , "closure_tree_test_#{ SecureRandom . hex } .sqlite3" )
2929 ActiveRecord ::Base . establish_connection ( adapter : 'sqlite3' , database : db_file )
3030 end
31+ elsif database_url . start_with? ( 'mysql2://' )
32+ # Parse MySQL URL: mysql2://root:root@0/closure_tree_test
33+ # The @0 means localhost in GitHub Actions
34+ fixed_url = database_url . gsub ( '@0/' , '@127.0.0.1/' )
35+ ActiveRecord ::Base . establish_connection ( fixed_url )
36+ elsif database_url . start_with? ( 'postgres://' )
37+ # Parse PostgreSQL URL: postgres://closure_tree:closure_tree@0/closure_tree_test
38+ # The @0 means localhost in GitHub Actions
39+ fixed_url = database_url . gsub ( '@0/' , '@127.0.0.1/' )
40+ # PostgreSQL adapter expects 'postgresql://' not 'postgres://'
41+ fixed_url = fixed_url . gsub ( 'postgres://' , 'postgresql://' )
42+ ActiveRecord ::Base . establish_connection ( fixed_url )
3143else
32- # For MySQL and PostgreSQL , use the URL directly
44+ # For other database URLs , use directly
3345 ActiveRecord ::Base . establish_connection ( database_url )
3446end
3547
You can’t perform that action at this time.
0 commit comments