Active Record includes a migration system that allows developers to version-control database schema changes. Migrations are written in Ruby and provide a way to evolve the database schema over time.
The migration files are located in the
db/migrate directory. Migration files are usually generated using the
rails g migration command.
rails g migration CreateUsers name:string age:integer
Generates a file named
class CreateUsers < ActiveRecord::Migration[7.1] def change create_table :users do |t| t.string :name t.integer :age end end end