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:----SJ9I9om8smQIp6V7so64mXwVsTmUO/9gnFLlsyHcDMVXuA8WxOULGQUzKHmNdPiLXxv6kHhRuUD/eb40bB7k+csacpTNlqixxI7DnA3SDU917M+Pz+wsXfzfO878hIILrC8aseTUMKSfKM+lXKOHv5qRFEbVwTn6mF/KY/nynocou1Ip7B3Kc25ru9V6G2ONCMAbOJhI7OtxZLYuAxHsG0b1WtZ3fkH/0c1hXlJgxZ7dTevcMyb+ni5iIlUc/Li67f52tdXizjoJZ+YYh8tiKEjyR3T8iDHB4jMg8FcoukrUgFGYT67pI3YcQX7IdyLtmyfBvv9PEI4L3+b0C6+M40mMB+zJxbo8yvBwbEolWo/BV8rg9NhHrqt/HKCWNlx4YJr7Trao5tjITQK+5OUViEaU2GhgvSAhkCEa1E96EXirvVsUPK8dddvBhbDIJeG7pfJPTsdoD0wDjlYE27ro1MUpJzbdXRfNarMAu7MYtZp0+znTurrnbmQSrF/YipBud1Cr96jULeLw09bp/FXGVlydLNAb0UX74IK66CTTPrkHfXiOZ1kQbh1jJtOdGJbT3eLYxZGAyHCf5dYPXlX0j4w94Zyp2IhVesMHvkEinUHO4yuE7qsWcVu8qnbQdOZ56m6n7EIRh2zkNFFVCLkgqwaw53pRPOYtZEm3pHNb9IQ=----ATTACHMENT:----NjYyMDQ3NzExODY4NDY5NiAzMDczNzg5MDYzMDM2MjkzIDY4Nzg3NTk5MTMyOTg2MzQ=