[英]rake db:test:prepare not creating all tables
注意:使用 Rails 3.0.7、Postgresql 8.4.4-1、rake 0.8.7。
試圖讓 Rails 測試工作。
命令 rake db:test:prepare 似乎工作正常——
$ rake db:test:prepare -t (in /home/beau/looked) ** Invoke db:test:prepare (first_time) ** Invoke db:abort_if_pending_migrations (first_time) ** Invoke environment (first_time) ** Execute environment ** Execute db:abort_if_pending_migrations ** Execute db:test:prepare ** Invoke db:test:load (first_time) ** Invoke db:test:purge (first_time) ** Invoke environment ** Execute db:test:purge ** Execute db:test:load ** Invoke db:schema:load (first_time) ** Invoke environment ** Execute db:schema:load NOTICE: CREATE TABLE will create implicit sequence "slugs_id_seq" for serial column "slugs.id" NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "slugs_pkey" for table "slugs"
但是有些表沒有被創建。
這些是“發展”表:
$ psql -d looked -U admin -c '\d' List of relations Schema | Name | Type | Owner --------+-------------------+----------+------- public | businesses | table | admin public | businesses_id_seq | sequence | admin public | categories | table | admin public | categories_id_seq | sequence | admin public | schema_migrations | table | admin public | slugs | table | admin public | slugs_id_seq | sequence | admin (7 rows)
rake:db:prepare 為測試環境創建的表——
$ psql -d looked_test -U admin -c '\d' List of relations Schema | Name | Type | Owner --------+-------------------+----------+------- public | categories | table | admin public | schema_migrations | table | admin public | slugs | table | admin public | slugs_id_seq | sequence | admin (4 rows)
如您所見,它創建了一些表,但沒有創建企業、businesss_id_seq 或 categories_id_seq。
我不知道為什么,有人可以幫助我嗎?
首先確保在rake db:test:prepare
之前運行rake db:migrate
。
如果這不起作用,請在某處備份您的schema.rb
,將其刪除,然后在運行rake db:test:prepare
rake db:schema:dump
。 這將確保您的schema.rb
文件完全反映您的數據庫。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.