Skip to content

Commit

Permalink
Fix sslca param + disable schema dumps for psdb
Browse files Browse the repository at this point in the history
- sslca doesnt need an underscore

For the schema dump. I've found that when rails generates schema.rb or structure.sql, it runs an incredible amount of queries to construct dump.

Normally, with local mysql this is fine because there is nearly no latency per query. When running this against a cloud database, it adds up very quickly.

One of our example databases takes a full minute to dump (my laptop is 30ms from the database).

By adding `schema_dump=`, this sets the Rails config for schema_dump to nil. Telling Rails not to run the dump.

`schema_dump=false` does not work because this sets it to a string, which rails interprets at the filename where we want the dump stored.
  • Loading branch information
mscoutermarsh committed Jan 12, 2024
1 parent d532add commit f3691a8
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/planetscale_rails/tasks/psdb.rake
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,14 @@ namespace :psdb do
adapter = "trilogy"
end

# Setting schema_dump to nil is intentional. It prevents Rails from creating a dump after running migrations.
url = "#{adapter}://#{username}:#{password}@#{host}:3306/#{database}?ssl_mode=VERIFY_IDENTITY&schema_dump="

# Check common CA paths for certs.
ssl_ca_path = %w[/etc/ssl/certs/ca-certificates.crt /etc/pki/tls/certs/ca-bundle.crt /etc/ssl/ca-bundle.pem /etc/ssl/cert.pem].find { |f| File.exist?(f) }
url = "#{adapter}://#{username}:#{password}@#{host}:3306/#{database}?ssl_mode=VERIFY_IDENTITY"

if ssl_ca_path
url += "&ssl_ca=#{ssl_ca_path}"
url += "&sslca=#{ssl_ca_path}"
end

url
Expand Down

0 comments on commit f3691a8

Please sign in to comment.