# Auto migrate test database schema

**URL:** <https://meta.discourse.org/t/auto-migrate-test-database-schema/150786>\
**Category:** Development\
**Created:** [May 8, 2020, 4:27am UTC](https://meta.discourse.org/t/auto-migrate-test-database-schema/150786 "2020-05-08T04:27:56Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![markvanlan](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/markvanlan/32/160087_2.png) [@markvanlan](https://meta.discourse.org/u/markvanlan)\
**Post date:** [May 8, 2020, 1:15pm UTC](https://meta.discourse.org/t/auto-migrate-test-database-schema/150786/2 "2020-05-08T13:15:45Z")

</div>

I applied that diff and dropped by databases then ran  
`bin/rails db:create`  
`bin/rails db:migrate`

then chose a random spec

```bash
▶ bundle exec rspec spec/requests/permalinks_controller_spec.rb 
An error occurred while loading ./spec/requests/permalinks_controller_spec.rb.
Failure/Error: Group.find_by(id: id)

ActiveRecord::StatementInvalid:
  PG::UndefinedTable: ERROR: relation "groups" does not exist
  LINE 8: WHERE a.attrelid = '"groups"'::regclass
                              ^
# ./app/models/group.rb:532:in `lookup_group'
# ./app/models/group.rb:516:in `block in ensure_automatic_groups!'
# ./app/models/group.rb:515:in `each_key'
# ./app/models/group.rb:515:in `ensure_automatic_groups!'
# (eval):3:in `block (2 levels) in run_file'
# ./spec/rails_helper.rb:79:in `<top (required)>'
# ./spec/requests/permalinks_controller_spec.rb:3:in `require'
# ./spec/requests/permalinks_controller_spec.rb:3:in `<top (required)>'
# ------------------
# --- Caused by: ---
# PG::UndefinedTable:
# ERROR: relation "groups" does not exist
# LINE 8: WHERE a.attrelid = '"groups"'::regclass
# ^
# ./app/models/group.rb:532:in `lookup_group'
No examples found.

Finished in 0.00003 seconds (files took 1.6 seconds to load)
0 examples, 0 failures, 1 error occurred outside of examples

```

I never got into `config.before('suite')`

---

_[View the full topic](https://meta.discourse.org/t/auto-migrate-test-database-schema/150786)._
