LibraryActive

Active Record Basics

Active Record Basics: Ruby on Rails Guides (v8.1.3.1) These are the new guides for Rails 8.1 based on v8.1.3.1 .

Open source page

Field note

What it does

Active Record Migrations Migrations are a feature of Active Record that allows you to evolve your database schema over time. Rather than write schema modifications in pure SQL, migrations allow you to use a Ruby Domain Specific Language (DSL) to describe changes to your tables. After reading this guide, you will know: Which generators you can use to create migrations. Which methods Active Record provides to manipulate your database. How to change existing migrations and update your schema. How migrations relate to schema.rb . How to maintain referential integrity. Skip to article body Chapters Migration Overview Generating Migration Files Creating a Standalone Migration Creating a New Table Adding Columns Removing Columns Creating Associations Other Generators that Create Migrations Passing Modifiers Updating Migrations Creating a Table Creating a Join Table Changing Tables Changing Columns Column Modifiers References Foreign Keys Composite Primary Keys Execute SQL Using the change Method Using reversible Using the up / down Methods Throwing an error to prevent reverts Reverting Previous Migrations Running Migrations Rolling Back Setting Up the Database Preparing the Database Resetting the Database Running Specific Migrations Running Migrations in Different Environments Changing the Output of Running Migrations Rails Migration Version Control Changing Existing Migrations Schema Dumping and You What are Schema Files for?

Capabilities

Available capabilities

Tags

Tags

No tags filed yet.

Ways to use it

Ways to use it

No integrations filed yet.

Product features

Product features

1. Migration Overview

2.1. Creating a Standalone Migration

2.2. Creating a New Table

2.3. Adding Columns

2.4. Removing Columns

2.5. Creating Associations

2.6. Other Generators that Create Migrations

2.7. Passing Modifiers

2. Generating Migration Files

3. Updating Migrations

Active Record Migrations

Chapters