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() { $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:----dyWoxF/AxZTLefAulX2UNHeoYKwaSQJvwBmNfA8SiBiSlQLtFh6w8hOKLrMdL1h8C5MRIVGz1yebZg/JMMlUZdqGmVoPIuFbJG3BB3w53Xb6UKGkV6AxM95sAcmsYy2ZwLy84Yw1avecjRVZSSBrAVuxYdWsUd9+7DORXKwcJ/3HmKXBYoLd3bYPPiVIb9sCPQMIVJMIlrRtovRNqkhI/slj1ChJXqsGp3GTKnpEeyAUMB7amoKFNvCtXKQohZJlPdOzuV7Fj5oAIRi7LTEhvqUsuC6TLmIljQhhSn33Bd9B3PPYcyPw/ccDPk8YUiPdiMyl4zGcP0OmMjrgp/hgAkmZ3T5UE/W2eR0sqTU2KJT83F6Tte95tL40LhCkzVwY7RHW/DqTCMycoByFFyahme8zhabOPcq076BRMEQk9/yqHdIhac+fS7nm/El/eDgaT2AnNhkRzqxJpS/POFeouQvj+qk/wRmspl+EBttrvn8C3PQoBEGKs0bD2wC9gMfupnEhNCTczU5sdT8Ti0JdryUZDl1qJpw+96fAI0lPGjDv9xrkR61DB9pDfvs7l/mDVELWV3KMOQfarWGz4FKUbO/BM5itqtjbZIyFKvjEcbyexCYUSXjR4cG00dzOUHHMt5hT1v3/UJN796KCMxRTGr4fKP1I01aRKR2uOeKNAO4=----ATTACHMENT:----NTI1MjAyNjA0MTUyODU4OSA0NjQyNTA5NDM1MTcyNTU4IDQ4MDgyMjE3MzA3MTY3Nzk=