Adding and Removing Columns in Rails
📖 Scenario: You are working on a Rails app that manages a list of books. You need to update the database to add a new column for the book's genre and later remove the published_year column.
🎯 Goal: Create a Rails migration to add a genre column of type string to the books table, then create another migration to remove the published_year column from the same table.
📋 What You'll Learn
Create a migration file to add a
genre column of type string to the books tableCreate a migration file to remove the
published_year column from the books tableUse the correct Rails migration methods
add_column and remove_columnName the migration classes correctly following Rails conventions
💡 Why This Matters
🌍 Real World
Adding and removing columns is a common task when evolving a Rails app's database to support new features or remove outdated data.
💼 Career
Rails developers frequently write migrations to update database schemas safely and maintain data integrity during app development.
Progress0 / 4 steps