fix script/discourse script
This commit is contained in:
parent
269f52b8f7
commit
d92c6ece63
|
@ -28,7 +28,7 @@ WHERE table_schema='public' and (data_type like 'char%' or data_type like 'text%
|
||||||
results.each do |result|
|
results.each do |result|
|
||||||
table_name = result["table_name"]
|
table_name = result["table_name"]
|
||||||
column_name = result["column_name"]
|
column_name = result["column_name"]
|
||||||
puts "Reampping #{table_name} #{column_name}"
|
puts "Remapping #{table_name} #{column_name}"
|
||||||
result = cnn.async_exec("UPDATE #{table_name}
|
result = cnn.async_exec("UPDATE #{table_name}
|
||||||
SET #{column_name} = replace(#{column_name}, $1, $2)
|
SET #{column_name} = replace(#{column_name}, $1, $2)
|
||||||
WHERE NOT #{column_name} IS NULL
|
WHERE NOT #{column_name} IS NULL
|
||||||
|
@ -38,25 +38,34 @@ WHERE table_schema='public' and (data_type like 'char%' or data_type like 'text%
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
desc "export", "Export a Discourse backup"
|
desc "backup", "Backup a discourse forum"
|
||||||
def export(filename=nil)
|
def backup
|
||||||
load_rails
|
load_rails
|
||||||
|
|
||||||
filename = File.expand_path(filename) if filename
|
require "backup_restore"
|
||||||
|
require "export/exporter"
|
||||||
|
|
||||||
puts 'Starting export...'
|
puts 'Starting export...'
|
||||||
output_filename = Jobs::Exporter.new.execute( format: :json, filename: filename)
|
output_filename = Export::Exporter.new(Discourse.system_user).run
|
||||||
puts 'Export done.'
|
puts 'Export done.'
|
||||||
puts "Output file is in: #{output_filename}", ''
|
puts "Output file is in: #{output_filename}", ''
|
||||||
end
|
end
|
||||||
|
|
||||||
desc "import", "Import a Discourse backup"
|
desc "export", "Backup a Discourse forum"
|
||||||
def import(filename)
|
def export
|
||||||
|
backup
|
||||||
|
end
|
||||||
|
|
||||||
|
desc "restore", "Restore a Discourse backup"
|
||||||
|
def restore(filename)
|
||||||
load_rails
|
load_rails
|
||||||
|
|
||||||
|
require "backup_restore"
|
||||||
|
require "import/importer"
|
||||||
|
|
||||||
begin
|
begin
|
||||||
filename = File.expand_path(filename)
|
|
||||||
puts "Starting import: #{filename}"
|
puts "Starting import: #{filename}"
|
||||||
Jobs::Importer.new.execute( format: :json, filename: filename)
|
Import::Importer.new(Discourse.system_user, filename).run
|
||||||
puts 'Import done.'
|
puts 'Import done.'
|
||||||
rescue Import::FilenameMissingError
|
rescue Import::FilenameMissingError
|
||||||
puts '', 'The filename argument was missing.', ''
|
puts '', 'The filename argument was missing.', ''
|
||||||
|
@ -67,6 +76,11 @@ WHERE table_schema='public' and (data_type like 'char%' or data_type like 'text%
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
desc "import", "Restore a Discourse backup"
|
||||||
|
def import(filename)
|
||||||
|
restore(filename)
|
||||||
|
end
|
||||||
|
|
||||||
desc "migrate", "Make sure all the posts are pointing to the new domain"
|
desc "migrate", "Make sure all the posts are pointing to the new domain"
|
||||||
option :from, type: :array, required: true, banner: "http://previous.domain.com"
|
option :from, type: :array, required: true, banner: "http://previous.domain.com"
|
||||||
option :database, default: "default", aliases: :db
|
option :database, default: "default", aliases: :db
|
||||||
|
|
Loading…
Reference in New Issue