megahra
megahra

Reputation: 335

Rails - Table still in schema.rb after rails destroy scaffold and drop_table migration

I'm trying to remove an old model etc., that I had created by scaffolding several migrations past. So I followed the advice in this thread and ran a drop_table migration and the rails d scaffold Modelname command (maybe I did that first, not sure anymore).

As far as I can tell that removed the table and all the other files that had been created by the scaffolding, but my issue is that the schema.rb still includes the table! I've read here that I could probably fix this issue by running rails db:drop db:create db:migrate, but I was wondering if there is a way to fix schema.rb without resetting the database completely? (Unfortunately I started populating my db by console while I was adding parts to my app instead of writing a proper seed file.)

Upvotes: 0

Views: 1077

Answers (1)

widjajayd
widjajayd

Reputation: 6253

you can drop the table from rails console, for example the model is user then your table will be users

$rails console

Then just type:

ActiveRecord::Migration.drop_table(:users)

Additional answer for user problem:

to update table schema in schema.rb you can use

$ rake db:schema:dump

Upvotes: 1

Related Questions