Skip to content

Fix test error "PG::UndefinedTable: ERROR: relation "membership_number_seq" does not exist"

Ashley Engelund edited this page Nov 17, 2017 · 4 revisions

The full error output looks like this:

Failure/Error: self.class.connection.execute("SELECT nextval('membership_number_seq')").getvalue(0,0).to_s
     
     ActiveRecord::StatementInvalid:
       PG::UndefinedTable: ERROR:  relation "membership_number_seq" does not exist
       LINE 1: SELECT nextval('membership_number_seq')

This is typically due to the schema not being up to date in the test DB. To fix:

  1. Update the schema.rb file:

bundle exec rails db:schema:dump

  1. Update the schema in the test DB:

bundle exec rails db:test:prepare

Clone this wiki locally