원클릭으로
rails-migrations
Database migration patterns, reversible migrations, indexes, and conventions for this Rails codebase
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
메뉴
Database migration patterns, reversible migrations, indexes, and conventions for this Rails codebase
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
SOC 직업 분류 기준
Create, execute, update, and complete implementation plans and trackers following Linkvan API conventions
Standardized Ruby gem update workflow with version checking, breaking change analysis, security advisory detection, and testing
Controller patterns, service delegation, strong parameters, and HTTP conventions for this Rails codebase
RuboCop metrics, Brakeman security, code style conventions, and quality checks for this Rails codebase
ActiveRecord model patterns, validations, scopes, and conventions for this Rails codebase
RSpec testing patterns, conventions, and test commands for this Rails codebase
| name | rails-migrations |
| description | Database migration patterns, reversible migrations, indexes, and conventions for this Rails codebase |
rails db:create db:migrate db:seed db:reset rails console
rails db:migrate:status # Check migration status
rails db:rollback # Rollback last migration
rails db:migrate:redo # Rollback and re-run
db/migrate/ directoryYYYYMMDDHHMMSS_migration_name.rbadd_email_to_users.rbchange method instead of up/down when possible:
class AddEmailToUsers < ActiveRecord::Migration[8.0]
def change
add_column :users, :email, :string
end
end
rails generate migration AddFieldToTable field:type
rails generate migration RemoveFieldFromTable field:type
rails generate migration CreateTableName field1:type field2:type
def change
add_column :users, :email, :string, null: false
end
def change
remove_column :users, :email, :string
end
def change
add_index :users, :email, unique: true
end
def change
add_reference :bookings, :facility, foreign_key: true
end
def change
add_foreign_key :bookings, :facilities
end
def change
create_table :facilities do |t|
t.string :name, null: false
t.text :address
t.timestamps
end
end
change method instead of up/downnull: false and foreign key constraints# Single column index
add_index :users, :email
# Composite index
add_index :bookings, [:user_id, :facility_id]
# Unique index
add_index :users, :email, unique: true
# Index with name
add_index :users, :email, name: 'index_users_on_email_lower'
# Add reference with foreign key
add_reference :bookings, :facility, foreign_key: true
# Add foreign key constraint
add_foreign_key :bookings, :facilities
# Add foreign key with options
add_foreign_key :bookings, :facilities, on_delete: :cascade
Use up/down when change doesn't support the operation:
class ChangeUserEmailFormat < ActiveRecord::Migration[8.0]
def up
execute <<-SQL
UPDATE users SET email = LOWER(email)
SQL
end
def down
# Cannot automatically rollback
raise ActiveRecord::IrreversibleMigration
end
end
rails db:migrate:status to check statusnull: false for required fields