Note that there are some explanatory texts on larger screens.

plurals
  1. POrake db:setup db:test:prepare won’t behave as expected
    primarykey
    data
    text
    <p>I have a <code>script/cibuild</code> script, which I run on <a href="https://semaphoreapp.com/" rel="nofollow">Semaphore Hosted CI Service</a>), that contains…</p> <pre><code>time bundle exec rake db:setup db:test:prepare --trace; echo </code></pre> <p>… to setup the database and check if are there any pending migrations, but for some reason this won’t work not even on my development machine.</p> <p>Striping down <code>script/cibuild</code>’s contents boils down to this:</p> <pre><code>export RAILS_ENV=test export RACK_ENV=test # options to rake 'spec' task export SPEC_OPTS='--color --format documentation --backtrace spec' echo "Installing dependencies..." time bundle install --deployment; echo echo "Setting-up database..." time bundle exec rake db:setup db:test:prepare --trace; echo echo "Running tests..." time bundle exec rake spec --trace; echo </code></pre> <p>Build will eventually fail with the following trace on Semaphore:</p> <pre><code>Running tests... ** Invoke spec (first_time) ** Invoke test:prepare (first_time) ** Invoke db:test:prepare (first_time) ** Invoke db:abort_if_pending_migrations (first_time) ** Invoke environment (first_time) ** Execute environment ** Invoke db:load_config (first_time) ** Execute db:load_config ** Execute db:abort_if_pending_migrations You have 10 pending migrations: 20130418144736 CreateUsers 20130424134725 CreateCollections 20130506124127 AddStaffToUsers 20130513115848 CreateResourceTypes 20130513140804 InstallHstore 20130513141924 CreateResources 20130513144332 AddCredentialDataToUsers 20130523155851 RenameSubscriptionDataInResource 20130531110125 AddProfilePictureToUser 20130722101545 AddEmailIndexToUser Run `rake db:migrate` to update your database then try again. </code></pre> <p>Now it seems to me that the problem may not be at <code>db:setup db:test:prepare</code> line, but instead when <code>rake spec</code> is run. I am not sure.</p> <p>In any case if I run in my development machine…</p> <pre><code>rake db:drop:all rake db:setup db:test:prepare </code></pre> <p>… I will end up with an empty test database (“empty” as in no tables, etc.) whereas…</p> <pre><code>rake db:drop:all rake db:setup rake db:test:prepare </code></pre> <p>… will create also test database, as expected.</p> <p>One might think as if I didn’t run <code>rake db:migrate</code> at some point (hence 10 pending migrations), but I am pretty confident that this isn’t the case. Although I don’t have a <code>db/schema.rb</code> file, rails should apply all the migrations to get to the final database schema just fine.</p> <p>Any ideas, please? Thank you.</p> <p><strong>Update:</strong></p> <p>I kind of suspect that the issue might be related to setting <code>RACK_ENV</code> and/or <code>RAILS_ENV</code> environment variables to <code>test</code>. This <em>seems to</em> mess things up a bit.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload