15 lines
2.1 KiB
Python
15 lines
2.1 KiB
Python
from pathlib import Path
|
|
import json,subprocess
|
|
r=Path.cwd();o=Path(__file__).resolve().parent;p=Path('C:/Users/macbook/.config/investmoz/editorial-QA-20261018');q=p/'source';pg=Path('C:/Program Files/PostgreSQL/17/bin');db='editorial_install_20261018_test'
|
|
b=json.loads((r/'outputs/investmoz-documentos-publicos-ativacao-20261018/FRESH-BACKUP.json').read_text('utf8'));dump=Path(b['private_directory'])/'destination.dump';args=['-h','127.0.0.1','-p','55441','-U','postgres']
|
|
assert subprocess.run([str(pg/'psql.exe'),*args,'-d','postgres','-Atc','SELECT inet_server_port()'],check=True,capture_output=True,text=True).stdout.strip()=='55441'
|
|
subprocess.run([str(pg/'createdb.exe'),*args,db],check=True,capture_output=True);subprocess.run([str(pg/'pg_restore.exe'),*args,'-d',db,'--exit-on-error','--no-owner','--no-privileges',str(dump)],check=True,capture_output=True)
|
|
env=(q/'.env').read_text('utf8').replace('editorial_20261018_test',db).replace('18548','18550');(p/'installation.env').write_text(env,'utf8')
|
|
for f in ['storage/framework/sessions','storage/framework/views','storage/logs']:(p/'installation'/f).mkdir(parents=True,exist_ok=True)
|
|
boot=(o/'boot-QA.php').read_text('utf8').replace("$source.'/.env'", "'"+(p/'installation.env').as_posix()+"'").replace('editorial_20261018_test',db)
|
|
boot=boot.replace("$source.'/storage'","'"+(p/'installation/storage').as_posix()+"'").replace("$source.'/storage/framework/sessions'","'"+(p/'installation/storage/framework/sessions').as_posix()+"'").replace("$source.'/storage/framework/views'","'"+(p/'installation/storage/framework/views').as_posix()+"'")
|
|
(o/'boot-install-QA.php').write_text(boot,'utf8');(o/'router-install-QA.php').write_text((o/'router-QA.php').read_text('utf8').replace('boot-QA.php','boot-install-QA.php'),'utf8')
|
|
fixture=(o/'fixture-QA.php').read_text('utf8').replace('boot-QA.php','boot-install-QA.php').replace('editorial_20261018_test',db).replace("'/fixture-private.json'","'/fixture-install-private.json'").replace('18548','18550')
|
|
(o/'fixture-install-QA.php').write_text(fixture,'utf8')
|
|
print('Nominal installer QA base restored without 160000; source and session isolation preserved')
|