A user encountered a multisite upgrade failure due to a missing database column (uploaded_background_id) during asset compilation. The issue arose because the multisite:migrate command was run after bundle exec, but assets were precompiled before the migration, causing the error. tgxworld identified the problem and suggested moving the migration to the before_bundle_exec hook. fuerst confirmed that modifying the template to run multisite:migrate before asset compilation resolved the issue. Another user, Sander78, faced a similar problem and worked around it by manually running the migration after ensuring the Gemfile.lock was present.
discourse_kulturladen=# SELECT * FROM schema_migration_details WHERE name = 'AddUploadsToCategories';
id | version | name | hostname | git_version | rails_version | duration | direction | created_at
----+---------+------+----------+-------------+---------------+----------+-----------+------------
(0 rows)
You’re only running multisite:migrate after the bundle exec hook but during the hook, assets are already being precompiled when the multisite DB hasn’t been migrated yet. To work around the problem, can you change your template to something like
before_bundle_exec:
- exec: su discourse -c 'bundle install --deployment --verbose --without test --without development'
- exec: cd /var/www/discourse && sudo -E -u discourse bundle exec rake multisite:migrate
You are right - precompiling assets started before database migration. Adding your code above to the before_bundle_exec hook worked. Thanks a lot for your help!
I had to modify it slightly to get it executed properly. My hook for multi site looks like this now:
I’m glad I found this topic. Had the same problem. But even now I have an error:
INFO -- : Running `bundle install --deployment --verbose --without "development"` with bundler 1.13.7
The --deployment flag requires a Gemfile.lock. Please make sure you have checked
your Gemfile.lock into version control before deploying.
So it seems it’s missing that Gemfile.lock file.
In the end I fixed it by running the older version of Discourse I had, then:
enter it with launcher enter app
cd db/migrations
paste the contents of the migration file above into a new file