[FIX] service: error database in use on duplicate database
When trying to duplicate a database, while having opened connections to it, postgresql throws ``` OperationalError: source database "duplicate_test" is being accessed by other users DETAIL: There is 1 other session using the database. ``` Connections must be dropped before trying duplication using TEMPLATE to avoid this.
This commit is contained in:
parent
534d5b8fe7
commit
7e7ecf36f1
|
@ -97,6 +97,7 @@ def exp_duplicate_database(db_original_name, db_name):
|
|||
db = openerp.sql_db.db_connect('postgres')
|
||||
with closing(db.cursor()) as cr:
|
||||
cr.autocommit(True) # avoid transaction block
|
||||
_drop_conn(cr, db_original_name)
|
||||
cr.execute("""CREATE DATABASE "%s" ENCODING 'unicode' TEMPLATE "%s" """ % (db_name, db_original_name))
|
||||
|
||||
from_fs = openerp.tools.config.filestore(db_original_name)
|
||||
|
|
Loading…
Reference in New Issue