mirror of
https://github.com/discourse/discourse.git
synced 2025-05-22 22:43:33 +08:00
FIX: add port information when backuping/restoring
This commit is contained in:
@ -99,7 +99,7 @@ module BackupRestore
|
|||||||
SQL
|
SQL
|
||||||
end
|
end
|
||||||
|
|
||||||
DatabaseConfiguration = Struct.new(:host, :username, :password, :database)
|
DatabaseConfiguration = Struct.new(:host, :port, :username, :password, :database)
|
||||||
|
|
||||||
def self.database_configuration
|
def self.database_configuration
|
||||||
config = Rails.env.production? ? ActiveRecord::Base.connection_pool.spec.config : Rails.configuration.database_configuration[Rails.env]
|
config = Rails.env.production? ? ActiveRecord::Base.connection_pool.spec.config : Rails.configuration.database_configuration[Rails.env]
|
||||||
@ -107,6 +107,7 @@ module BackupRestore
|
|||||||
|
|
||||||
DatabaseConfiguration.new(
|
DatabaseConfiguration.new(
|
||||||
config["host"],
|
config["host"],
|
||||||
|
config["port"],
|
||||||
config["username"] || ENV["USER"] || "postgres",
|
config["username"] || ENV["USER"] || "postgres",
|
||||||
config["password"],
|
config["password"],
|
||||||
config["database"]
|
config["database"]
|
||||||
|
@ -172,6 +172,7 @@ module Export
|
|||||||
|
|
||||||
password_argument = "PGPASSWORD=#{db_conf.password}" if db_conf.password.present?
|
password_argument = "PGPASSWORD=#{db_conf.password}" if db_conf.password.present?
|
||||||
host_argument = "--host=#{db_conf.host}" if db_conf.host.present?
|
host_argument = "--host=#{db_conf.host}" if db_conf.host.present?
|
||||||
|
port_argument = "--port=#{db_conf.port}" if db_conf.port.present?
|
||||||
username_argument = "--username=#{db_conf.username}" if db_conf.username.present?
|
username_argument = "--username=#{db_conf.username}" if db_conf.username.present?
|
||||||
|
|
||||||
[ password_argument, # pass the password to pg_dump (if any)
|
[ password_argument, # pass the password to pg_dump (if any)
|
||||||
@ -182,6 +183,7 @@ module Export
|
|||||||
"--no-privileges", # prevent dumping of access privileges
|
"--no-privileges", # prevent dumping of access privileges
|
||||||
"--verbose", # specifies verbose mode
|
"--verbose", # specifies verbose mode
|
||||||
host_argument, # the hostname to connect to (if any)
|
host_argument, # the hostname to connect to (if any)
|
||||||
|
port_argument, # the port to connect to (if any)
|
||||||
username_argument, # the username to connect as (if any)
|
username_argument, # the username to connect as (if any)
|
||||||
db_conf.database # the name of the database to dump
|
db_conf.database # the name of the database to dump
|
||||||
].join(" ")
|
].join(" ")
|
||||||
|
@ -218,6 +218,7 @@ module Import
|
|||||||
|
|
||||||
password_argument = "PGPASSWORD=#{db_conf.password}" if db_conf.password.present?
|
password_argument = "PGPASSWORD=#{db_conf.password}" if db_conf.password.present?
|
||||||
host_argument = "--host=#{db_conf.host}" if db_conf.host.present?
|
host_argument = "--host=#{db_conf.host}" if db_conf.host.present?
|
||||||
|
port_argument = "--port=#{db_conf.port}" if db_conf.port.present?
|
||||||
username_argument = "--username=#{db_conf.username}" if db_conf.username.present?
|
username_argument = "--username=#{db_conf.username}" if db_conf.username.present?
|
||||||
|
|
||||||
[ password_argument, # pass the password to psql (if any)
|
[ password_argument, # pass the password to psql (if any)
|
||||||
@ -226,6 +227,7 @@ module Import
|
|||||||
"--file='#{@dump_filename}'", # read the dump
|
"--file='#{@dump_filename}'", # read the dump
|
||||||
"--single-transaction", # all or nothing (also runs COPY commands faster)
|
"--single-transaction", # all or nothing (also runs COPY commands faster)
|
||||||
host_argument, # the hostname to connect to (if any)
|
host_argument, # the hostname to connect to (if any)
|
||||||
|
port_argument, # the port to connect to (if any)
|
||||||
username_argument # the username to connect as (if any)
|
username_argument # the username to connect as (if any)
|
||||||
].join(" ")
|
].join(" ")
|
||||||
end
|
end
|
||||||
|
Reference in New Issue
Block a user