High Leverage Rails
Introduction
Introduction to this course
Why use Ruby on Rails
Why use SQLite
Ruby on Rails + SQLite
Powering Your App with SQLite
Creating tables
Timestamps
Column types
Typeof
Ruby types
Creating table introduction
Creating table advanced
Inserting data
Updating data
Upserting data
Reading data
Virtual columns
Enums
Introduction to JSON
Indexing JSON
JSON table functions
Building a Modern Rails Application
Creating a new Rails application
Installing Solid Queue
Installing Solid Cache
Installing Solid Cable
Dockerfile
Application overview
Authentication
Base styles
Registration
Scaffolding posts
Polishing posts
Scaffolding comments
Polishing comments
Polishing models
Polishing controllers
Creating new post
Updating post
Reviewing MVP
Tagging posts
Custom tags
Friendly URLs
Full text search
Deploying & Operating Your App
Backups
Check Litestream locally
Verifying backups
Deployment options
Deploying with Hatchbox
Deployment constraints
Vertical scaling
Database access
Migrations
Locked video

Please purchase the course to watch this video.

Video thumbnail
Deploying & Operating Your App
Migrations

Full Course

$
129
$179
USD, one-time fee
This course came at the perfect time. I’ve recently gotten back into Rails after an 18-year hiatus, and this was a perfect refresher and shows just how much you can accomplish with Rails right out of the box.
Garrett Winder
Garrett Winder

Rails hosting made simple

Deploy apps to servers that you own and control.

Move fast and fix things

Application monitoring that helps developers get it done.

Summary

Scaling a Rails application with SQLite requires careful migration planning due to its limited ALTER TABLE support. Learn how to handle write-intensive migrations, prevent conflicts, and use Active Record effectively to ensure smooth database updates while maintaining performance.

Video Transcript

As we continue to build and evolve our application, it's important to understand how database migrations work differently in SQLite compared to other database engines. There are two key reasons why migrations require special attention when using SQLite.

1. SQLite’s Weaker ALTER TABLE Command

The first major limitation is that SQLite’s ALTER TABLE statement is less powerful compared to databases like PostgreSQL or MySQL. You cannot modify tables as flexibly with a simple ALTER TABLE command.

That said, because we are using Rails, Active Record's migration management system handles much of this complexity for us. Rails follows the recommended 12-step process for making database updates, which helps smooth over SQLite’s limitations.

While SQLite’s ALTER TABLE may feel restrictive, when you rely on an ORM like Active Record, you likely won’t notice this limitation in most cases.

2. Write-Intensive Migrations Cause Contention

The second limitation is more critical to be aware of—write-intensive migrations can cause contention with regular application activity.

Why?

  • SQLite only supports one write operation at a time
  • If a migration is writing to the database, it blocks all other write operations
  • This means that your users may experience delays if they try to write data while a migration is running

Since migrations are programmatically executed, they almost always override user activity, winning the race for write access.

If you have a large data migration (such as backfilling data from one table to another), it’s best to schedule downtime to prevent disruptions and ensure a smooth user experience.

The Solution: Embrace Scheduled Downtime

One of the simplest ways to handle migrations in SQLite is to embrace scheduled downtime when necessary.

  • Downtime simplifies complexity by ensuring that migrations don’t interfere with live user activity
  • Hatchbox and similar platforms offer built-in maintenance mode, making downtime management easier
  • Avoiding write-heavy migrations when possible helps prevent unnecessary issues