[Rails / ActiveRecord :: Migration] Creating migrations for deletion `rails g migration DropUsers`

After creating the migration file for deletion,

$ rails g migration DropUsers

I couldn't find the official one, but it would be nice to edit it in such a way that it can be rolled back.

db/migrate/20201214000000_drop_users.rb


class DropUsers < ActiveRecord::Migration
  def change
    drop_table :users do |t|
      t.string :email, null: false

      t.timestamps  #In Rails 5 t.Columns created with timestamps are not needed because they are NOT NULL by default.
    end
  end
end

Recommended Posts

[Rails / ActiveRecord :: Migration] Creating migrations for deletion `rails g migration DropUsers`
Rails migration
[Rails] ActiveRecord
[For beginners] Procedure for creating a controller using rails