forked from thesuss/shf-project
-
Notifications
You must be signed in to change notification settings - Fork 37
Fix test error "PG::UndefinedTable: ERROR: relation "membership_number_seq" does not exist"
Ashley Engelund edited this page May 20, 2019
·
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 can happen if the database is not being loaded from db/structure.sql
Ensure that both your development and test environments are dumping and loading structure.sql instead of using schema.rb.
You do that by setting config.active_record.schema_format = :sql
in your environment config files:
- config/environments/development.rb
- config/environments/test.rb
The default for config.active_record.schema_format
is :ruby
which will use schema.db for db dump
and db load.
Here's a detailed UML activity diagram (flowchart) that shows what happens during db:test:prepare
. This diagram starts with the SHF task db_prep
which eventually calls db:test:prepare