2013-09-06 16:03:30 +08:00
|
|
|
# kind of odd, but we need it, we also need to nuke usage of User from inside migrations
|
|
|
|
# very poor form
|
2014-05-06 21:41:59 +08:00
|
|
|
user = User.find_by("id <> -1 and username_lower = 'system'")
|
2013-09-06 12:07:23 +08:00
|
|
|
if user
|
2013-09-06 15:28:37 +08:00
|
|
|
user.username = UserNameSuggester.suggest("system")
|
2013-09-06 12:07:23 +08:00
|
|
|
user.save
|
|
|
|
end
|
|
|
|
|
2017-04-27 02:47:36 +08:00
|
|
|
UserEmail.seed do |ue|
|
|
|
|
ue.id = -1
|
|
|
|
ue.email = "no_email"
|
|
|
|
ue.primary = true
|
|
|
|
ue.user_id = -1
|
|
|
|
end
|
|
|
|
|
2013-09-06 12:07:23 +08:00
|
|
|
User.seed do |u|
|
|
|
|
u.id = -1
|
2013-09-06 15:28:37 +08:00
|
|
|
u.name = "system"
|
|
|
|
u.username = "system"
|
|
|
|
u.username_lower = "system"
|
2013-09-06 12:07:23 +08:00
|
|
|
u.password = SecureRandom.hex
|
|
|
|
u.active = true
|
|
|
|
u.admin = true
|
|
|
|
u.moderator = true
|
|
|
|
u.approved = true
|
2014-09-05 13:20:39 +08:00
|
|
|
u.trust_level = TrustLevel[4]
|
2013-09-06 12:07:23 +08:00
|
|
|
end
|
2014-06-17 08:46:30 +08:00
|
|
|
|
2016-02-17 12:46:19 +08:00
|
|
|
UserOption.where(user_id: -1).update_all(
|
|
|
|
email_private_messages: false,
|
|
|
|
email_direct: false
|
|
|
|
)
|
|
|
|
|
2015-07-27 17:07:42 +08:00
|
|
|
Group.user_trust_level_change!(-1, TrustLevel[4])
|
|
|
|
|
2018-03-20 15:20:50 +08:00
|
|
|
Migration::ColumnDropper.drop(
|
2017-05-04 22:15:32 +08:00
|
|
|
table: 'users',
|
2017-11-07 10:06:42 +08:00
|
|
|
after_migration: 'DropEmailFromUsers',
|
|
|
|
columns: %w[
|
|
|
|
email
|
|
|
|
email_always
|
|
|
|
mailing_list_mode
|
|
|
|
email_digests
|
|
|
|
email_direct
|
|
|
|
email_private_messages
|
|
|
|
external_links_in_new_tab
|
|
|
|
enable_quoting
|
|
|
|
dynamic_favicon
|
|
|
|
disable_jump_reply
|
|
|
|
edit_history_public
|
|
|
|
automatically_unpin_topics
|
|
|
|
digest_after_days
|
|
|
|
auto_track_topics_after_msecs
|
|
|
|
new_topic_duration_minutes
|
|
|
|
last_redirected_to_top_at
|
|
|
|
auth_token
|
|
|
|
auth_token_updated_at
|
|
|
|
],
|
2017-07-28 09:20:09 +08:00
|
|
|
on_drop: ->() {
|
2017-05-04 22:15:32 +08:00
|
|
|
STDERR.puts 'Removing superflous users columns!'
|
|
|
|
}
|
|
|
|
)
|
2016-02-17 15:08:05 +08:00
|
|
|
|
2018-03-20 15:20:50 +08:00
|
|
|
Migration::ColumnDropper.drop(
|
2017-11-11 01:18:08 +08:00
|
|
|
table: 'users',
|
|
|
|
after_migration: 'RenameBlockedSilence',
|
|
|
|
columns: %w[
|
|
|
|
blocked
|
|
|
|
],
|
|
|
|
on_drop: ->() {
|
|
|
|
STDERR.puts 'Removing user blocked column!'
|
|
|
|
}
|
|
|
|
)
|
|
|
|
|
2018-03-20 15:20:50 +08:00
|
|
|
Migration::ColumnDropper.drop(
|
2017-11-14 02:41:36 +08:00
|
|
|
table: 'users',
|
|
|
|
after_migration: 'AddSilencedTillToUsers',
|
|
|
|
columns: %w[
|
|
|
|
silenced
|
|
|
|
],
|
|
|
|
on_drop: ->() {
|
|
|
|
STDERR.puts 'Removing user silenced column!'
|
|
|
|
}
|
|
|
|
)
|
|
|
|
|
2018-03-20 15:20:50 +08:00
|
|
|
Migration::ColumnDropper.drop(
|
2017-11-24 04:55:44 +08:00
|
|
|
table: 'users',
|
|
|
|
after_migration: 'AddTrustLevelLocksToUsers',
|
|
|
|
columns: %w[
|
|
|
|
trust_level_locked
|
|
|
|
],
|
|
|
|
on_drop: ->() {
|
|
|
|
STDERR.puts 'Removing user trust_level_locked!'
|
|
|
|
}
|
|
|
|
)
|
|
|
|
|
2015-07-27 17:07:42 +08:00
|
|
|
# User for the smoke tests
|
|
|
|
if ENV["SMOKE"] == "1"
|
2017-04-27 02:47:36 +08:00
|
|
|
UserEmail.seed do |ue|
|
|
|
|
ue.id = 0
|
|
|
|
ue.email = "smoke_user@discourse.org"
|
|
|
|
ue.primary = true
|
|
|
|
ue.user_id = 0
|
|
|
|
end
|
|
|
|
|
2015-07-27 17:07:42 +08:00
|
|
|
smoke_user = User.seed do |u|
|
|
|
|
u.id = 0
|
|
|
|
u.name = "smoke_user"
|
|
|
|
u.username = "smoke_user"
|
|
|
|
u.username_lower = "smoke_user"
|
|
|
|
u.password = "P4ssw0rd"
|
|
|
|
u.active = true
|
|
|
|
u.approved = true
|
|
|
|
u.approved_at = Time.now
|
|
|
|
u.trust_level = TrustLevel[3]
|
|
|
|
end.first
|
|
|
|
|
2016-02-17 18:57:06 +08:00
|
|
|
UserOption.where(user_id: smoke_user.id).update_all(
|
|
|
|
email_direct: false,
|
|
|
|
email_digests: false,
|
|
|
|
email_private_messages: false,
|
|
|
|
)
|
|
|
|
|
|
|
|
EmailToken.where(user_id: smoke_user.id).update_all(confirmed: true)
|
2015-07-27 17:07:42 +08:00
|
|
|
end
|