v0.2 Fix class definition for goss-destroydeletedposts.rb

This commit is contained in:
David Sainty 2024-09-09 14:27:13 +10:00
parent 145e956011
commit b61b2edbaa
2 changed files with 9 additions and 15 deletions

Binary file not shown.

View File

@ -1,7 +1,7 @@
# Federated Computer, Inc.
# David Sainty <saint@federated.computer> 2024 A.D.
# Gossamer Threads to Discourse -- CleanUp Script
# v0.1 New script
# v0.2 Fix class definition
require 'mysql2'
require 'active_record'
@ -9,6 +9,14 @@ require 'active_record'
# require 'concurrent-ruby'
require File.expand_path("../../../../config/environment", __FILE__)
class LegacyPost < ActiveRecord::Base
self.table_name = 'gforums_Post'
end
class LegacyUser < ActiveRecord::Base
self.table_name = 'gforums_User'
end
class GossamerForumsDestroyDeletedPosts
# def initialize
# super
@ -53,11 +61,6 @@ class GossamerForumsDestroyDeletedPosts
password: 'yxnh93Ybbz2Nm8#mp28zCVv'
)
# Load the gforums_Post model for legacy database
class LegacyPost < ActiveRecord::Base
self.table_name = 'gforums_Post'
end
# Find all posts marked as deleted in the legacy database
LegacyPost.where(post_deleted: 1).find_each do |legacy_post|
# Look for the post in Discourse by custom field
@ -81,15 +84,6 @@ class GossamerForumsDestroyDeletedPosts
password: 'yxnh93Ybbz2Nm8#mp28zCVv'
)
# Load the gforums_Post model for legacy database
class LegacyPost < ActiveRecord::Base
self.table_name = 'gforums_Post'
end
class LegacyUser < ActiveRecord::Base
self.table_name = 'gforums_User'
end
# Find the user ID for the given username
user = LegacyUser.find_by(username: username)
if user.nil?