2011-05-03 5 views
7

참고 : Rails 3.0.7, PostgreSQL 8.4.4-1, rake 0.8.7을 사용하십시오.rake db : test : 모든 테이블을 만들지 마십시오.

레일 테스트 작동을 시도 중입니다.

명령 레이크 dB : 시험 : 잘 작동이 나타납니다 준비 -

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

하지만 테이블의 일부는 생성되지 않습니다. DB : 레이크 만든

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

테이블 :

이있는 "개발"테이블 테스트 환경을 준비 -

 
$ 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_id_seq 또는 categories_id_seq는 포함하지 않습니다.

나는 왜, 누군가가 나를 도울 수 있습니까?

+0

스키마 파일의 모양은 무엇입니까? 'RAILS_ROOT/db/schema.rb' –

+0

'schema.rb' 파일은 어떻게 생겼습니까? –

+0

OK 방금 확인한 결과 테이블이 스키마 파일에서 누락되었습니다. –

답변

24

먼저 rake db:test:prepare 앞에 rake db:migrate을 실행하십시오.

그래도 해결되지 않으면 schema.rb을 어딘가에 백업하고 제거한 다음 을 실행 한 다음 rake db:test:prepare을 실행하십시오. 그러면 schema.rb 파일에 데이터베이스가 완전히 반영됩니다.

+0

고마워. 마지막 마이그레이션을 롤백하여 schema.rb 파일을 수정했습니다. 하지만 마이그레이션에 어떤 문제가 있는지 잘 모르겠습니다. 알아낼 수 없다면 다른 질문을하겠습니다. 당신의 도움을 주셔서 감사합니다. –

+0

나를 위해 일했습니다. 감사. 지금 볼 수 있듯이 병합으로 인해 스키마의 일부 변경 사항이 취소되었습니다 .rb 때문에 문제가 발생했습니다. BTW : schema.rb 제거 필요하지 않았습니다. –

관련 문제