Skip to content

Commit

Permalink
Fix for migration issues
Browse files Browse the repository at this point in the history
Fix for content type response
  • Loading branch information
andrevanzuydam committed Jan 3, 2024
1 parent a4cfb0f commit e4b6e13
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
9 changes: 7 additions & 2 deletions Tina4/Database/Migration.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,9 @@ public function __construct(string $migrationPath = "./migrations", string $deli
$this->migrationPath .= "/" . $this->DBA->getShortName();
$this->runRootMigrations = true;
} else {
\Tina4\Debug::message("Please upgrade the database driver to include getShortName method for migrations", TINA4_LOG_DEBUG);
if (!method_exists($this->DBA, "getShortName")) {
\Tina4\Debug::message("Please upgrade the database driver to include getShortName method for migrations", TINA4_LOG_DEBUG);
}
}

//Turn off auto commits so we can roll back
Expand Down Expand Up @@ -223,6 +225,7 @@ final public function doMigration(): string
if ($error) {
$result .= "<span style=\"color:red;\">FAILED: \"{$migrationId} {$description}\"</span>\nAll Transactions Rolled Back ...\n";
$this->DBA->rollback($transId);
break;
} else {
$this->DBA->commit($transId);

Expand All @@ -248,12 +251,14 @@ final public function doMigration(): string
error_reporting(E_ALL);
$result .= "</pre>";



if ($this->runRootMigrations) {
//get rid of the database path
$this->migrationPath = str_replace("/".$this->DBA->getShortName(), "", $this->migrationPath);
$this->runRootMigrations = false;
$result .= $this->doMigration();

file_put_contents("./log/migrations.html", $result, FILE_APPEND);
}

return $result;
Expand Down
2 changes: 1 addition & 1 deletion Tina4/Tina4Php.php
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ public function __toString(): string
}
}
}
header("Content-Type: " . $routerResponse->contentType);
header($routerResponse->contentType);
http_response_code($routerResponse->httpCode);
if ($routerResponse->content === "") {
//try give back a response based on the error code - first templates then public
Expand Down

0 comments on commit e4b6e13

Please sign in to comment.