<?php
namespace Claromentis\Setup\Db;

$GLOBALS["__65da1b1ec2d6653e8a0ab7848e53621" . "5"] = (@$GLOBALS["__65da1b1ec2d6653e8a" . "0ab7848e536215"] ?: array()) + array("_a591754a8ddcd" . "bda9c80f1db4d9" . "11e14" => base64_decode("aXNfbnVsbA=" . "="), "d" . "b" => base64_decode("Z" . "G" . "I" . "="), "_b21ec8d" . "7fad482f" . "6736bdae" . "3a4b12f9" . "a" => base64_decode("bWlncmF" . "0aW9ucw" . "=="));
use Claromentis\Core\DAL\Db;
use Claromentis\Setup\Logger;
use Claromentis\Setup\SetupFacade;
use Claromentis\Setup\Util;
use Claromentis\Setup\Db\Migrations;
use Psr\Log\LoggerInterface;







class SchemaFacade
{
    
    
    
    
    protected $db;
    
    
    
    
    protected $schema;
    
    
    
    
    protected $rollup;
    
    
    
    
    protected $partial;
    
    
    
    
    
    
    protected $setup_facade;
    
    
    
    
    protected $logger;
    
    
    
    
    protected $persistence;
    
    
    
    
    
    
    
    
    
    public function __construct($db, $app_code, $_4825e032d19ebe3edee32a6a54c7afd2, $_d3a4df576cec8d467e29e06a95ac4009)
    {
        $this->db = $db;
        $this->logger = new Logger();
        $this->persistence = $_d3a4df576cec8d467e29e06a95ac4009;
        if ($GLOBALS["__65da1b1ec2d66" . "53e8a0ab7848e53" . "6215"]["_a591754a8ddcdbda9c" . "80f1db4d911e14"]($this->persistence)) {
            $this->persistence = new Migrations\PersistenceDatabase($app_code, $this->db, $this->logger);
        }
        $_dc9ec269884b7d92cba431fcfbfe3904 = Util::GetAppInitPath($_4825e032d19ebe3edee32a6a54c7afd2);
        $this->schema = new Migrations\Schema($_dc9ec269884b7d92cba431fcfbfe3904, $this->persistence);
        $this->rollup = new Migrations\Rollup($_dc9ec269884b7d92cba431fcfbfe3904, $this->persistence);
        $this->partial = new Migrations\Partial($_dc9ec269884b7d92cba431fcfbfe3904, $this->persistence);
        $_54fa8523f2845872533bfb14523f79ed = array($GLOBALS["__65da1b1ec2" . "d6653e8a0ab7" . "848e536215"]["_b21ec8d7fad482f6736bdae3a4" . "b12f9a"] => $this, $GLOBALS["__65da1b1ec2d6653e8a0ab784" . "8e536215"]["d" . "b"] => $this->db);
        $this->schema->SetEnvironment($_54fa8523f2845872533bfb14523f79ed);
        $this->rollup->SetEnvironment($_54fa8523f2845872533bfb14523f79ed);
        $this->setup_facade = new SetupFacade($this->db);
        $this->setup_facade->setLogger($this->logger);
        $_54fa8523f2845872533bfb14523f79ed = array($GLOBALS["__65da1b1ec" . "2d6653e8a0a" . "b7848e53621" . "5"]["_b21ec8d7fad482f6736bdae3a4b12f" . "9a"] => $this->setup_facade, $GLOBALS["__65da1b1ec2d6653e8a0ab7848e53" . "6215"]["d" . "b"] => $this->db);
        $this->partial->SetEnvironment($_54fa8523f2845872533bfb14523f79ed);
        $this->setLogger($this->logger);
    }
    
    
    
    
    
    
    public function setLogger(LoggerInterface $logger)
    {
        $this->logger = $logger;
        $this->schema->setLogger($this->logger);
        $this->rollup->setLogger($this->logger);
        $this->partial->setLogger($this->logger);
        $this->setup_facade->setLogger($this->logger);
    }
    
    
    
    
    
    
    public function Install()
    {
        $this->db->DisableTokenCheck();
        try {
            $this->schema->Install();
            $this->rollup->Up();
            
            
            $this->partial->Up();
        } catch (\Exception $e) {
            $this->db->EnableTokenCheck();
            throw $e;
        }
        $this->db->EnableTokenCheck();
    }
    
    
    
    
    
    
    public function Update()
    {
        $this->db->DisableTokenCheck();
        try {
            $this->schema->Update();
            $this->rollup->Up();
            $this->partial->Up();
        } catch (\Exception $e) {
            $this->db->EnableTokenCheck();
            throw $e;
        }
        $this->db->EnableTokenCheck();
    }
    
    
    
    
    
    
    
    
    public function Run($file_name, $code)
    {
        $this->partial->Run($file_name, $code);
    }
    
    
    
    
    
    
    public function GetVersion()
    {
        return $this->persistence->GetVersion();
    }
    
    
    
    
    
    
    public function SetVersion($_c80a67ccfaf6579232efc354d30eb275)
    {
        $this->persistence->SetVersion($_c80a67ccfaf6579232efc354d30eb275);
    }
    
    
    
    
    
    
    
    
    
    
    public function CheckValid($_d5ebf376f635c188ec65813608e6ece5)
    {
    }
}