我试图在开发中删除并重置我的数据库:rake db:drop db:create db:migrate
但由于某种原因它没有工作。现在,当我尝试运行该命令时,我得到:
FATAL: database "myapp_development" does not exist
FATAL: database "myapp_test" does not exist
ERROR: relation "posts" does not exist at character 315
STATEMENT: 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 = '"posts"'::regclass
AND a.attnum > 0 AND NOT a.attisdropped
ORDER BY a.attnum
如果我只尝试rake db:create db:migrate
然后我得到错误
myapp_development already exists
myapp_test already exists
ERROR: relation "posts" does not exist at character 315...
如果我只运行,rake db:migrate
那么我只会得到错误的最后一部分:
PG::Error: ERROR: relation "posts" does not exist
LINE 5: WHERE a.attrelid = '"posts"'::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 = '"posts"'::regclass
AND a.attnum > 0 AND NOT a.attisdropped
ORDER BY a.attnum
我尝试重新启动我的数据库:pg_ctl stop -D /usr/local/var/postgres
pg_ctl start -D /usr/local/var/postgres
,但无济于事。
我在这个完全停滞不前。有人知道如何重置数据库并重新迁移吗?