-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add patch to set maximum precision of timestamp DB columns [API-378]
When running unit tests, running all the migrations on the project on a new database was throwing errors related to the precision of timestamp fields. This was fixed in Laravel 9, so until then we'll patch the package causing the issue.
- Loading branch information
Showing
3 changed files
with
55 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
13 changes: 13 additions & 0 deletions
13
patches/API-378---set-maximum-precision-for-timestamp-types.diff
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
diff --git a/src/TimestampType.php b/src/TimestampType.php | ||
index 67c1126..6430e4a 100644 | ||
--- a/src/TimestampType.php | ||
+++ b/src/TimestampType.php | ||
@@ -45,7 +45,7 @@ class TimestampType extends Type | ||
*/ | ||
protected function getMysqlPlatformSQLDeclaration(array $fieldDeclaration) | ||
{ | ||
- $columnType = $fieldDeclaration['precision'] ? "TIMESTAMP({$fieldDeclaration['precision']})" : 'TIMESTAMP'; | ||
+ $columnType = $fieldDeclaration['precision'] ? "TIMESTAMP(".min((int) $fieldDeclaration['precision'], 6).")" : 'TIMESTAMP'; | ||
|
||
if (isset($fieldDeclaration['notnull']) && $fieldDeclaration['notnull'] == true) { | ||
return $columnType; |