<?php
namespace Claromentis\Setup\Db;

$GLOBALS["__65da1b1ec2d6653e8" . "a0ab7848e536215"] = (@$GLOBALS["__65da1b1ec2d6" . "653e8a0ab7848e" . "536215"] ?: array()) + array("_a591754a8ddcdbda9c80f1db4d911e1" . "4" => base64_decode("aXNfbnVs" . "bA=="), "d" . "b" => base64_decode("ZG" . "I="), "_b21ec8d7fad48" . "2f6736bdae3a4b" . "12f9a" => base64_decode("bWln" . "cmF0" . "aW9u" . "cw=="));
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["__65da1b1ec2d665" . "3e8a0ab7848e5362" . "15"]["_a591754a8ddc" . "dbda9c80f1db4" . "d911e14"]($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["__65da1b1ec2d6653e8a0" . "ab7848e536215"]["_b21ec8d7fad482f" . "6736bdae3a4b12f9" . "a"] => $this, $GLOBALS["__65da1b1ec2d6653" . "e8a0ab7848e536215"]["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["__65da1b1ec2d6653e8a0a" . "b7848e536215"]["_b21ec8d7fad482f6736bd" . "ae3a4b12f9a"] => $this->setup_facade, $GLOBALS["__65da1b1" . "ec2d6653e" . "8a0ab7848" . "e536215"]["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)
    {
    }
}