v0.30 Add former_user support to prevent missing posts
This commit is contained in:
parent
1223421028
commit
798d0947c4
@ -1,5 +1,5 @@
|
||||
# gossamer threads migration-import code
|
||||
# v0.29
|
||||
# v0.30
|
||||
|
||||
require 'mysql2'
|
||||
require 'open-uri'
|
||||
@ -490,6 +490,29 @@ class GossamerForumsImporter < ImportScripts::Base
|
||||
# upload
|
||||
# end
|
||||
|
||||
# Add 'Former_User' account if not already present
|
||||
def add_former_user
|
||||
puts "Adding 'Former User' account if it does not exist..."
|
||||
|
||||
former_user = User.find_by(username: 'Former_User')
|
||||
|
||||
if former_user.nil?
|
||||
former_user = User.create!(
|
||||
username: 'Former_User',
|
||||
name: 'Former User',
|
||||
email: 'former_user@example.com',
|
||||
password: SecureRandom.hex(16),
|
||||
active: true
|
||||
)
|
||||
puts "'Former User' account created with user ID: #{former_user.id}"
|
||||
|
||||
# Store the user ID mapping
|
||||
puts "for insert_user_id_mapping: 0 (former_user) discourse_user.id #{former_user.id}"
|
||||
insert_user_id_mapping(0, former_user.id)
|
||||
else
|
||||
puts "'Former User' account already exists with user ID: #{former_user.id}"
|
||||
end
|
||||
end
|
||||
|
||||
# Import users from Gossamer Forums to Discourse
|
||||
def import_users
|
||||
@ -1249,6 +1272,7 @@ class GossamerForumsImporter < ImportScripts::Base
|
||||
|
||||
puts "Starting Gossamer Forums import... #{timestamp}"
|
||||
|
||||
add_former_user
|
||||
# import_users
|
||||
# export_username_mapping_to_csv("gossamer-migration-username-mapping#{timestamp}")
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user