Knowledge
  • ⚡️ Knowledge
  • Talks I like
  • Thinking
  • Unix
  • CSS
    • CSS
  • Git
    • git
  • business
    • concepts
  • databases
    • PostgreSQL
  • dev-ops
    • Docker
    • heroku
  • javascript
    • javascript
    • Jest
    • Readme
      • General
      • Libraries
        • React_DnD
  • npm
    • npm cheatsheet
  • people
    • Active Listening
  • productivity
    • focus
    • reviews
  • reading-log
    • 12 Rules for Life
    • nonfiction
  • ruby-on-rails
    • Active Storage
    • bundler
    • file-io
    • Migrations
    • patterns
    • rake-tasks
    • views
  • stoicism
    • Notes
  • food-drink
    • coffee
      • Coffee Beans
  • tools
    • macOS
      • Things
    • services
      • Trello
Powered by GitBook
On this page
  • Create a new model
  • Rollback multiple steps
  1. ruby-on-rails

Migrations

Create a new model

  class CreateMyModel < ActiveRecord::Migration[6.1]
    def change
      create_table :my_table do |t|
        t.string :name
      end
    end
  end

Rollback multiple steps

Can be achieved using the STEP variable:

rails db:rollback STEP=2

will roll back the last two migrations

Previousfile-ioNextpatterns

Last updated 3 years ago