-
Notifications
You must be signed in to change notification settings - Fork 523
Migrations
redsummernight edited this page May 2, 2020
·
10 revisions
Please refer to the Active Record Migrations guide for working with migrations in general.
We track both types of schema dumps in our repository: Ruby and SQL. Every once in a while, we generate new versions of these dumps by connecting to a production app server and running:
cd ~/app/current bundle exec rake db:schema:dump # Ruby dump bundle exec rake db:structure:dump # SQL dump
The new dumps can be found at:
~/app/current/db/schema.rb ~/app/current/db/structure.sql
We need to manually edit them:
- Ruby dump: Change the version in
ActiveRecord::Schema.define
to the latest migration timestamp. Then we need to check the existing pull requests for migrations and bump their timestamps to later. - SQL dump: Remove AUTO_INCREMENT values.
We use Percona Toolkit's pt-online-schema-change tool when we need to change a large table without going into maintenance mode. This lets us make changes without blocking writes to the table.
pt-online-schema-change D=$DATABASE,t=$TABLE \ --alter "ROW_FORMAT=$ROW_FORMAT CHARACTER SET utf8mb4 COLLATE $COLLATE" \ -uroot --ask-pass --chunk-size=5k --max-flow-ctl 0 --pause-file /tmp/pauseme \ --max-load Threads_running=15 --critical-load Threads_running=100 \ --set-vars innodb_lock_wait_timeout=2 --alter-foreign-keys-method=auto \ --execute
- Only use
--max-flow-ctl 0
if the environment is running Galera. - Run the Active Record migration after the pt-online-schema-change command to mark the migration as done.
If you have any questions regarding code development, please don't hesitate to send an email to [email protected] and we will try to get back to you as soon as possible!
- Home
- Set Up Instructions
- Docker (All platforms)
- Gitpod (Cloud-based development)
- Linux
- OS X
- Creating Development Data
- Writing and Tracking Code
- Automated Testing
- Architecture
-
Getting Started Guide
- Getting Set Up
- Your First Pull Request
- More About Git
- Jira