Moving to a new server - error with database

We are trying to move everything to a new server, after the migration we get this message on top:

when I try to run the following inside the app:

  # sudo ./launcher enter app
  # rails c
  > user = User.find_by_email("<admin_email>")
  > user.admin = true
  > user.save`

I get the following error:

ActiveModel::MissingAttributeError: can’t write unknown attribute ``
from /var/www/discourse/vendor/bundle/ruby/2.6.0/gems/activemodel-6.0.2.2/lib/active_model/attribute.rb:206:in with_value_from_database' Caused by ActiveRecord::StatementInvalid: PG::SyntaxError: ERROR: zero-length delimited identifier at or near """" LINE 1: ... = '2020-04-23 16:30:36.173916' WHERE "site_settings"."" = 3 ^ from /var/www/discourse/vendor/bundle/ruby/2.6.0/gems/rack-mini-profiler-2.0.1/lib/patches/db/pg.rb:69:in exec_params’
Caused by PG::SyntaxError: ERROR: zero-length delimited identifier at or near “”“”
LINE 1: … = ‘2020-04-23 16:30:36.173916’ WHERE “site_settings”.“” = 3
^
from /var/www/discourse/vendor/bundle/ruby/2.6.0/gems/rack-mini-profiler-2.0.1/lib/patches/db/pg.rb:69:in `exec_params’

Any ideas on how to finalise installation? It may look like a table is corrupted.

Can you back up and tell us more exactly of what you’re trying to do? Is this prior to restoring a backup or after? Or is this a new install?

Steps we did:

  1. Install latest version on new server
  2. Switched old server to read only, took backup
  3. Restored backup on new server

Error is happening after number 3 and we repeated process twice.

Do you have a developer email defined in app.yml? Have you tried rebuilding the container yet?

yes. Discourse without importing migration works correctly. No errors. After the backup database is restored settings cannot be modified because we get an error and trying to activate the devs email doesn’t send an email. thats why I was trying to activate the account manually, but then I encountered that error

Have you done a ./launcher rebuild app after the backup restore? Or entered the container and run rake db:migrate? That may help, but can’t say for sure until we try :smiley:

I already run launcher rebuild app but the problem is still there. Do I run the rake from the server or from inside the app (launcher enter app)?

./launcher rebuild app will do the same thing.

Do you still have the previous instance running? If so, your best bet going forward is to destroy the new one and rebuild it with a fresh backup from the old instance.

Yes, the previous server is still running. Having investigated the problem more deeply, this happens even in the old server. Same error pops up. :face_with_raised_eyebrow:

Shall I try to clear the site_settings table and re-set them manually? Will Discourse work after I delete all records from this table manually from postgresql?

I would avoid doing that unless you know what you’re doing.

You may want to post in marketplace for more advanced help. Sounds like you might have a broken install unfortunately.

1 Like