gpt4 book ai didi

ruby-on-rails - PG :Error relation does not exist

转载 作者:行者123 更新时间:2023-11-29 11:37:05 25 4
gpt4 key购买 nike

我正在使用 Rails 3.2.x,同时也在使用 RailsAdmin。

我运行了很多次迁移并多次更改了我的数据库结构。结果,我得到一个 PG:Error 说对于一个实际上不存在的表不存在关系。

这是错误:

ActiveRecord::StatementInvalid at /
PG::Error: ERROR: relation "addresses" does not exist
LINE 5: WHERE a.attrelid = '"addresses"'::regclass
^
: SELECT a.attname, format_type(a.atttypid, a.atttypmod),
pg_get_expr(d.adbin, d.adrelid), a.attnotnull, a.atttypid, a.atttypmod

简而言之,当我转到 /admin 时,我的 development.log 中显示的错误是:

Started GET "/admin" for 127.0.0.1 at 2013-07-04 02:24:07 -0500
Processing by RailsAdmin::MainController#dashboard as HTML
Cart Load (0.5ms) SELECT "carts".* FROM "carts" WHERE "carts"."id" = $1 LIMIT 1 [["id", 5]]
User Load (0.4ms) SELECT "users".* FROM "users" WHERE "users"."id" = 1 LIMIT 1
(0.6ms) SELECT COUNT(*) FROM "roles" INNER JOIN "users_roles" ON "roles"."id" = "users_roles"."role_id" WHERE "users_roles"."user_id" = 1 AND (((roles.name = 'admin') AND (roles.resource_type IS NULL) AND (roles.resource_id IS NULL)))
(0.6ms) SELECT COUNT(*) FROM "roles" INNER JOIN "users_roles" ON "roles"."id" = "users_roles"."role_id" WHERE "users_roles"."user_id" = 1 AND (((roles.name = 'seller') AND (roles.resource_type IS NULL) AND (roles.resource_id IS NULL)))
PG::Error: ERROR: relation "addresses" does not exist
LINE 5: WHERE a.attrelid = '"addresses"'::regclass
^
: SELECT a.attname, format_type(a.atttypid, a.atttypmod),
pg_get_expr(d.adbin, d.adrelid), a.attnotnull, a.atttypid, a.atttypmod
FROM pg_attribute a LEFT JOIN pg_attrdef d
ON a.attrelid = d.adrelid AND a.attnum = d.adnum
WHERE a.attrelid = '"addresses"'::regclass
AND a.attnum > 0 AND NOT a.attisdropped
ORDER BY a.attnum

Completed 500 Internal Server Error in 1269ms

ActiveRecord::StatementInvalid - PG::Error: ERROR: relation "addresses" does not exist
LINE 5: WHERE a.attrelid = '"addresses"'::regclass
^
: SELECT a.attname, format_type(a.atttypid, a.atttypmod),
pg_get_expr(d.adbin, d.adrelid), a.attnotnull, a.atttypid, a.atttypmod
FROM pg_attribute a LEFT JOIN pg_attrdef d
ON a.attrelid = d.adrelid AND a.attnum = d.adnum
WHERE a.attrelid = '"addresses"'::regclass
AND a.attnum > 0 AND NOT a.attisdropped
ORDER BY a.attnum

我该如何解决这个问题?

最佳答案

我的建议是删除并重新创建整个数据库。执行此操作时,您可能会在迁移过程中遇到一些问题 - 修复所有问题,以便全新安装应用程序成为可能。

关于ruby-on-rails - PG :Error relation does not exist,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17464503/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com