Skip to content

Commit

Permalink
Fix for migrations that do not conform to specification which resulte…
Browse files Browse the repository at this point in the history
…d in the migrationId being blank
  • Loading branch information
andrevanzuydam committed Jan 18, 2024
1 parent c762911 commit 28cdfd2
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions Tina4/Database/Migration.php
Original file line number Diff line number Diff line change
Expand Up @@ -148,11 +148,6 @@ final public function doMigration(): string
//Get first 14 characters (length of migration id column)
$migrationId = substr($fileParts[0], 0, 14);

//Fix if we end up with weird migrations which do not conform to the spec
if (empty($migrationId)) {
$migrationId = substr($entry, 0, 14);
}

//Get the rest of the string
$leftOverFileParts = substr($fileParts[0], 14, strlen($fileParts[0]));
unset($fileParts[0]);
Expand All @@ -168,6 +163,11 @@ final public function doMigration(): string
$migrationText = $leftOverFileParts . implode(" ", $fileParts);
}

//Fix if we end up with weird migrations which do not conform to the spec
if (empty($migrationId)) {
$migrationId = substr($entry, 0, 14);
}

$sqlCheck = "select * from tina4_migration where migration_id = '{$migrationId}'";
$record = $this->DBA->fetch($sqlCheck)->AsObject();
if (!empty($record)) {
Expand Down

0 comments on commit 28cdfd2

Please sign in to comment.