By Vito Botta
Hi, I’ve opened a ticket but I thought I’d ask here as well in case someone can help. I havre a Rails app that connects to a database in my MySQL cluster managed by DO. If I run migrations on that database, the schema.rb file generated isn’t valid and cannot be used for example for loading into an empty db. If, however, I do exactly the same thing but with a local (Docker) instance of MySQL 8.0.17 - exactly the same version as DO - then all is good. Is there any Rails developer here who could try dumping the schema while connected to DO MySQL?
Thanks!
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
Hello,
Just came across this answer and decided to write some general guidelines for anyone who comes across this in the future despite the old question.
First, make sure your database.yml file is configured correctly to connect to the DigitalOcean managed MySQL cluster. You should have something like this in your config/database.yml file:
- production:
- adapter: mysql2
- encoding: utf8
- url: <%= ENV['DB_URL'] %>
- username: <%= ENV['DB_USERNAME'] %>
- password: <%= ENV['DB_PASSWORD'] %>
- database: <%= ENV['DB_NAME'] %>
- pool: <%= ENV['DB_POOL'] %>
Ensure your environment variables are set correctly in the environment or in your app’s configuration (e.g., using a .env file with the dotenv gem).
After verifying your configuration, run the migrations using:
RAILS_ENV=production bundle exec rake db:migrate
Ensure your local version of MySQL is the same as the one you’re using on DigitalOcean. If the problem persists, please provide more information about the error message you’re receiving, and I’ll do my best to help you further.
For more information on connecting Ruby on Rails with DigitalOcean managed databases, refer to the official documentation.
Hope that this helps!
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.