Tag: ruby on rails web

Modifying Existing Migrations in Ruby

Periodically, you will make mistakes when writing migrations. If you’ve already run a migration, you can’t just edit the migration and run it again: Rails will assume it has already run a migration and will do nothing when you run rails db:migrate. You must rollback the migration (using bin/rails db:rollback, for example), edit the migration, […]

Using reversible in Ruby

A complex migration may involve processes that Active Record does not know how to reverse. You can use reversible to specify what to do when a migration is run and when it needs to be rolled back. For example: class ExampleMigration < ActiveRecord::Migration   def change     create_table :distributors do |t|       t.string :zipcode     […]