After a while, that made sense. I even wrote a spec, but even before I added my spec (and when I reverted to before I added any code), specs fail because:
An error occurred while loading ./plugins/discourse-prometheus/spec/middleware/metrics_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
^
# (eval):24:in `async_exec'
# (eval):24:in `async_exec'
# ./app/models/group.rb:529:in `lookup_group'
# ./app/models/group.rb:513:in `block in ensure_automatic_groups!'
# ./app/models/group.rb:512:in `each_key'
# ./app/models/group.rb:512:in `ensure_automatic_groups!'
# (eval):3:in `block (2 levels) in run_file'
# ./spec/rails_helper.rb:79:in `<top (required)>'
# ./plugins/discourse-prometheus/spec/middleware/metrics_spec.rb:3:in `require'
# ./plugins/discourse-prometheus/spec/middleware/metrics_spec.rb:3:in `<top (required)>'
# ------------------
# --- Caused by: ---
# PG::UndefinedTable:
# ERROR: relation "groups" does not exist
# LINE 8: WHERE a.attrelid = '"groups"'::regclass
# ^
# (eval):24:in `async_exec'
No examples found.
That seems to hit for nearly every spec in the site. I think that I properly did git reset --hard upstream/master to get to what should be working and then deleted and re-created the database but I’m still getting that error.
I didn’t do anything with groups (group doesn’t appear on my plugin) and those specs fail all over discourse. I’ll do one more clone of the master to see if somehow my fork. Thanks again!
Make double sure you put RAILS_ENV=test, otherwise you’ll accidentally delete your development database (I managed to do that by accident this week )
Maybe that’s my problem! Maybe I dropped development and not test. Thanks. Ooh, and I need to install a fresh development environment in my laptop before I head to the airport.
Thanks, David! I saw that it prints a warning now. I don’t quite understand why it was so difficult to get the test database migrated, but after I did a bunch of destroy,create,migrate and then the RAILS_ENV=test bin/rake db:migrate you recommended, I managed to see that my spec is broken! Now, I can fix it and I’m on my way to learning how to write specs! Thanks again for your push, @Mittineague.
Has that been fixed? It looks like a ./bin/rake db:drop db:create drops and creates the test database, but it seems that ./bin/rake db:migrate doesn’t also do the migrations on test.