Can't rebuild container, "null value in column "score" violates not-null constraint"

Yes, but disabling those doesn’t allow the bootstrap to complete.

I suspect something went wrong with user deletion - maybe someone deleted a user directly from the database in the “wrong way” - and that’s left a broken row.

Although, the date in the row is very near the birth of our Discourse forum (April 2016) so that’s not likely to have been the cause. We also didn’t have custom plugins installed at that point.

It might also explain why dealing with Flags has been throwing errors for the past few weeks.

Edit:

Oh. It might be because of

https://github.com/angusmcleod/discourse-moderator-extension

That might be doing something with the table… and when enabled it causes bootstrap to fail earlier:

https://github.com/angusmcleod/discourse-moderator-extension/issues/1

Edit:

I’m also wondering whether some database migrations haven’t actually been run…

https://github.com/discourse/discourse/commit/b58867b6e936a5247304e9f06f827cf5012a92ed

I don’t think migrations can be partially run… so the container base image shouldn’t be using the wrong database schema…

500 error when logging in as a Staff user:

ActiveRecord::StatementInvalid (PG::UndefinedTable: ERROR:  relation "queued_posts" does not exist
LINE 8:                WHERE a.attrelid = '"queued_posts"'::regclass
                                          ^
:               SELECT a.attname, format_type(a.atttypid, a.atttypmod),
                     pg_get_expr(d.adbin, d.adrelid), a.attnotnull, a.atttypid, a.atttypmod,
                     c.collname, col_description(a.attrelid, a.attnum) AS comment
                FROM pg_attribute a
                LEFT JOIN pg_attrdef d ON a.attrelid = d.adrelid AND a.attnum = d.adnum
                LEFT JOIN pg_type t ON a.atttypid = t.oid
                LEFT JOIN pg_collation c ON a.attcollation = c.oid AND a.attcollation <> t.typcollation
               WHERE a.attrelid = '"queued_posts"'::regclass
                 AND a.attnum > 0 AND NOT a.attisdropped
               ORDER BY a.attnum
)
/var/www/discourse/vendor/bundle/ruby/2.5.0/gems/rack-mini-profiler-1.0.2/lib/patches/db/pg.rb:110:in `async_exec'
Failed to handle exception in exception app middleware : PG::UndefinedTable: ERROR:  relation "queued_posts" does not exist
LINE 8:                WHERE a.attrelid = '"queued_posts"'::regclass
                                          ^
:               SELECT a.attname, format_type(a.atttypid, a.atttypmod),
                     pg_get_expr(d.adbin, d.adrelid), a.attnotnull, a.atttypid, a.atttypmod,
                     c.collname, col_description(a.attrelid, a.attnum) AS comment
                FROM pg_attribute a
                LEFT JOIN pg_attrdef d ON a.attrelid = d.adrelid AND a.attnum = d.adnum
                LEFT JOIN pg_type t ON a.atttypid = t.oid
                LEFT JOIN pg_collation c ON a.attcollation = c.oid AND a.attcollation <> t.typcollation
               WHERE a.attrelid = '"queued_posts"'::regclass
                 AND a.attnum > 0 AND NOT a.attisdropped
               ORDER BY a.attnum

Edit:

After a final rebuild the above 500 is resolved.