I created 2 models and ran the migrations, attempted some work on each of them and now I would like to start over and approach them differently. I'm new to Rails and have never attempted to delete/remove database tables (apart from rolling them back right after I migrated them).
Thanks!
To drop a table during a migration, you can rails g migration DropUsers
class DropUsers < ActiveRecord::Migration
def up
drop_table :users
end
def down
# recreate table logic here
end
end
You can also drop tables from the Rails console
ActiveRecord::Migration.drop_table(:users)
FYI If you want to remove scaffold-created code, rails destroy scaffold User
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With