Heroku Drop Table Rails Help

后端 未结 3 1711
眼角桃花
眼角桃花 2021-02-06 07:07

I am using Ruby on Rails and I no longer need my table Order so I deleted it using SQLite manager.. How can I make the table deletion take place in heroku?

3条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-02-06 07:25

    In case you don't want to create a migration to drop table and cant rollback the previous migrations because you don't want to lose the data in the tables created after that migration, you could use following commands on heroku console to drop a table:

    $ heroku console
    Ruby console for heroku-project-name
    >> ActiveRecord::Migration.drop_table(:orders)
    

    Above command will drop the table from your heroku database. You can use other methods like create_table, add_column, add_index etc. in the ActiveRecord::Migration module to manipulate database without creating and running a migration. But be warned that this will leave a mess behind in the schema_migrations table created by Rails for managing migration versions.

    This could only be useful if your application is still under development and you don't want to lose the data you have added on remote staging server on heroku.

提交回复
热议问题