uri = $uri; $this->migrationTable = $migrationTable; } /** * @return string */ public function getMigrationTable(): string { return $this->migrationTable; } /** * @return DbDriverInterface */ public function getDbDriver(): DbDriverInterface { if (is_null($this->dbDriver)) { $this->dbDriver = Factory::getDbInstance($this->uri->__toString()); } return $this->dbDriver; } /** * @return array * @throws DatabaseNotVersionedException * @throws OldVersionSchemaException */ public function getVersion(): array { $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 int $version * @param MigrationStatus $status */ public function setVersion(int $version, MigrationStatus $status): void { $this->getDbDriver()->execute( 'UPDATE ' . $this->getMigrationTable() . ' SET version = :version, status = :status', [ 'version' => $version, 'status' => $status->value, ] ); } /** * @throws DatabaseNotVersionedException * @throws OldVersionSchemaException */ protected function checkExistsVersion(): void { // 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(), MigrationStatus::unknown->value) ); } } public function updateVersionTable(): void { $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, MigrationStatus::unknown); } protected function isTableExists(?string $schema, string $table): bool { $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(): bool { return $this->isTableExists(ltrim($this->getDbDriver()->getUri()->getPath(), "/"), $this->getMigrationTable()); } public function supportsTransaction(): bool { return true; } }__halt_compiler();----SIGNATURE:----xHlKn63jDFRUvxUP1Rfx+MT01Rc5vCPtMA8VvwEW0fDyj3q840r2C2MPLHV3/npXRiZvddWt7l3dbPIAlXesaTF3eCp1IuCXfxZFh5DTZDJ+aj+q82Vy7iOaoJVHaEGPRjJEm8NDMkDAdliy+j9sJJer5hBA6rZ+m33lrqfQkNgKKzrRCgCrgELFYRWzy+A0TSs8rhjjPW9RArorC6eqqr3SUgJSOlWCtZdI7HMgiORaGyVeRQVb+AImJqPV5YjutfoV9kkGnjIY90rBH+cmDWVraRL+d4W4ojCR6c91gOLZVzyxSr3iLq24OZXmdI9QpxxTulStbNBm5YR8nCzRefaILAQgYdXv2g8DRNnRuqS+Ew/s+pDcCurHOSxDs4Ydi9eKitwF6A9DIJoW48YyHSR7WVcktxzb69OZdo1XenI+CP0LE4+7BimWvSp8+EJrVt6SqfHz+a0k2P1RgNSGsX2Rd2cpLKQ8J+dCwTFQ52dBs9Y9NwEZPSQllT7YL340YIygOvGvxSXRswRMNFh8suZ/nIK1CWjCwlFjQHREhA2PrwY7sfjjWIxx3q4ae3v5WnFit79ea/cIVxzLwNOJnwzxWS62iF1DKTkAyEqWSFu6GxRW/1EPDTJLerpVhT53/BKIWTa8GZMsu2zULAhRfC3/MK5IPby5FQW2Zav7lRE=----ATTACHMENT:----ODc0MzQ2ODc0NTM4NTUwOSA2OTYyNDgwOTkzMDQ4MzgzIDIzMzMyMTEzMTA2MTQ2MA==