Ejemplo n.º 1
0
 /**
  * @param SqlFile $file
  * @throws MigrationException
  */
 private function log(SqlFile $file, $success)
 {
     $statement = $this->pdo->prepare("insert into installed_migrations(installation_time, migration_file_name, migration_file_checksum, success) values(now(), ?, ?, ?)");
     try {
         $success = $statement->execute([$file->getFile()->getFilename(), $file->getHash(), $success === true ? "true" : "false"]);
         if ($success === false) {
             throw new MigrationException("Could not write to installed_migrations table: " . var_export($statement->errorInfo(), true));
         }
     } finally {
         $statement->closeCursor();
     }
 }
Ejemplo n.º 2
0
 private function validateChecksum(SqlFile $file, Migration $migration)
 {
     if ($file->getHash() !== $migration->getChecksum()) {
         throw new MigrationException("Migration " . $file->getFile()->getFilename() . " is already installed, but it's contents were modified afterwards. Checksum at installation time: " . $migration->getChecksum() . "; current checksum: " . $file->getHash());
     }
 }