我正在使用Rails 3.2.x並使用RailsAdmin。PG:錯誤關係不存在
我已經運行了許多遷移並多次更改了我的數據庫結構。因此,我得到了一個PG:錯誤指出一個關係對於一個不存在的表是不存在的。
這是錯誤:
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
我該如何解決這個問題?
這是在生產環境? –
這是在開發中,但它也可能在生產中發生。 – marcamillion
問題是'地址表'丟失了,但我不知道原因是什麼。正如你所說 - 遷徙是混亂的。 –