db-migration-postgres-mysql

Migrate Ruby on Rails applications from PostgreSQL to MySQL with pgloader and dual-write cutover.

21|2|Updated May 24, 2026
One-click install
npx skills add https://github.com/sandeepmvl/rails-skills --skill db-migration-postgres-mysql
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: db-migration-postgres-mysql
Source: https://github.com/sandeepmvl/rails-skills/tree/main/skills/21-db-migration-postgres-mysql
Command: npx skills add https://github.com/sandeepmvl/rails-skills --skill db-migration-postgres-mysql

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Migrating a Ruby on Rails application from PostgreSQL to MySQL introduces significant risk due to Postgres-specific schema features like JSONB columns, ARRAY data types, partial indexes, and custom sequences, which can break queries, lose functionality, or cause data corruption if not handled correctly during migration.

Core Features & Use Cases

  • Pre-migration schema audit: Catalog all Postgres-specific features in your existing schema to identify required rewrites before migration.
  • Bulk data and schema migration: Use pgloader to transfer schema and data in a single step, with built-in type casting for common Postgres-to-MySQL conversions.
  • Zero-downtime cutover: Implement a dual-write pattern to sync data between Postgres and MySQL during the transition, with verification steps to ensure data consistency before flipping the primary database.
  • Postgres feature rewrite guidance: Get explicit instructions for converting JSONB queries to MySQL JSON functions, replacing ARRAY columns with join tables, and adapting partial indexes to MySQL's generated column syntax. Use case: A Rails team forced to switch to MySQL for compliance or hosting requirements can use this skill to avoid breaking existing application functionality and eliminate downtime during the cutover.

Quick Start

Use the db-migration-postgres-mysql skill to plan and execute a zero-downtime migration of your Rails application's database from PostgreSQL to MySQL, including schema auditing, bulk data transfer, and production cutover.

Frequently Asked Questions about db-migration-postgres-mysql

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I migrate a Rails database from PostgreSQL to MySQL without downtime?

To migrate a Rails database from PostgreSQL to MySQL without downtime, implement a dual-write cutover pattern that syncs data to both databases simultaneously, verify consistency, then flip the primary database connection.

How do I convert PostgreSQL JSONB and ARRAY columns for MySQL compatibility in Rails?

Convert PostgreSQL JSONB and ARRAY columns for MySQL compatibility by rewriting JSONB queries to use MySQL JSON functions and replacing ARRAY columns with join tables during your schema audit.

Can I use pgloader for bulk data transfer from Postgres to MySQL?

You can use pgloader to transfer schema and data from Postgres to MySQL in a single step, utilizing built-in type casting to handle common database conversions automatically during the migration.

What is a pre-migration schema audit for Rails database migrations?

A pre-migration schema audit catalogs all PostgreSQL-specific features in your existing schema, such as JSONB columns, ARRAY data types, and partial indexes, to identify required rewrites before migrating to MySQL.

Does migrating Rails from Postgres to MySQL require changing database gems?

Migrating Rails from Postgres to MySQL requires swapping database gems, specifically replacing the pg gem with mysql2 or trilogy to establish the new active record database connection.

How do I handle PostgreSQL partial indexes when moving to MySQL?

Handle PostgreSQL partial indexes when moving to MySQL by adapting them to MySQL's generated column syntax, enabling you to replicate the conditional indexing behavior required by your Rails application.