2012-05-14 12 views
13

Sto provando a creare il mio progetto Ruby on Rails da github su Travis-CI, ma sto incontrando un problema di migrazione. Esegue un'attività di rake per la migrazione, ma si lamenta della stessa fase di migrazione.rake db: migrazione non funzionante su travis-ci build

Ne consegue mio file .travis.yml:

language: ruby 
rvm: 
    - 1.9.2 
before_script: 
    - "rake db:migrate RAILS_ENV=test" 

Ed ecco l'output di compilazione:

1Using worker: ruby4.worker.travis-ci.org:travis-ruby-3 
2 
3 
4 
5$ cd ~/builds 
6 
7 
8$ git clone --depth=100 --quiet git://github.com/rafaelportela/bacilo.git rafaelportela/bacilo 
9 
10 
11 
12$ cd rafaelportela/bacilo 
13 
14$ git checkout -qf 7553b7351b7a642e39ea7b55204de6cd4f320c36 
15 
16 
17$ export TRAVIS_RUBY_VERSION=1.9.2 
18 
19$ rvm use 1.9.2 
20Using /home/vagrant/.rvm/gems/ruby-1.9.2-p290 
21 
22$ ruby --version 
23ruby 1.9.2p290 (2011-07-09 revision 32553) [i686-linux] 
24 
25$ gem --version 
261.8.17 
27 
28 
29$ export BUNDLE_GEMFILE=/home/vagrant/builds/rafaelportela/bacilo/Gemfile 
30 
31$ bundle install 
32Fetching gem metadata from https://rubygems.org/....... 
33Using rake (0.9.2.2) 
34Installing i18n (0.6.0) 
35Installing multi_json (1.3.4) 
36Installing activesupport (3.2.2) 
37Installing builder (3.0.0) 
38Installing activemodel (3.2.2) 
39Installing erubis (2.7.0) 
40Installing journey (1.0.3) 
41Installing rack (1.4.1) 
42Installing rack-cache (1.2) 
43Installing rack-test (0.6.1) 
44Installing hike (1.2.1) 
45Installing tilt (1.3.3) 
46Installing sprockets (2.1.3) 
47Installing actionpack (3.2.2) 
48Installing mime-types (1.18) 
49Installing polyglot (0.3.3) 
50Installing treetop (1.4.10) 
51Installing mail (2.4.4) 
52Installing actionmailer (3.2.2) 
53Installing arel (3.0.2) 
54Installing tzinfo (0.3.33) 
55Installing activerecord (3.2.2) 
56Installing activeresource (3.2.2) 
57Installing bcrypt-ruby (3.0.1) with native extensions 
58Installing coffee-script-source (1.3.1) 
59Installing execjs (1.3.1) 
60Installing coffee-script (2.2.0) 
61Installing rack-ssl (1.3.2) 
62Installing json (1.7.0) with native extensions 
63Installing rdoc (3.12) 
64Installing thor (0.14.6) 
65Installing railties (3.2.2) 
66Installing coffee-rails (3.2.2) 
67Installing orm_adapter (0.0.7) 
68Installing warden (1.1.1) 
69Installing devise (2.0.4) 
70Installing jquery-rails (2.0.2) 
71Installing pg (0.13.2) with native extensions 
72Using bundler (1.1.3) 
73Installing rails (3.2.2) 
74Installing sass (3.1.16) 
75Installing sass-rails (3.2.5) 
76Installing sqlite3 (1.3.6) with native extensions 
77Installing uglifier (1.2.4) 
78Your bundle is complete! Use `bundle show [gemname]` to see where a bundled gem is installed. 
79Post-install message from rdoc: 
80Depending on your version of ruby, you may need to install ruby rdoc/ri data: 
81 
82<= 1.8.6 : unsupported 
83 = 1.8.7 : gem install rdoc-data; rdoc-data --install 
84 = 1.9.1 : gem install rdoc-data; rdoc-data --install 
85>= 1.9.2 : nothing to do! Yay! 
86 
87 
88$ rake db:migrate RAILS_ENV=test 
89== DeviseCreateUsers: migrating ============================================== 
90-- create_table(:users) 
91 -> 0.0174s 
92-- add_index(:users, :email, {:unique=>true}) 
93 -> 0.0017s 
94-- add_index(:users, :reset_password_token, {:unique=>true}) 
95 -> 0.0010s 
96== DeviseCreateUsers: migrated (0.0239s) ===================================== 
97 
98 
99$ bundle exec rake 
100You have 1 pending migrations: 
101 20120508052346 DeviseCreateUsers 
102Run `rake db:migrate` to update your database then try again. 
103 
104 
105Done. Build script exited with: 1 

Apprezzerei ogni suggerimento! =]

+0

Hi rafael, Immagino che tu stia utilizzando il tuo ambiente di test su un db sqlite3 con l'utilizzo in memoria, giusto? Perché io sto lottando con lo stesso problema combinato di: - ** Travis-CI ** - ** ** SQLite {database: "**: Memoria: **"} sto anche chiedendo , perché questa impostazione è anche raccomandata/data come esempio nel [travis-ci doc] (http://docs.travis-ci.com/user/database-setup/#SQLite3). – loybert

+0

funziona ma potrebbe essere necessario modificarlo in 'bundle exec rake db: migrate RAILS_ENV = test' – equivalent8

risposta

28

mi ha aiutato moltissimo quando stavo cercando di far funzionare la mia app Rails 3.2 con Travis CI e di scrivere un file .travis.yml che funzionava effettivamente. Ecco il mio per il vostro riferimento, quindi spero che aiuta:

.travis.yml

language: ruby 
rvm: 
    - 1.9.2 
    - 1.9.3 
env: 
    - DB=sqlite 
    - DB=mysql 
    - DB=postgresql 
script: 
    - RAILS_ENV=test bundle exec rake db:migrate --trace 
    - bundle exec rake db:test:prepare 
    - bundle exec rspec spec/ 
before_script: 
    - mysql -e 'create database my_app_test' 
    - psql -c 'create database my_app_test' -U postgres 
bundler_args: --binstubs=./bundler_stubs 
+0

Grazie. Come hai gestito il database.yml di travis? e puoi anche postare il contenuto del file bundler_stubs? –

+0

@Pratick, si spera che dovresti ottenere le tue risposte da [questa domanda StackOverflow] (http://stackoverflow.com/q/11156627/567863). –

6

Invece di eseguire rake db:migrate RAILS_ENV=test eseguire rake db:test:prepare invece.

Questo perché rake db:migrate eseguirà tutte le le migrazioni sul database di test, che potrebbe richiedere molto tempo se si eseguono molte migrazioni. L'attività db:test:prepare non lo farà, ma verrà semplicemente impostato il database di test con lo schema da db/schema.rb.

Dai uno sguardo e guarda se funziona.

+1

Questa è generalmente una cattiva idea. Volete che il vostro ambiente di test trovi i problemi che potrebbero verificarsi nella produzione. In produzione, eseguirai le migrazioni, non caricando il tuo schema dal tuo db/schema.rb. Per trovare potenziali problemi con le migrazioni che potrebbero verificarsi durante la produzione, è meglio eseguire 'rake db: migrate' –

0

La soluzione che ha risolto il problema per me era in funzione: rake db:schema:load invece di rake db:migrate RAILS_ENV=test

Problemi correlati