Skip to main content
Test Double company logo
Services
Pragmatic Services Overview
Holistic software investment consulting
Acccelerate Software Delivery
Balance efficiency and quality
Improve Product Impact
Drive results that matter
Upgrade Rails Seamlessly
Update Ruby and Rails versions
Scale DevOps
Dev experience and infrastructure
Technical Recruitment
Build tech & product teams
Case Studies
Solutions
Legacy Modernization
Renovate legacy software systems
Pragmatic AI
Solve business problems without hype
Technical & Product Assessments
Uncover root causes & improvements
About
About
What's a test double?
Approach
Meeting you where you are
Founder's Story
The origin of our mission
Culture
Culture & Careers
Double Agents decoded
Great Causes
Great code for great causes
EDI
Equity, diversity & inclusion
Insights
All Insights
Hot takes and tips for all things software
Leadership
Bold opinions and insights for tech leaders
Developer
Essential coding tutorials and tools
Product Manager
Practical advice for real-world challenges
Say Hello
Test Double logo
Menu
Services
BackGrid of dots icon
Services Overview
Holistic software investment consulting
Software Delivery
Accelerate quality software development
Product Impact
Drive results that matter
Cycle icon
DevOps
Scale infrastructure smoothly
Upgrade Rails
Update Rails versions seamlessly
Technical Recruitment
Build tech & product teams
Case Studies
Solutions
Solutions
Legacy Modernization
Renovate legacy software systems
Pragmatic AI
Solve business problems without hype
Technical & Product Assessments
Uncover root causes & improvements
About
About
About
What's a test double?
Approach
Meeting you where you are
Founder's Story
The origin of our mission
Culture
Culture
Culture & Careers
Double Agents decoded
Great Causes
Great code for great causes
EDI
Equity, diversity & inclusion
Insights
Insights
All Insights
Hot takes and tips for all things software
Leadership
Bold opinions and insights for tech leaders
Developer
Essential coding tutorials and tools
Product Manager
Practical advice for real-world challenges
Say hello
Developers
Developers
Developers
Software tooling & tips

Simplify your Rails projects with good migrations

Ever wished your Rails projects could handle migrations more smoothly? Meet 'good_migrations'—your new best friend in database management. Add it and forget it!
Justin Searls
|
February 4, 2016
Thank you! Your submission has been received!
Oops! Something went wrong while submitting the form.

We wrote a gem! It’s called good_migrations and we recommend you add it to all of your Ruby on Rails projects and subsequently forget about it.

Just do it. There’s no reason we can see not to blindly copy-paste this command right now:

$ echo "gem 'good_migrations'" >> Gemfile

Need some background first? Okay.

Some background

A little over a year ago, we shared some tips for writing better database migrations in Rails.

In the last section of that post, we explained why it’s important to resist the temptation to reference your app’s ActiveRecord models from your migration code.

Following that advice would require vigilance on the part of the developer and their team to steer clear of this potential hazard. And, while standing vigilant has its virtues when truly necessary, it’s generally better to leverage automation when possible to reduce the number of things we need to actively worry about while we work.

So after Aaron Patterson shared a gist of one approach to monkey-patch and disable the ActiveSupport auto-loader while migrations were running, we jumped at the opportunity to wrap a well-tested gem around it.

If you have the good_migrations gem in your Gemfile, your migrations will raise an error whenever the Rails auto-loader attempts to load a Ruby file from your project’s app/ directory, do its best to explain why this is almost certainly a problem, and then forward you to the GitHub README for more details. There’s no API or configuration to worry about, and if you really really need to load a file from app/ you can always (gasp) require it explicitly.

By adding this gem to your Rails projects as a preventative measure, you’ll be guarding yourself from one of the most obscure and hard-to-debug classes of errors on Rails projects. What’s not to like?

Related Insights

🔗
How to keep your Rails migrations healthy

Explore our insights

See all insights
Developers
Developers
Developers
What it takes to keep humans in the lead with AI

Teams actually shipping AI products build a system that keeps agents honest with humans in charge.

by
Dave Mosher
Developers
Developers
Developers
Introducing Han: A research, plan, and implement plugin, without the rails

There are a lot of good ways to bring research, planning, and implementation structure to AI coding tools. Han is built for people who would rather pick their own path than ride someone else's track.

by
River Lynn Bailey
Product managers
Product managers
Product managers
Great company cultures hold people accountable

Principles without consequences are aspirations. Here's the framework for turning codified culture into real behavioral change.

by
Michael Toland
Letter art spelling out NEAT

Join the conversation

Technology is a means to an end: answers to very human questions. That’s why we created a community for developers and product managers.

Explore the community
Test Double Executive Leadership Team

Learn about our team

Like what we have to say about building great software and great teams?

Get to know us
Test Double company logo
Improving the way the world builds software.
What we do
Services OverviewSoftware DeliveryProduct StrategyLegacy ModernizationPragmatic AIDevOpsUpgrade RailsTechnical RecruitmentAssessments
Who WE ARE
About UsCulture & CareersGreat CausesEDIOur TeamContact UsNews & AwardsN.E.A.T.
Resources
Case StudiesAll InsightsLeadership InsightsDeveloper InsightsProduct InsightsPairing & Office Hours
NEWSLETTER
Sign up hear about our latest innovations.
Your email has been added!
Oops! Something went wrong while submitting the form.
Standard Ruby badge
614.349.4279hello@testdouble.com
Privacy PolicyTerms & Conditions
© 2020 Test Double. All Rights Reserved.