Merge remote-tracking branch 'parent/main' into kb_migration

This commit is contained in:
KMY 2023-09-06 10:09:07 +09:00
commit fdf1d6df38
41 changed files with 752 additions and 569 deletions

View file

@ -90,7 +90,7 @@ class BackfillAdminActionLogs < ActiveRecord::Migration[6.1]
log.update_attribute('route_param', log.user.account_id)
end
Admin::ActionLog.where(target_type: 'Report', human_identifier: nil).in_batches.update_all('human_identifier = target_id::text')
AdminActionLog.where(target_type: 'Report', human_identifier: nil).in_batches.update_all('human_identifier = target_id::text')
AdminActionLog.includes(:domain_block).where(target_type: 'DomainBlock').find_each do |log|
next if log.domain_block.nil?

View file

@ -90,7 +90,7 @@ class BackfillAdminActionLogsAgain < ActiveRecord::Migration[6.1]
log.update_attribute('route_param', log.user.account_id)
end
Admin::ActionLog.where(target_type: 'Report', human_identifier: nil).in_batches.update_all('human_identifier = target_id::text')
AdminActionLog.where(target_type: 'Report', human_identifier: nil).in_batches.update_all('human_identifier = target_id::text')
AdminActionLog.includes(:domain_block).where(target_type: 'DomainBlock').find_each do |log|
next if log.domain_block.nil?

View file

@ -0,0 +1,27 @@
# frozen_string_literal: true
class FixKmrLocaleSettings < ActiveRecord::Migration[7.0]
disable_ddl_transaction!
class MigrationUser < ApplicationRecord
self.table_name = :users
end
def up
MigrationUser.reset_column_information
MigrationUser.where.not(settings: [nil, '{}']).find_each do |user|
user_settings = Oj.load(user.settings)
next unless user_settings['default_language'] == 'kmr'
user_settings['default_language'] = 'ku'
user.update!(settings: Oj.dump(user_settings))
end
MigrationUser.where.not(chosen_languages: nil).where('chosen_languages && ?', '{kmr}').find_each do |user|
user.update!(chosen_languages: user.chosen_languages.map { |lang| lang == 'kmr' ? 'ku' : lang }.uniq)
end
end
def down; end
end

View file

@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema[7.0].define(version: 2023_08_26_023400) do
ActiveRecord::Schema[7.0].define(version: 2023_09_04_134623) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"