rake db:test:prepare 不创建所有表 [英] 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 似乎工作正常 --
<前>$耙分贝:测试:准备-t(在/home/beau/looked)** 调用 db:test:prepare (first_time)** 调用 db:abort_if_pending_migrations (first_time)** 调用环境(first_time)** 执行环境** 执行 db:abort_if_pending_migrations** 执行 db:test:prepare** 调用 db:test:load (first_time)** 调用 db:test:purge (first_time)** 调用环境** 执行 db:test:purge** 执行 db:test:load** 调用 db:schema:load (first_time)** 调用环境** 执行 db:schema:load注意:CREATE TABLE 将为串行列slugs.id"创建隐式序列slugs_id_seq"注意:CREATE TABLE/PRIMARY KEY 将为表slugs"创建隐式索引slugs_pkey"但是有些表没有被创建.
这些是发展"表:
<前>$ psql -d 看了 -U admin -c '\d'关系列表架构 |姓名 |类型 |所有者--------+-----------+----------+-------公共|企业 |表|行政公共|business_id_seq |序列 |行政公共|类别 |表|行政公共|category_id_seq |序列 |行政公共|schema_migrations |表|行政公共|蛞蝓表|行政公共|slugs_id_seq |序列 |行政(7 行)rake:db:prepare 为测试环境创建的表 --
<前>$ psql -d look_test -U admin -c '\d'关系列表架构 |姓名 |类型 |所有者--------+-----------+----------+-------公共|类别 |表|行政公共|schema_migrations |表|行政公共|蛞蝓表|行政公共|slugs_id_seq |序列 |行政(4 行)如您所见,它创建了一些表,但没有创建businesss_id_seq 或categories_id_seq.
我不知道为什么,有人可以帮助我吗?
首先确保在 rake db:test:prepare
之前运行 rake db:migrate
.>
如果这不起作用,请在某处备份您的 schema.rb
,将其删除,然后在运行 rake db 之前运行
.这将确保您的 rake db:schema:dump
:test:准备schema.rb
文件完全反映您的数据库.
NOTE: Using Rails 3.0.7, Postgresql 8.4.4-1, rake 0.8.7.
Trying to get rails testing working.
The command rake db:test:prepare appears to work fine --
$ 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"
BUT some of the tables are not being created.
These are the "development" tables:
$ 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)
Tables created by rake:db:prepare for the test environment --
$ 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)
As you can see it has created some tables, but not businesses, businesses_id_seq or categories_id_seq.
I'm at a loss as to why, can someone help me?
First make sure to run rake db:migrate
before rake db:test:prepare
.
If that doesn't work, back up your schema.rb
somewhere, remove it, then run rake db:schema:dump
before running rake db:test:prepare
. That will make sure your schema.rb
file fully reflects your database.
这篇关于rake db:test:prepare 不创建所有表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!