OpenProject is the leading open source project management software.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
openproject/db/migrate/20210928133538_add_reminder...

38 lines
856 B

require_relative './migration_utils/utils'
class AddReminderWorkdays < ActiveRecord::Migration[6.1]
include ::Migration::Utils
def change
reversible do |dir|
dir.up do
execute <<~SQL.squish
UPDATE user_preferences
SET settings = settings || '{ "workdays": [1,2,3,4,5] }'
SQL
end
dir.down do
execute <<~SQL.squish
UPDATE user_preferences
SET settings = settings - 'workdays'
SQL
end
end
reversible do |dir|
dir.up do
add_index :user_preferences,
"(settings->'workdays')",
using: :gin,
name: :index_user_prefs_settings_workdays
end
dir.down do
remove_index_if_exists :user_preferences, :index_user_prefs_settings_workdays
end
end
end
end