db-migration-mysql-postgres

Migrate Ruby on Rails applications from MySQL to PostgreSQL with pgloader and zero-downtime cutover.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Migrating a Ruby on Rails application from MySQL to PostgreSQL requires handling type conversions, data transfer, zero-downtime cutover, and query behavior changes correctly to avoid data loss, broken functionality, or service interruption.

Core Features & Use Cases

  • Bulk data migration guidance: Step-by-step instructions for using pgloader to transfer data with correct type casts for TINYINT to BOOLEAN, JSON to JSONB, and datetime to timestamptz, plus handling MySQL-specific edge cases like zero dates.
  • Zero-downtime cutover pattern: Dual-write cutover workflow to migrate production databases without downtime, including verification steps and primary database swap procedures.
  • Schema upgrade best practices: Guidance to leverage Postgres-exclusive features like GIN indexes for JSONB, CHECK constraints for ActiveRecord enums, partial indexes, and ILIKE for case-insensitive queries, instead of just translating MySQL schema verbatim.
  • Use Case: A team running a production Rails e-commerce platform on MySQL can use this skill to migrate to Postgres while avoiding common pitfalls like duplicate key errors from unreset sequences or broken user search queries from case-sensitivity changes.

Quick Start

Use the db-migration-mysql-postgres skill to plan and execute a zero-downtime migration of your Rails application's primary database from MySQL to PostgreSQL, including schema upgrades and pgloader-based data transfer.

Frequently Asked Questions about db-migration-mysql-postgres

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

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

Migrating Rails from MySQL to PostgreSQL without downtime uses a dual-write cutover workflow. This involves writing to both databases simultaneously, transferring bulk data via pgloader, verifying consistency, and swapping the primary database to prevent service interruption.

How does pgloader handle MySQL to PostgreSQL type conversions in a Rails migration?

pgloader handles MySQL to PostgreSQL type conversions by casting TINYINT to BOOLEAN, JSON to JSONB, and datetime to timestamptz. It also manages MySQL-specific edge cases like zero dates to prevent data loss during the bulk transfer process.

Why do I get duplicate key errors after migrating Rails from MySQL to PostgreSQL?

Duplicate key errors after migrating Rails from MySQL to PostgreSQL occur because sequences are not reset post-migration. Resetting PostgreSQL sequences after the pgloader data transfer ensures auto-incrementing primary keys generate correct, non-conflicting values.

How do I fix broken case-insensitive search queries after moving Rails to PostgreSQL?

Broken case-insensitive search queries after moving Rails to PostgreSQL occur because MySQL searches are case-insensitive by default. You can fix this by using the Postgres-native ILIKE operator for case-insensitive matching instead of translating MySQL schema verbatim.

Can I use PostgreSQL CHECK constraints for ActiveRecord enums in Rails?

Yes, you can use PostgreSQL CHECK constraints for ActiveRecord enums in Rails. Upgrading your schema to leverage Postgres-exclusive features like CHECK constraints ensures enum compatibility while enforcing data integrity at the database level.

What are the best practices for upgrading Rails database schema to use PostgreSQL features?

Best practices for upgrading Rails schema to PostgreSQL involve leveraging GIN indexes for JSONB, partial indexes, and ILIKE for case-insensitive queries. This approach optimizes query performance rather than simply translating the MySQL schema verbatim.