加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

ruby-on-rails – rake db:test:准备不创建所有表

发布时间:2020-12-17 04:39:42 所属栏目:百科 来源:网络整理
导读:注意:使用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_migration
注意:使用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:为测试环境做准备 –

$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)

正如您所看到的,它创建了一些表,但没有创建business,business_id_seq或categories_id_seq.

我不知道为什么,有人可以帮助我吗?

解决方法

首先确保在rake db:test:prepare之前运行rake db:migrate.

如果这不起作用,请在某处备份schema.rb,删除它,然后在运行rake db:test:prepare之前运行rake db:schema:dump.这将确保您的schema.rb文件完全反映您的数据库.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读