From 1ad5e561ee77481611978e19a8d18795a4aa4482 Mon Sep 17 00:00:00 2001 From: Kit Loong Date: Mon, 4 Nov 2024 11:56:04 +0800 Subject: [PATCH] Add comment to `flattenCurrentTimestamp` --- src/Database/Models/MySQL/MySQLColumn.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/Database/Models/MySQL/MySQLColumn.php b/src/Database/Models/MySQL/MySQLColumn.php index 0791aa9..ff968e8 100644 --- a/src/Database/Models/MySQL/MySQLColumn.php +++ b/src/Database/Models/MySQL/MySQLColumn.php @@ -358,6 +358,12 @@ private function getMariaDBColumnDefault(?string $columnDefault): ?string }; } + /** + * Set the default value to `CURRENT_TIMESTAMP` if the value is `CURRENT_TIMESTAMP(2)`, `CURRENT_TIMESTAMP(3)`, ... `CURRENT_TIMESTAMP(n)`. + * This function is needed so that + * column type `datetime(2) DEFAULT CURRENT_TIMESTAMP(2)` would be generated as + * `dateTime('datetime', 2)->useCurrent()`. + */ private function flattenCurrentTimestamp(): void { if ($this->default === null) {