# Breaking up with your MonoRail

DevFeed: [Breaking up with your MonoRail](<https://devfeed.tech/articles/breaking-up-with-your-monorail-15553.md>)

Original publisher: [Read original article](<https://developer.squareup.com/blog/breaking-up-with-your-monorail>)

Author: Square Engineering

Published: 2016-01-13T17:10:00Z

Content type: article

Language: en

Sources: [Square Corner](<https://devfeed.tech/sources/square-corner-blog-medium.md>)

Topics: [Ruby on Rails](<https://devfeed.tech/topics/ruby-on-rails.md>), [software-architecture](<https://devfeed.tech/topics/software-architecture.md>), [Database](<https://devfeed.tech/topics/database.md>), [Test-driven development](<https://devfeed.tech/topics/tdd.md>), [Data serialization](<https://devfeed.tech/topics/data-serialization.md>), [Deployment Strategies](<https://devfeed.tech/topics/deployment-strategies.md>)

Tags: [2013](<https://devfeed.tech/tags/2013.md>), [2014](<https://devfeed.tech/tags/2014.md>), [2015](<https://devfeed.tech/tags/2015.md>), [2016](<https://devfeed.tech/tags/2016.md>), [about](<https://devfeed.tech/tags/about.md>), [abstraction](<https://devfeed.tech/tags/abstraction.md>), [active-record](<https://devfeed.tech/tags/active-record.md>), [activerecord](<https://devfeed.tech/tags/activerecord.md>), [added](<https://devfeed.tech/tags/added.md>), [all](<https://devfeed.tech/tags/all.md>), [also](<https://devfeed.tech/tags/also.md>), [analysis](<https://devfeed.tech/tags/analysis.md>), [android](<https://devfeed.tech/tags/android.md>), [anker](<https://devfeed.tech/tags/anker.md>), [api](<https://devfeed.tech/tags/api.md>), [app](<https://devfeed.tech/tags/app.md>), [engineering](<https://devfeed.tech/tags/engineering.md>), [planning](<https://devfeed.tech/tags/planning.md>), [rails](<https://devfeed.tech/tags/rails.md>), [up](<https://devfeed.tech/tags/up.md>), [with](<https://devfeed.tech/tags/with.md>)

## AI overview

Square extracted payments from its monolithic Rails app into Spot, a MySQL service sharded by merchant key. The team analyzed SQL access patterns with active_record-sql_analyzer, grouped them into seven protobuf APIs, and routed calls through a PaymentApi abstraction. Converters and wrappers let existing call sites use consistent data while the team switched between ActiveRecord and Spot. They finalized the API before migrating callers, ran the test suite with wrapper flags both on and off, and compared wrapper output with Spot data to catch mismatches. Feature flags enabled gradual traffic rollout and rollback. The migration removed about 56,000 lines and completed in January 2016, with reads on Spot for roughly six weeks before local writes were disabled. The article notes that schema divergence, weak API contracts, legacy Register clients, and ActiveResource's flexible HTTP-to-SQL layer complicated auditing. Randomized rollout caused a version-specific regression to appear inconsistently; stable rollout by merchant would have made failures more consistent for fewer merchants.

## Source excerpt

Planning an extraction from a monolithic Rails app.