nam1962 / returnsworth

Ruby on Rails app & PWA to manage commerce logistics returns
https://returnsworth-0dc66e0a7879.herokuapp.com/
GNU Affero General Public License v3.0
0 stars 1 forks source link

Remove consumers table #33

Closed nam1962 closed 1 year ago

nam1962 commented 1 year ago
git checkout -b remove-consumers
rails generate migration DropConsumersTable
rails db:migrate
rm app/models/consumer.rb
nam1962 commented 1 year ago

Migration:

class DropConsumersTable < ActiveRecord::Migration[7.0]
  def up
    drop_table :consumers
  end

  def down
    create_table :consumers do |t|
      t.integer :command_number
      t.string :first_name
      t.string :last_name
      t.string :email
      t.string :phone_number
      t.timestamps
    end
  end
end
nam1962 commented 1 year ago

If we need to recreate the table in the future, we can rollback the migration using the following command:

$ rails db:rollback

This will execute the down method, recreating the consumers table with the specified columns