【发布时间】:2019-10-17 22:04:34
【问题描述】:
我有一个停滞的 Rails 迁移,所以我 ctrl-C 退出它并尝试重新运行它。我收到以下错误:
ActiveRecord::ConcurrentMigrationError:
Cannot run migrations because another migration process is currently running.
我已经尝试过this post 中的解决方案。我运行了以下命令,但没有输出:
richiethomas=# \c re_app_development
psql (9.6.11, server 11.2)
WARNING: psql major version 9.6, server major version 11.
Some psql features might not work.
You are now connected to database "re_app_development" as user "richiethomas".
re_app_development=# SELECT DISTINCT age(now(), query_start) AS age, pg_stat_activity.pid,pg_locks.granted,pg_stat_activity.application_name,pg_stat_activity.backend_start, pg_stat_activity.xact_start, pg_stat_activity.state_change, pg_stat_activity.waiting, pg_stat_activity.state, pg_stat_activity.query_start, left(pg_stat_activity.query, 60)
re_app_development-# FROM pg_stat_activity, pg_locks
re_app_development-# WHERE pg_locks.pid = pg_stat_activity.pid
re_app_development-#
我很困惑为什么没有输出,所以我开始寻找pg_locks 或pg_stat_activity 表。下面是我数据库中的所有表(请注意,我稍微重新排列了表的顺序,将我创建的表分组到底部组,将 Rails 或我的 gem 生成的表分组到第一组):
re_app_development-# \dt
List of relations
Schema | Name | Type | Owner
--------+------------------------+-------+--------------
public | ar_internal_metadata | table | richiethomas
public | flipper_features | table | richiethomas
public | flipper_gates | table | richiethomas
public | schema_migrations | table | richiethomas
public | reports | table | richiethomas
public | users | table | richiethomas
public | categories | table | richiethomas
public | responses | table | richiethomas
public | zip_code_hpis | table | richiethomas
public | zip_codes | table | richiethomas
(13 rows)
如您所见,上述查询中的两个表都丢失了。
我唯一能想到的是,选择数据库时的警告与此处相关:
WARNING: psql major version 9.6, server major version 11.
Some psql features might not work.
我的问题是 - 我在哪里可以找到这些表,以便我可以移除锁定并重新运行我的迁移?
【问题讨论】:
标签: ruby-on-rails postgresql activerecord database-migration