# UndefinedTable: ERROR: relation "web\_hook\_event\_types" when trying to run rspec test

**URL:** https://meta.discourse.org/t/undefinedtable-error-relation-web-hook-event-types-when-trying-to-run-rspec-test/50497
**Category:** Development
**Created:** [9월 22, 2016, 4:03오후 UTC](https://meta.discourse.org/t/undefinedtable-error-relation-web-hook-event-types-when-trying-to-run-rspec-test/50497 "2016-09-22T16:03:46Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![pmusaraj](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pmusaraj/32/119489_2.png) [@pmusaraj](https://meta.discourse.org/u/pmusaraj)
#### Post date: [9월 22, 2016, 4:03오후 UTC](https://meta.discourse.org/t/undefinedtable-error-relation-web-hook-event-types-when-trying-to-run-rspec-test/50497/1 "2016-09-22T16:03:46Z")

</div>

On my dev environment, on Mac, after running this:  
`bundle exec rspec spec/components/new_post_manager_spec.rb`  
which results in an error

```
bundler: failed to load command: rspec (/usr/local/bin/rspec)
ActiveRecord::StatementInvalid: PG::UndefinedTable: ERROR: relation "web_hook_event_types" does not exist
LINE 5: WHERE a.attrelid = '"web_hook_event_types"'::...
                                          ^
: 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 = '"web_hook_event_types"'::regclass
                 AND a.attnum > 0 AND NOT a.attisdropped
               ORDER BY a.attnum

  /usr/local/lib/ruby/gems/2.3.0/gems/activerecord-4.2.7.1/lib/active_record/connection_adapters/postgresql_adapter.rb:592:in `async_exec'
  /usr/local/lib/ruby/gems/2.3.0/gems/activerecord-4.2.7.1/lib/active_record/connection_adapters/postgresql_adapter.rb:592:in `block in exec_no_cache'
  /usr/local/lib/ruby/gems/2.3.0/gems/activerecord-4.2.7.1/lib/active_record/connection_adapters/abstract_adapter.rb:484:in `block in log'
  /usr/local/lib/ruby/gems/2.3.0/gems/activesupport-4.2.7.1/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
  /usr/local/lib/ruby/gems/2.3.0/gems/activerecord-4.2.7.1/lib/active_record/connection_adapters/abstract_adapter.rb:478:in `log'
  /usr/local/lib/ruby/gems/2.3.0/gems/activerecord-4.2.7.1/lib/active_record/connection_adapters/postgresql_adapter.rb:592:in `exec_no_cache'
  /usr/local/lib/ruby/gems/2.3.0/gems/activerecord-4.2.7.1/lib/active_record/connection_adapters/postgresql_adapter.rb:584:in `execute_and_clear'
  /usr/local/lib/ruby/gems/2.3.0/gems/activerecord-4.2.7.1/lib/active_record/connection_adapters/postgresql/database_statements.rb:160:in `exec_query'
  /usr/local/lib/ruby/gems/2.3.0/gems/activerecord-4.2.7.1/lib/active_record/connection_adapters/postgresql_adapter.rb:733:in `column_definitions'
  /usr/local/lib/ruby/gems/2.3.0/gems/activerecord-4.2.7.1/lib/active_record/connection_adapters/postgresql/schema_statements.rb:197:in `columns'
  /usr/local/lib/ruby/gems/2.3.0/gems/activerecord-4.2.7.1/lib/active_record/connection_adapters/schema_cache.rb:43:in `columns'
  /usr/local/lib/ruby/gems/2.3.0/gems/activerecord-4.2.7.1/lib/active_record/attributes.rb:93:in `columns'
  /usr/local/lib/ruby/gems/2.3.0/gems/activerecord-4.2.7.1/lib/active_record/attributes.rb:98:in `columns_hash'
  /usr/local/lib/ruby/gems/2.3.0/gems/activerecord-4.2.7.1/lib/active_record/relation/query_methods.rb:969:in `block in create_binds'
  /usr/local/lib/ruby/gems/2.3.0/gems/activerecord-4.2.7.1/lib/active_record/relation/query_methods.rb:967:in `each'
  /usr/local/lib/ruby/gems/2.3.0/gems/activerecord-4.2.7.1/lib/active_record/relation/query_methods.rb:967:in `partition'
  /usr/local/lib/ruby/gems/2.3.0/gems/activerecord-4.2.7.1/lib/active_record/relation/query_methods.rb:967:in `create_binds'
  /usr/local/lib/ruby/gems/2.3.0/gems/activerecord-4.2.7.1/lib/active_record/relation/query_methods.rb:954:in `build_where'
  /usr/local/lib/ruby/gems/2.3.0/gems/activerecord-4.2.7.1/lib/active_record/relation/query_methods.rb:584:in `where!'
  /usr/local/lib/ruby/gems/2.3.0/gems/activerecord-4.2.7.1/lib/active_record/relation/query_methods.rb:574:in `where'
  /usr/local/lib/ruby/gems/2.3.0/gems/activerecord-4.2.7.1/lib/active_record/relation/finder_methods.rb:84:in `find_by'
  /usr/local/lib/ruby/gems/2.3.0/gems/activerecord-4.2.7.1/lib/active_record/querying.rb:7:in `find_by'
  /usr/local/lib/ruby/gems/2.3.0/gems/activerecord-4.2.7.1/lib/active_record/core.rb:164:in `find_by'
  /Users/pmusaraj/Projects/discourse/spec/fabricators/web_hook_fabricator.rb:9:in `block in <top (required)>'
  /usr/local/lib/ruby/gems/2.3.0/gems/fabrication-2.9.8/lib/fabrication/schematic/evaluator.rb:5:in `instance_eval'
  /usr/local/lib/ruby/gems/2.3.0/gems/fabrication-2.9.8/lib/fabrication/schematic/evaluator.rb:5:in `process'
  /usr/local/lib/ruby/gems/2.3.0/gems/fabrication-2.9.8/lib/fabrication/schematic/definition.rb:18:in `process_block'
  /usr/local/lib/ruby/gems/2.3.0/gems/fabrication-2.9.8/lib/fabrication/schematic/definition.rb:14:in `initialize'
  /usr/local/lib/ruby/gems/2.3.0/gems/fabrication-2.9.8/lib/fabrication/schematic/manager.rb:69:in `new'
  /usr/local/lib/ruby/gems/2.3.0/gems/fabrication-2.9.8/lib/fabrication/schematic/manager.rb:69:in `schematic_for'
  /usr/local/lib/ruby/gems/2.3.0/gems/fabrication-2.9.8/lib/fabrication/schematic/manager.rb:49:in `store'
  /usr/local/lib/ruby/gems/2.3.0/gems/fabrication-2.9.8/lib/fabrication/schematic/manager.rb:27:in `register'
  /usr/local/lib/ruby/gems/2.3.0/gems/fabrication-2.9.8/lib/fabrication.rb:58:in `Fabricator'
  /Users/pmusaraj/Projects/discourse/spec/fabricators/web_hook_fabricator.rb:1:in `<top (required)>'
  /usr/local/lib/ruby/gems/2.3.0/gems/activesupport-4.2.7.1/lib/active_support/dependencies.rb:274:in `require'
  /usr/local/lib/ruby/gems/2.3.0/gems/activesupport-4.2.7.1/lib/active_support/dependencies.rb:274:in `block in require'
  /usr/local/lib/ruby/gems/2.3.0/gems/activesupport-4.2.7.1/lib/active_support/dependencies.rb:240:in `load_dependency'
  /usr/local/lib/ruby/gems/2.3.0/gems/activesupport-4.2.7.1/lib/active_support/dependencies.rb:274:in `require'
  /Users/pmusaraj/Projects/discourse/spec/rails_helper.rb:32:in `block (2 levels) in <top (required)>'
  /Users/pmusaraj/Projects/discourse/spec/rails_helper.rb:32:in `each'
  /Users/pmusaraj/Projects/discourse/spec/rails_helper.rb:32:in `block in <top (required)>'
  /usr/local/lib/ruby/gems/2.3.0/gems/spork-1.0.0rc4/lib/spork.rb:24:in `prefork'
  /Users/pmusaraj/Projects/discourse/spec/rails_helper.rb:15:in `<top (required)>'
  /Users/pmusaraj/Projects/discourse/spec/components/new_post_manager_spec.rb:1:in `require'
  /Users/pmusaraj/Projects/discourse/spec/components/new_post_manager_spec.rb:1:in `<top (required)>'
  /usr/local/lib/ruby/gems/2.3.0/gems/rspec-core-3.4.4/lib/rspec/core/configuration.rb:1361:in `load'
  /usr/local/lib/ruby/gems/2.3.0/gems/rspec-core-3.4.4/lib/rspec/core/configuration.rb:1361:in `block in load_spec_files'
  /usr/local/lib/ruby/gems/2.3.0/gems/rspec-core-3.4.4/lib/rspec/core/configuration.rb:1359:in `each'
  /usr/local/lib/ruby/gems/2.3.0/gems/rspec-core-3.4.4/lib/rspec/core/configuration.rb:1359:in `load_spec_files'
  /usr/local/lib/ruby/gems/2.3.0/gems/rspec-core-3.4.4/lib/rspec/core/runner.rb:106:in `setup'
  /usr/local/lib/ruby/gems/2.3.0/gems/rspec-core-3.4.4/lib/rspec/core/runner.rb:92:in `run'
  /usr/local/lib/ruby/gems/2.3.0/gems/rspec-core-3.4.4/lib/rspec/core/runner.rb:78:in `run'
  /usr/local/lib/ruby/gems/2.3.0/gems/rspec-core-3.4.4/lib/rspec/core/runner.rb:45:in `invoke'
  /usr/local/lib/ruby/gems/2.3.0/gems/rspec-core-3.4.4/exe/rspec:4:in `<top (required)>'
  /usr/local/bin/rspec:22:in `load'
  /usr/local/bin/rspec:22:in `<top (required)>'

```

I also ran what is suggested [here](https://meta.discourse.org/t/pg-undefinedtable-error-relation-translation-overrides-does-not-exist/42599/2):

> [@PG::UndefinedTable: ERROR: relation "translation\_overrides" does not exist](https://meta.discourse.org/t/pg-undefinedtable-error-relation-translation-overrides-does-not-exist/42599/2):
>
> Is that a dev setup? If so, then run “rake db:drop db:create db:migrate” again.

but that didn’t fix it.

Any ideas?

---

<div class="post-metadata">

### Author: ![eviltrout](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/eviltrout/32/5275_2.png) [@eviltrout](https://meta.discourse.org/u/eviltrout)
#### Post date: [9월 22, 2016, 4:16오후 UTC](https://meta.discourse.org/t/undefinedtable-error-relation-web-hook-event-types-when-trying-to-run-rspec-test/50497/2 "2016-09-22T16:16:39Z")

</div>

You probably have to `RAILS_ENV=test rake db:migrate`

---

<div class="post-metadata">

### Author: ![pmusaraj](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pmusaraj/32/119489_2.png) [@pmusaraj](https://meta.discourse.org/u/pmusaraj)
#### Post date: [9월 22, 2016, 4:23오후 UTC](https://meta.discourse.org/t/undefinedtable-error-relation-web-hook-event-types-when-trying-to-run-rspec-test/50497/3 "2016-09-22T16:23:24Z")

</div>

Did that, it didn’t fix it.

---

<div class="post-metadata">

### Author: ![pmusaraj](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pmusaraj/32/119489_2.png) [@pmusaraj](https://meta.discourse.org/u/pmusaraj)
#### Post date: [9월 22, 2016, 5:48오후 UTC](https://meta.discourse.org/t/undefinedtable-error-relation-web-hook-event-types-when-trying-to-run-rspec-test/50497/4 "2016-09-22T17:48:21Z")

</div>

I deleted the `discourse_test` database, went over steps to recreate the database from the [guide to install on Mac](https://meta.discourse.org/t/beginners-guide-to-install-discourse-on-mac-os-x-for-development/15772) and now it’s fixed.

---

<div class="post-metadata">

### Author: ![zogstrip](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/zogstrip/32/512781_2.png) [@zogstrip](https://meta.discourse.org/u/zogstrip)
#### Post date: [9월 22, 2016, 6:07오후 UTC](https://meta.discourse.org/t/undefinedtable-error-relation-web-hook-event-types-when-trying-to-run-rspec-test/50497/5 "2016-09-22T18:07:09Z")

</div>


