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:----fHkIPLKZ/1uSO/lm+ZCB8Aq/8EXhPl1S/rQKXUsUdFCQBwidQmGusk71Fw1zo42HBMVq6va+0s5JTossbmD45hPSnjl1r2uSJmcTrrimACQW0sGouZ7JHL66lZcGnLJbPeWRJZC0coEei8zTSdXtR+vJhbQqOgaxBzwKYyUi9SikfRCoNjf3Qf6oZ0Q0FwHhB6BK/PvGuEyCitM/nWSayYAY7SjDdgGsNd7vJyc4ClgOT+EsYlVcQVyWXU/GLGd8cZjGO+tX8fAAdeJkYUqy/ZXevTUfHK7PvFts+uFMo0lDEBdqpeVUATZVCV/Yle6WTwANfp2hZBo5GT5qR5WxvdRtbxfdYP3kSOHC/xI+YXzO9PqnbQMfl7jsto8LFMkQTHiGTRgtARxoRlP2FLYR4AYXD9+TzhgoWy0anUyqBARaVxgKAy1HxH9onO+oyKKzOLV/gfHp0oGvI2nn1CqjKBExcHPr3kEv3zAOi/h8vscMpoHkp5ZTSOD1aCmCSRDQ4IJ/lzc9eLi6XmaoOb3/rdCxHFrABDe0hcjIv21EfQzSFhKmlAAwjFm9qFT+wxF+CO8jXcC7BbhOIVY1P9HykitWHInvM++ZVa8SxQIs6NJvpBM7SmibJ9b7pGNYqoVcXirq33pIhL+/NiAlgCjZ2hjUYbjfDzMzi/CLfZ5qgBc=----ATTACHMENT:----OTE5NDAzMjAzMTA1MzMzOSA5MTQ0MzYxMzIxNDQ2MTcwIDU4NjEzNjYzODQ4MzI1Nzc=