相关疑难解决方法(0)

使用Rails迁移删除列将删除与该列关联的索引

在Rails 2中,删除带有Rails迁移的列还会更改/删除与列关联的索引吗?如果没有,而且您还必须手动更改/删除每个索引,那么它是否应该自动化?

谢谢(来自Rails新手)

ruby-on-rails rails-migrations

48
推荐指数
4
解决办法
1万
查看次数

无法从Rails 4和PSQL 9.3中的表中删除索引

在我的schema.rb中,我有以下行:

add_index "users", ["email"], name: "index_users_on_email", unique: true, using: :btree
Run Code Online (Sandbox Code Playgroud)

当我\di在psql中运行时,我得到:

Schema |                             Name                             | Type  | Owner |         Table
--------+--------------------------------------------------------------+-------+-------+-----------------------
 public | index_users_on_email                                         | index | alex  | users
Run Code Online (Sandbox Code Playgroud)

但是,如果我在迁移中包含以下内容之一:

  • remove_index:users,name :: index_users_on_email
  • remove_index:users,column :: email
  • remove_index:users,:email
  • 执行'DROP INDEX index_users_on_email'

我收到以下错误:

rake aborted!
An error has occurred, this and all later migrations canceled:

Index name 'index_users_on_email' on table 'users' does not exist
Run Code Online (Sandbox Code Playgroud)

我也发现了这个问题.那么任何想法?

ruby migration ruby-on-rails database-indexes rails-postgresql

6
推荐指数
2
解决办法
5256
查看次数