-
Notifications
You must be signed in to change notification settings - Fork 0
Moving to MySQL
This document is a work in progress, do not rely on this document to be accurate yet.
-
Stop your web server
-
IMPORTANT Backup your production database and server (if you are really paranoid). YES. Do it!
-
Install MySQL Community Server
-
Before doing the migration, some nice things to do to minimize the amount of data copied over and to speed up the process. This list is in the recommended, but not required order. Feel free to do re-order depending on your needs
RAILS_ENV=production rake chore:cleanup_missing_manifests
RAILS_ENV=production rake chore:cleanup_old_managed_install_reports
RAILS_ENV=production rake chore:cleanup_system_profiles
RAILS_ENV=production rake chore:destroy_stale_item_records
RAILS_ENV=production rake chore:validate_models #This is important because the MySQL migrations require you to have completely valid entries
sqlite3 <database_name> vacuum
- Pull the latest changes from MunkiServer, then apply Trey's branch, finally, get all the gems
git checkout master
git pull jnraine
git pull jnraine mysql_support_final master
bundle install
- Create a the production database in MySQL and edit your config/database.yml and replace the existing production section with something like this:
production:
adapter: mysql2
encoding: utf8
database: <database_name>
pool: 5
username: <db username>
password: <db password>
socket: /tmp/mysql.sock
This Rails Guide might help.
- Move the data from sqlite3 to MySQL
# Create temporary web service with production sqlite database
taps server sqlite://db/production.sqlite3 munkiserver munkiserver &
# Pull sqlite3 database into mysql
taps pull mysql2://<db username>:<db password>@localhost/<db name> http://munkiserver:munkiserver@localhost:5000
- Apply the latest migrations to the MySQL database
RAILS_ENV=production rake db:migrate
- Start webserver and cross your fingers. If you run into problems email [email protected]
-
If you run into any database corruption errors, such as "The database disk image is malformed", consider trying this database corruption fix
-
If you run into an error like "Library not loaded: libmysqlclient.18.dylib" in working with MySQL, consider looking at the libmysqlclient.18.dylib fix