Heroku Drop Table Rails帮助 [英] Heroku Drop Table Rails Help

查看:177
本文介绍了Heroku Drop Table Rails帮助的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用Ruby on Rails,我不再需要我的表 Order 所以我删除它使用SQLite管理器..我如何使表删除发生在heroku ?

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?

EDIT
我收到错误

EDIT I am getting the error

db/migrate/20110806052256_droptableorders.rb:10: syntax error, unexpected keyword_end, expecting $end

运行命令

class DropTableOrder < ActiveRecord::Migration
  self.up
      drop_table :orders
  end

  self.down
      raise IrreversibleMigration
  end
end


推荐答案

如果您不想创建迁移删除表并且无法回滚先前的迁移,因为您不想丢失在迁移后创建的表中的数据,您可以在heroku控制台上使用以下命令删除表:

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)

上述命令将从heroku数据库中删除表。您可以在ActiveRecord :: Migration模块中使用其他方法(如create_table,add_column,add_index等)来操作数据库,而不创建和运行迁移。但是请注意,这将留在Rails为管理迁移版本所创建的schema_migrations表中。

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.

这只有在您的应用程序仍在开发中才有用,您不希望丢失在heroku上的远程登台服务器上添加的数据。

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.

这篇关于Heroku Drop Table Rails帮助的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆