DEV: ensure discobot has a user_option & user_profile

When doing a migration, there might be some cases where the discobot user
doesn't have a user_option / user_profile record(s).

This ensures we always create one during the seed phase.
This commit is contained in:
Régis Hanol 2020-07-07 18:24:31 +02:00
parent d2e320d4f7
commit 44aaf4415d
1 changed files with 4 additions and 0 deletions

View File

@ -38,11 +38,15 @@ end
bot.update!(admin: true, moderator: false)
bot.create_user_option! if !bot.user_option
bot.user_option.update!(
email_messages_level: UserOption.email_level_types[:never],
email_level: UserOption.email_level_types[:never]
)
bot.create_user_profile! if !bot.user_profile
if !bot.user_profile.bio_raw
bot.user_profile.update!(
bio_raw: I18n.t('discourse_narrative_bot.bio', site_title: SiteSetting.title, discobot_username: bot.username)