我試圖刪除並重置我的數據庫在開發中:rake db:drop db:create db:migrate
並且由於某種原因它沒有工作。現在,當我試圖運行命令,我得到:Rails無法重置開發數據庫
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
,但無濟於事。
我在這一個完全停滯。任何人都知道如何重置數據庫並重新遷移?
加入此聊天http://chat.stackoverflow.com/rooms/34391/http-stackoverflow-com-questions-17929808-rails-unable-to-reset-development-dat – rmagnum2002