1
我試圖爲現有的rails項目設置開發環境,但仍然遇到遷移數據庫的問題。Rails + Postgres db:遷移失敗的數據而不是生成它
這裏的配置/ database.yml中
default: &default
adapter: postgresql
encoding: utf8
pool: 5
timeout: 5000
development:
<<: *default
timeout: 5000
username: postgres
password:
database: myapp_development
# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
test:
<<: *default
database: myapp_test
production:
<<: *default
database: myapp_production
心中已經安裝了 'PG' 寶石(v0.18.3),推出的Postgres並創建了應有的作用。下面是\list
從Postgres的外殼輸出:
postgres=# \list
List of databases
Name | Owner | Encoding | Collate | Ctype | Access privileges
----------------------+----------+----------+-------------+-------------+-----------------------
myapp_development | raul | UTF8 | en_US.UTF-8 | en_US.UTF-8 |
myapp_test | raul | UTF8 | en_US.UTF-8 | en_US.UTF-8 |
postgres | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 |
template0 | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 | =c/postgres +
| | | | | postgres=CTc/postgres
template1 | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 | =c/postgres +
| | | | | postgres=CTc/postgres
(7 rows)
我得到這個錯誤:
$ rake db:migrate
rake aborted!
ActiveRecord::StatementInvalid: PG::UndefinedTable: ERROR: relation "pools" does not exist
LINE 5: WHERE a.attrelid = '"pools"'::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 = '"pools"'::regclass
AND a.attnum > 0 AND NOT a.attisdropped
ORDER BY a.attnum
@muistooshort我已經更新了這個問題。感謝您的反饋意見! –