Ah thank you that worked =). Unfortunately I got another error once I executed u.build_user_stat.save:
ActiveRecord::StatementInvalid: PG::NotNullViolation: ERROR: null value in colu mn "new_since" violates not-null constraint
DETAIL: Failing row contains (3530, 0, 0, 0, 0, 0, 0, 0, null, null, null, 0, 0 , 0, null).
: INSERT INTO "user_stats" ("user_id") VALUES (3530) RETURNING "user_id"
from /var/www/discourse/vendor/bundle/ruby/2.3.0/gems/rack-mini-profiler-0.10.1/ lib/patches/db/pg.rb:90:in `exec'
For what it’s worth I checked user_stats and the user already has an entry in the table. I tried to locate build_user_stat in the Discourse code but I couldn’t find it anywhere?