mercredi 14 septembre 2016

Rails 4.2 test database

How do I get me test database schema to match my development? I tried running a test and get error:

 1) Error:
EntriesControllerTest#test_should_get_index:
ActiveRecord::StatementInvalid: PG::UndefinedTable: ERROR:  relation "entries" does not exist
LINE 5:                WHERE a.attrelid = '"entries"'::regclass
                                          ^
:               SELECT a.attname, format_type(a.atttypid, a.atttypmod),
                     pg_get_expr(d.adbin, d.adrelid), a.attnotnull, a.atttypid, a.atttypmod
                FROM pg_attribute a LEFT JOIN pg_attrdef d
                  ON a.attrelid = d.adrelid AND a.attnum = d.adnum
               WHERE a.attrelid = '"entries"'::regclass
                 AND a.attnum > 0 AND NOT a.attisdropped
               ORDER BY a.attnum
    app/controllers/entries_controller.rb:34:in `index'
    test/controllers/entries_controller_test.rb:13:in `block in <class:EntriesControllerTest>'
1 runs, 0 assertions, 0 failures, 1 errors, 0 skips

I noticed after some monkeying around I am missing the 'entries' table on test. Not sure if its related but I cannot seem to make my test db match my dev schema

test db is a remote heroku postgres so it seems difficult to rebuild it. For example:

➜  adshow git:(master) ✗ bundle exec rake db:drop RAILS_ENV=test 

FATAL:  permission denied for database "postgres"
DETAIL:  User does not have CONNECT privilege.

Aucun commentaire:

Enregistrer un commentaire