v0.19.1 Massive improvement of topic and post migration handling with extra field population
This commit is contained in:
		@@ -1,5 +1,5 @@
 | 
				
			|||||||
# gossamer threads migration-import code
 | 
					# gossamer threads migration-import code
 | 
				
			||||||
# v0.19
 | 
					# v0.19.1
 | 
				
			||||||
 | 
					
 | 
				
			||||||
require 'mysql2'
 | 
					require 'mysql2'
 | 
				
			||||||
require 'open-uri'
 | 
					require 'open-uri'
 | 
				
			||||||
@@ -60,7 +60,7 @@ class GossamerForumsImporter < ImportScripts::Base
 | 
				
			|||||||
      );
 | 
					      );
 | 
				
			||||||
    SQL
 | 
					    SQL
 | 
				
			||||||
    @db.execute <<-SQL
 | 
					    @db.execute <<-SQL
 | 
				
			||||||
      CREATE TABLE IF NOT EXISTS url_map (
 | 
					      CREATE TABLE IF NOT EXISTS url_map2 (
 | 
				
			||||||
        old_post_id INTEGER PRIMARY KEY,
 | 
					        old_post_id INTEGER PRIMARY KEY,
 | 
				
			||||||
        new_url TEXT,
 | 
					        new_url TEXT,
 | 
				
			||||||
        title TEXT
 | 
					        title TEXT
 | 
				
			||||||
@@ -104,7 +104,7 @@ class GossamerForumsImporter < ImportScripts::Base
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
  # Insert a URL mapping into the SQLite database
 | 
					  # Insert a URL mapping into the SQLite database
 | 
				
			||||||
  def insert_url_mapping(old_post_id, new_url, title)
 | 
					  def insert_url_mapping(old_post_id, new_url, title)
 | 
				
			||||||
    @db.execute "INSERT INTO url_map (old_post_id, new_url, title) VALUES (?, ?, ?)", [old_post_id, new_url, title]
 | 
					    @db.execute "INSERT INTO url_map2 (old_post_id, new_url, title) VALUES (?, ?, ?)", [old_post_id, new_url, title]
 | 
				
			||||||
  end
 | 
					  end
 | 
				
			||||||
  
 | 
					  
 | 
				
			||||||
  # Export the URL mappings to a CSV file
 | 
					  # Export the URL mappings to a CSV file
 | 
				
			||||||
@@ -112,7 +112,7 @@ class GossamerForumsImporter < ImportScripts::Base
 | 
				
			|||||||
    CSV.open(filename, "w") do |csv|
 | 
					    CSV.open(filename, "w") do |csv|
 | 
				
			||||||
      # Add headers
 | 
					      # Add headers
 | 
				
			||||||
      csv << ["Old Post ID", "New URL", "Title"]
 | 
					      csv << ["Old Post ID", "New URL", "Title"]
 | 
				
			||||||
      @db.execute("SELECT old_post_id, new_url, title FROM url_map") do |row|
 | 
					      @db.execute("SELECT old_post_id, new_url, title FROM url_map2") do |row|
 | 
				
			||||||
        csv << row
 | 
					        csv << row
 | 
				
			||||||
      end
 | 
					      end
 | 
				
			||||||
    end
 | 
					    end
 | 
				
			||||||
@@ -122,7 +122,7 @@ class GossamerForumsImporter < ImportScripts::Base
 | 
				
			|||||||
  # Method to create Nginx rewrite rules file
 | 
					  # Method to create Nginx rewrite rules file
 | 
				
			||||||
  def create_nginx_rewrite_rules(filename)
 | 
					  def create_nginx_rewrite_rules(filename)
 | 
				
			||||||
    File.open(filename, "w") do |file|
 | 
					    File.open(filename, "w") do |file|
 | 
				
			||||||
      @db.execute("SELECT old_post_id, new_url FROM url_map") do |row|
 | 
					      @db.execute("SELECT old_post_id, new_url FROM url_map2") do |row|
 | 
				
			||||||
        old_post_id, new_url = row
 | 
					        old_post_id, new_url = row
 | 
				
			||||||
        file.puts "rewrite ^/forum/.*P#{old_post_id}/$ #{new_url} permanent;"
 | 
					        file.puts "rewrite ^/forum/.*P#{old_post_id}/$ #{new_url} permanent;"
 | 
				
			||||||
      end
 | 
					      end
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user