diff --git a/gossamer_forums.rb b/gossamer_forums.rb index 8cc003b..13a46de 100644 --- a/gossamer_forums.rb +++ b/gossamer_forums.rb @@ -1,5 +1,5 @@ # gossamer threads migration-import code -# v0.19.1 +# v0.19.3 require 'mysql2' require 'open-uri' @@ -60,7 +60,13 @@ class GossamerForumsImporter < ImportScripts::Base ); SQL @db.execute <<-SQL - CREATE TABLE IF NOT EXISTS url_map2 ( + DROP TABLE IF EXISTS url_map; + SQL + @db.execute <<-SQL + DROP TABLE IF EXISTS url_map2; + SQL + @db.execute <<-SQL + CREATE TABLE IF NOT EXISTS url_map ( old_post_id INTEGER PRIMARY KEY, new_url TEXT, title TEXT @@ -104,7 +110,7 @@ class GossamerForumsImporter < ImportScripts::Base # Insert a URL mapping into the SQLite database def insert_url_mapping(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] + @db.execute "INSERT INTO url_map (old_post_id, new_url, title) VALUES (?, ?, ?)", [old_post_id, new_url, title] end # Export the URL mappings to a CSV file @@ -112,7 +118,7 @@ class GossamerForumsImporter < ImportScripts::Base CSV.open(filename, "w") do |csv| # Add headers csv << ["Old Post ID", "New URL", "Title"] - @db.execute("SELECT old_post_id, new_url, title FROM url_map2") do |row| + @db.execute("SELECT old_post_id, new_url, title FROM url_map") do |row| csv << row end end @@ -122,7 +128,7 @@ class GossamerForumsImporter < ImportScripts::Base # Method to create Nginx rewrite rules file def create_nginx_rewrite_rules(filename) File.open(filename, "w") do |file| - @db.execute("SELECT old_post_id, new_url FROM url_map2") do |row| + @db.execute("SELECT old_post_id, new_url FROM url_map") do |row| old_post_id, new_url = row file.puts "rewrite ^/forum/.*P#{old_post_id}/$ #{new_url} permanent;" end