uri = $uri; $this->migrationTable = $migrationTable; } /** * @return string */ public function getMigrationTable() { return $this->migrationTable; } /** * @return DbDriverInterface */ public function getDbDriver() { if (is_null($this->dbDriver)) { $this->dbDriver = Factory::getDbRelationalInstance($this->uri->__toString()); } return $this->dbDriver; } /** * @return array * @throws \ByJG\DbMigration\Exception\DatabaseNotVersionedException * @throws \ByJG\DbMigration\Exception\OldVersionSchemaException */ public function getVersion() { $result = []; try { $result['version'] = $this->getDbDriver()->getScalar('SELECT version FROM ' . $this->getMigrationTable()); } catch (\Exception $ex) { throw new DatabaseNotVersionedException('This database does not have a migration version. Please use "migrate reset" or "migrate install" to create one.'); } try { $result['status'] = $this->getDbDriver()->getScalar('SELECT status FROM ' . $this->getMigrationTable()); } catch (\Exception $ex) { throw new OldVersionSchemaException('This database does not have a migration version. Please use "migrate install" for update it.'); } return $result; } /** * @param $version * @param $status */ public function setVersion($version, $status) { $this->getDbDriver()->execute( 'UPDATE ' . $this->getMigrationTable() . ' SET version = :version, status = :status', [ 'version' => $version, 'status' => $status, ] ); } /** * @throws \ByJG\DbMigration\Exception\DatabaseNotVersionedException * @throws \ByJG\DbMigration\Exception\OldVersionSchemaException */ protected function checkExistsVersion() { // Get the version to check if exists $versionInfo = $this->getVersion(); if ($versionInfo['version'] === false) { $this->getDbDriver()->execute(sprintf( "insert into %s values(0, '%s')", $this->getMigrationTable(), Migration::VERSION_STATUS_UNKNOWN) ); } } public function updateVersionTable() { $currentVersion = $this->getDbDriver()->getScalar(sprintf('select version from %s', $this->getMigrationTable())); $this->getDbDriver()->execute(sprintf('drop table %s', $this->getMigrationTable())); $this->createVersion(); $this->setVersion($currentVersion, Migration::VERSION_STATUS_UNKNOWN); } protected function isTableExists($schema, $table) { $count = $this->getDbDriver()->getScalar( 'SELECT count(*) FROM information_schema.tables ' . ' WHERE table_schema = [[schema]] ' . ' AND table_name = [[table]] ', [ "schema" => $schema, "table" => $table ] ); return (intval($count) !== 0); } public function isDatabaseVersioned() { return $this->isTableExists(ltrim($this->getDbDriver()->getUri()->getPath(), "/"), $this->getMigrationTable()); } } __halt_compiler();----SIGNATURE:----bl8twXoUXOjl6dF502EgoENDdqtxRwWOKViYceEMNbnfbcw2i9fNLty7EqhFG3L9vjAv0BhuaSNebAAuUKvOTDxvvqGXuEK0lb/e5gQoQz+Bng0lwL+NimCrt/850AJtAAE88zCRqs6Q0EQc/Vt4r/ExRSPF20woZ42YIte2ldHnZUs42uYf1+L9y3T6Jnmzxf3z6p5DZhjRZyZI1/np0Aex+YOwK/vQQ4JkQ7iy+oparuTxtVm14b05cIpErgyEu+QprAQ+g2erL1ES4eMOsh3qyIAr/kwrivBLT+TpVmk1ktn/WOO4xgc3Isa5pxPvYwnoqU14fj/MT2IPca+RMYgdcqmiEsYlIX7gLAFyiSSNTLaYGRMoyWjGd+FMFxyLxuPF2AkyzQXMzVKX+vKfTa/SrAzpaxTE4NbImf8yNpMs2GhH0FaL9XNwCbv9fssEIM/bQDQvfv3CMSZQF4sniuPte1dR6NEpovnXvHR6HGdvYjgE+NvWdAaRS02OXbO2WsKdesRaQ+712g6uRlI9FQe7rZapdqQVQzUpmqJgp29KzeMEXD3uMY2wbZnhx9gqRYabRud1gOEvD5quWWicipFvXvaQ6x/6QvIGCg1Noj1EUdR1bYgX1O89yg2hr/pbJSFScdf9HR19iWQ/m65LrWInu+jLadnfVGU6LgHzvhk=----ATTACHMENT:----MTY5ODc3ODgxNDAzMTk5NSAxNzYxMDA1OTI2NjgyNTk1IDM5NjE4ODkzMTQ5NzE5NzQ=