修復member_profile_id型態問題

This commit is contained in:
邱博亞 2023-05-25 23:15:42 +08:00
parent 934b054974
commit def145d70d
1 changed files with 29 additions and 20 deletions

View File

@ -1,6 +1,15 @@
module PersonalJournal module PersonalJournal
class Engine < ::Rails::Engine class Engine < ::Rails::Engine
initializer "personal_journal" do initializer "personal_journal" do
require File.expand_path('../../../app/models/journal_paper', __FILE__)
mp_id_maps = {}
JournalPaper.where({'member_profile_id.0'=> {'$exists'=> false}, 'member_profile_id' => {'$ne'=> nil}}).pluck(:id, :member_profile_id).each do |jpv|
mp_id_maps[jpv[1]] = [] if !mp_id_maps[jpv[1]]
mp_id_maps[jpv[1]] << jpv[0]
end
mp_id_maps.each do |mp_id, ids|
JournalPaper.where(:id.in => ids).update_all(member_profile_id: [mp_id])
end
OrbitApp.registration "PersonalJournal",:type=> 'ModuleApp' do OrbitApp.registration "PersonalJournal",:type=> 'ModuleApp' do
module_label 'module_name.journal_paper' module_label 'module_name.journal_paper'
base_url File.expand_path File.dirname(__FILE__) base_url File.expand_path File.dirname(__FILE__)