我正在使用Ruby on Rails,我不再需要我的表管理器,所以我使用SQLite Order删除了它。如何在heroku中进行表删除?
编辑我收到错误
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发布于 2011-09-03 23:14:32
如果您不想创建一个drop table的迁移,并且因为不想丢失迁移后创建的表中的数据而无法回滚之前的迁移,您可以在heroku控制台上使用以下命令来删除表:
$ 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表中留下一团糟。
只有当您的应用程序仍在开发中,并且您不想丢失在heroku上的远程临时服务器上添加的数据时,这才是有用的。
发布于 2012-10-24 17:48:03
执行下面的command.Here 'abc‘是应用程序名称
heroku run console --app abc然后使用,
ActiveRecord::Migration.drop_table(:orders)它将删除表'order‘。
发布于 2011-08-06 12:50:58
只需像这样创建一个迁移:
def self.up
drop_table :orders
end
def self.down
# whatever you need to recreate the table or
# raise IrreversibleMigration
# if you want this to be irreversible.
end然后在下一次推送更改时执行heroku rake db:migrate。
您可能希望在SQLite中重新创建表,以便也可以在本地运行此迁移。
https://stackoverflow.com/questions/6964824
复制相似问题