Skip to content

SYSTEM Cited by 1 source

planetscale_rails gem

What it is

planetscale_rails is PlanetScale's Ruby gem that integrates Rails' ActiveRecord migration workflow with PlanetScale's schema-change lifecycle.

Named in Coutermarsh's 2024 post How PlanetScale makes schema changes as the migration executor used by PlanetScale's internal CI pull-request bot: "We use the planetscale_rails gem to run the migrations."

Role

The gem is the bridge between:

  • Rails' ActiveRecord migration convention — files under db/migrate/*.rb with up/down methods.
  • PlanetScale's deploy-request lifecycle — every schema change runs via an isolated deploy request against a PlanetScale branch.

Without the gem, engineers would need to hand-translate ActiveRecord::Migration DDL into pscale CLI calls. The gem does this automatically, so the existing rake db:migrate mental model continues to work against a PlanetScale target.

Place in the architecture

┌─────────────────────────────────────────────┐
│ Rails app                                   │
│  └── db/migrate/20240101_add_column.rb      │
└─────────────────────────────────────────────┘
               │ (file watched by PR-bot)
┌─────────────────────────────────────────────┐
│ GitHub Actions PR-bot                       │
│  └── detects schema change → invokes…       │
└─────────────────────────────────────────────┘
┌─────────────────────────────────────────────┐
│ planetscale_rails gem                       │
│  └── runs migration against PlanetScale     │
│      branch via API                         │
└─────────────────────────────────────────────┘
┌─────────────────────────────────────────────┐
│ PlanetScale API / pscale CLI                │
│  └── creates deploy request                 │
└─────────────────────────────────────────────┘

Seen in

Scope the source does not cover

  • Gem internals: how it maps ActiveRecord::Migration DDL to pscale calls, which commands it supports, what version compatibility it has with Rails.
  • Whether it handles non-migration schema changes (e.g. ad-hoc ALTER TABLE outside db/migrate/).
  • Its interaction with rails db:schema:load for fresh-database initialisation.
  • Whether non-PlanetScale-customer Rails teams use it against plain MySQL as a safer migration executor.
Last updated · 378 distilled / 1,213 read