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:----CLOJHEE8NagDoQjbXG+rLtTPihScGjwgOR801OX7zWTxQLAlf7lkYkg2i24AWk2DnOwuLy8UL8CGkQToDxUgmyQalbKisdUSbFuShacxU1prEyqY6jZoBtwpYfPJFRfOvTe8J1D2zJfoFxAA9aiMjEJGHOBPf6TSFC+qQLaM4KN1Jb9KRjbPdhJ2O4rSpz1tRWhQyDinMmGQNcgBDdUe/KZtIBrbyuFh98vXlygiOq5Fjsxp8UEsuT+4rxT81Re2yXVaH9b9fEygHg+ZbaywGEuP+SHZgGPbwGq7d2hi7mRZfAt5AliddtErr8XDEZXRxoYbOE4q27RLEvPZv6fxeOxW9ppyviDMco2OaW3UjseS/vCqu1feyG+bcJ3/9ifDyBlZvEKdiJAUVbUDPc/AFJSQLX/I2EnzaxIPlWhHs6ROPijX3SfblGIZeaEPVnuhhSBjw9mz0w4yX1kX5e85r1Y1on9U4XJeJCxHF4XEhjbqO50JPU8IIlheiJkxQaisYutNHPwwdWYK8SvJ7m7wMNazzTGLym/tC2jm4+XFQTwOx6hIonPCK0tbCrwECph3FR9k6O8oyftlQ6sQV5eOw5YcQ5RDcngH17HBEvKtJCBt2XxNVzzr4YHJe/sg5B24u1F2C22q4GAYAUtH5IrNNyKAoJ1v/fx/joGxFYMOKJI=----ATTACHMENT:----NTQ1Nzk2MjQ3Njg1MzY3MCA2MjY2NDQ5NDAxODE5Nzc0IDQyNzk1ODkwODI2OTE5ODI=