I tried to update our forum via the web UI (tests-passed
branch) and Activerecord failed due to a DB migration error. There wasn’t a way to rollback, the button didn’t show up.
The error in the Rails console was:
: SELECT "javascript_caches".* FROM "javascript_caches" WHERE "javascript_caches"."theme_id" = 2)
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/rack-mini-profiler-1.0.2/lib/patches/db/pg.rb:69:in `async_exec_params'
Failed to handle exception in exception app middleware : PG::UndefinedColumn: ERROR: column javascript_caches.theme_id does not exist
The migration was failing because of a foreign key violation:
DETAIL: Key (theme_field_id)=(6) is not present in table "theme_fields".
: ALTER TABLE "javascript_caches" ADD CONSTRAINT "fk_rails_ed33506dbd"
FOREIGN KEY ("theme_field_id")
REFERENCES "theme_fields" ("id")
ON DELETE CASCADE
We had to remove the offending row from javascript_caches
for the migration to succeed:
5 | 6 | da39a3ee5e6b4b0d3255bfef95601890afd80709 | | 2018-10-18 10:03:26.069247 | 2018-10-18 10:03:26.069247
Our current version is https://github.com/discourse/discourse/compare/22abad415192b53b899ea6a98b8c7f73c85ca0c1...tests-passed
Our issue in GitLab https://gitlab.com/gitlab-com/gl-infra/infrastructure/issues/6844.