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:----h8cSTVw6Nz3SiDkQ9L0WZdl7YFcCies6kUePcF62WhVql3mNp7sIUsYtPYFrw60io/ggLjWYLePWoX9tM/rUUWZb2T+9UM+7AFz3Y3NtbLdAokd1rD4BbTvUUp0HmCxRko4P97dohZif+/aUJMa9AKzu73TG8JPX0yyQWM36uClwosrDpuRWQakmJulEu/LGq4CXIwejE6gPaCHbUEmIVRH9D4CH0aEJgTIIN83NxK8+fZpMff2EcjVMUuqe3DaQwfzWDMSaPxMsuUthw9F0PQkX4BSoR6R2zAPkVsQCaX0e87mVXZSxczzwYPRi7aVcKqCk3+Yt/kyDjmN/yRJQJZ6sbfCAKHgMStnB84pCM4D965/s3GU8rGdOgiaaTpWRg+Hg9sMi2l4Co1WtiSW3yZ2hYLliA7TgCFn6skdzTwL5byhoO8F5sRkky/tNZ5PDLX2AfT6CxTCsNJ6+0W1SuQg2XqifgKp1dCfvTP6uutS4sF0qlHsmrnrxffhDpSjbNr6w6iwrg9l6o4zjes1V5tsGinMDTotZh/noZjFGqAXfMBn76QqVL2rw6NEArnzs49/KQTAy1pYddPNFRwa8uWnJFLk+/WEDdspJbR5VHPMMZoUzbB2hr07IUQMXicxOwXQgPDrLjIzut8N0HT/CjbODpzZ5jjkBx5jOFf8QlUY=----ATTACHMENT:----ODU3NDYyNzMxMDI5NDgyMyA4OTI3NTA3NjI3MzczNTEzIDc4MTU2ODA5Mjc3NjMxMzM=