【问题标题】:rails + sqlite - Can't remove columns from database due to foreign key issuerails + sqlite - 由于外键问题,无法从数据库中删除列
【发布时间】:2017-12-07 05:48:45
【问题描述】:

我目前无法从数据库中的特定表中删除列。 sqlite3 给我的错误信息是:

FOREIGN KEY 约束失败:DROP TABLE 'table_name'

虽然我不想删除表,但我的迁移是

remove_column :table_name, :column_name

这只是一个字符串数据列,没什么特别的

【问题讨论】:

  • 可能您有一个表将该 column_name 引用为 foreign_key?
  • SQLite 没有 DROP COLUMN 语句,因此必须通过创建不同的表来实现迁移。
  • @CL。说得通。我不知道这个限制,谢谢

标签: ruby-on-rails sqlite


【解决方案1】:

我做了ruby db:migrate:redo 并且成功了。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-06-23
    • 1970-01-01
    • 2021-11-18
    • 2016-08-07
    • 1970-01-01
    • 1970-01-01
    • 2015-08-30
    相关资源
    最近更新 更多