가장 많이 묻는 면접 질문과 답변 & 온라인 테스트
면접 준비, 온라인 테스트, 튜토리얼, 라이브 연습을 위한 학습 플랫폼

집중 학습 경로, 모의고사, 면접 준비 콘텐츠로 실력을 키우세요.

WithoutBook은 주제별 면접 질문, 온라인 연습 테스트, 튜토리얼, 비교 가이드를 하나의 반응형 학습 공간으로 제공합니다.

Chapter 6

Migrations, Schema Design, Seeds, Indexes, and the Rails Database Workflow

Learn how Rails evolves databases safely through migrations and how schema design affects correctness and performance.

Inside this chapter

  1. What Migrations Are For
  2. Migration Example
  3. Schema Design Still Matters
  4. Seeds and Environment Setup

Series navigation

Study the chapters in order for the clearest path from Rails beginner concepts to advanced production architecture. Use the previous and next links at the bottom of each page to move through the full tutorial series.

Tutorial Home

Chapter 6

What Migrations Are For

Migrations are version-controlled Ruby files that describe database schema changes over time. They let teams add tables, rename columns, create indexes, and evolve the database in a repeatable way across environments. Good Rails teams treat migrations as part of the application codebase, not as random one-off scripts.

Chapter 6

Migration Example

class CreateBooks < ActiveRecord::Migration[7.1]
  def change
    create_table :books do |t|
      t.string :title, null: false
      t.decimal :price, precision: 10, scale: 2
      t.references :author, foreign_key: true
      t.timestamps
    end

    add_index :books, :title
  end
end
Chapter 6

Schema Design Still Matters

Rails makes database work easier, but it does not replace good data modeling. Students should understand column types, nullability, defaults, uniqueness constraints, foreign keys, indexes, and normalization trade-offs. A poorly designed schema stays painful no matter how elegant the Rails code looks.

Chapter 6

Seeds and Environment Setup

Author.create!(name: "Mira Sen")
Book.create!(title: "Rails in Practice", price: 599, author: Author.first)

Seed data is useful for onboarding, demos, and local development. Advanced teams keep seeds intentional and separate large production-like data generation from basic developer setup data.

Copyright © 2026, WithoutBook.