Skip to main content
Test Double company logo
Services
Services Overview
Holistic software investment consulting
Software Delivery
Accelerate quality software development
Product Impact
Drive results that matter
Legacy Modernization
Renovate legacy software systems
Pragmatic AI
Solve business problems without hype
Upgrade Rails
Update Rails versions seamlessly
DevOps
Scale infrastructure smoothly
Technical Recruitment
Build tech & product teams
Technical & Product Assessments
Uncover root causes & improvements
Case Studies
Solutions
Accelerate Quality Software
Software Delivery, DevOps, & Product Delivery
Maximize Software Investments
Product Performance, Product Scaling, & Technical Assessments
Future-Proof Innovative Software
Legacy Modernization, Product Transformation, Upgrade Rails, Technical Recruitment
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
Legacy Modernization
Renovate legacy software systems
Pragmatic AI
Solve business problems without hype
Cycle icon
DevOps
Scale infrastructure smoothly
Upgrade Rails
Update Rails versions seamlessly
Technical Recruitment
Build tech & product teams
Technical & Product Assessments
Uncover root causes & improvements
Case Studies
Solutions
Solutions
Accelerate Quality Software
Software Delivery, DevOps, & Product Delivery
Maximize Software Investments
Product Performance, Product Scaling, & Technical Assessments
Future-Proof Innovative Software
Legacy Modernization, Product Transformation, Upgrade Rails, Technical Recruitment
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
Pydantically perfect: Declare rich validation rules

Learn how to validate datatypes that go beyond Python’s primitives with Pydantic. The post covers different validators included with Pydantic as well as how to write your own custom validators.

by
Gabriel Côté-Carrier
by
Kyle Adams
Leadership
Leadership
Leadership
Why product operating model transformations stall—and what to do first

Transitioning to a product operating model? Codify your culture first. Principles and trade-offs create the decision-making framework that makes transformation stick. We cannot change what we do not name.

by
Michael Toland
Developers
Developers
Developers
Anyone can code: Software Is having Its Ratatouille moment

Gusteau said it best: "anyone can cook", and now, "anyone can code." LLMs and agentic coding are the Remy to our Linguini. Our job isn't to guard the kitchen—it's to help others cook something worth serving.

by
Dave Mosher
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 Policy
© 2020 Test Double. All Rights Reserved.