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:----0KRWF77OUVOP0PpyxV6nDuy/Wd9b4oGuPNaLvHr5DAUqRbwCWEQs82J1GdGVl0SIsNO4E2hIkPdB9BAwj1DsESbFGdhFS/udOxAfXSB3QmvXGp+t4c00n0MJvqCTOyL7JL9KNLsguhUqoXGQHVt7xhVvteG73TCSrt56nIydU/WWZRKZeilahBZwbJasLy7XbaQNqqO2iyZW66JCh88F/zp60B242+oEeJ/J5K5zaTfjRZmlOfh91c0RZADKlRL/0rNm5eUxIt6u75bFHMiI8kar0CrHw7xB4GcrowXCpvKN21qDqnj5uoU5smpt+HUyTC0pXCVAcTMqpCCk6hqiWGsRsUSteSZw/GMsEhtwK0hLOjA6CvdErz71SbeKJwtUBh/TX957Z7mbVVEHEs2FGCLlDMvaj2tcfwQ6cZ5XttNUvlPWOvYrFyupu8MDjn92bwSvsHYcFTEVR6nlpcecV0thqTR0a5xRjxOnLskdjJloegfsFrTOtSpk3m0jWsy2RhIlO62bKytHrAyx66IuUSC1fqu6D5wGI8SVEFQWrEgItKq0LGKna1v0grfC3sbL+0oLywHzfXMnB+ecDumlKFqTIUTJP6mLKKFIw7lzor6ELanRm/2Y8OGv4S/N/obICNEUltEM3hmz1jdIlPieZ4xKcvlaX27l/53kGZPaNa8=----ATTACHMENT:----OTUyMzA0NzM5OTg2ODY5MiA3ODc4MzU2OTI0OTY2MzY0IDYwNzgxNjIzNjk5ODU0MDM=