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

**URL:** <https://meta.discourse.org/t/cant-rebuild-container-null-value-in-column-score-violates-not-null-constraint/112883>\
**Category:** Self-hosting\
**Created:** [29 במרץ,‏ 2019,‏ 1:48am UTC](https://meta.discourse.org/t/cant-rebuild-container-null-value-in-column-score-violates-not-null-constraint/112883 "2019-03-29T01:48:17Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![jonathon](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jonathon/32/265865_2.png) [@jonathon](https://meta.discourse.org/u/jonathon)\
**Post date:** [29 במרץ,‏ 2019,‏ 10:21am UTC](https://meta.discourse.org/t/cant-rebuild-container-null-value-in-column-score-violates-not-null-constraint/112883/3 "2019-03-29T10:21:27Z")

</div>

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](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](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](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:

```plaintext
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.

---

_[View the full topic](https://meta.discourse.org/t/cant-rebuild-container-null-value-in-column-score-violates-not-null-constraint/112883)._
