mirror of
https://github.com/discourse/discourse.git
synced 2024-11-23 05:40:52 +08:00
afb5533581
* Add timezone to user_options table * Also migrate existing timezone values from UserCustomField, which is where the discourse-calendar plugin is storing them * Allow user to change their core timezone from Profile * Auto guess & set timezone on login & invite accept & signup * Serialize user_options.timezone for group members. this is so discourse-group-timezones can access the core user timezone, as it is being removed in discourse-calendar. * Annotate user_option with timezone * Validate timezone values
20 lines
439 B
Ruby
20 lines
439 B
Ruby
# frozen_string_literal: true
|
|
|
|
class AddTimezoneToUserOptions < ActiveRecord::Migration[6.0]
|
|
def up
|
|
add_column :user_options, :timezone, :string
|
|
execute(
|
|
<<-SQL
|
|
UPDATE user_options
|
|
SET timezone = ucf.value
|
|
FROM user_custom_fields AS ucf
|
|
WHERE ucf.user_id = user_options.user_id AND ucf.name = 'timezone'
|
|
SQL
|
|
)
|
|
end
|
|
|
|
def down
|
|
remove_column :user_options, :timezone
|
|
end
|
|
end
|