> For the complete documentation index, see [llms.txt](https://wiki.christianpoplawski.de/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://wiki.christianpoplawski.de/ruby-on-rails/migrations.md).

# Migrations

## Create a new model

```ruby
  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:

```shell
rails db:rollback STEP=2
```

will roll back the last two migrations
