Migration Guide: 9.12.0 → 9.12.1
Osumi Framework 9.12.1 adds support for CURRENT_TIMESTAMP as a dynamic default value for DATETIME fields.
This release fixes a case discovered while using generateModelFromDB against real-world databases.
CURRENT_TIMESTAMP
In 9.12.0, an SQL column such as:
`joined_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP
could not be represented by the ORM.
generateModelFromDB correctly detected the field as OField::DATETIME, but rejected CURRENT_TIMESTAMP because ORM default values only supported literal values.
Starting with 9.12.1 it can be represented as:
#[OField(
type: OField::DATETIME,
nullable: false,
default: OField::CURRENT_TIMESTAMP
)]
public ?string $joined_at = null;
When the SQL schema is generated again, the expression is preserved:
`joined_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP
generateModelFromDB
generateModelFromDB now recognizes both common representations returned by MariaDB:
CURRENT_TIMESTAMP
CURRENT_TIMESTAMP()
Both are converted to:
default: OField::CURRENT_TIMESTAMP
This support is explicitly limited to OField::DATETIME fields.
Arbitrary SQL expressions such as UUID() remain unsupported because the ORM cannot represent them safely.
Literal Values
OField::CURRENT_TIMESTAMP is a special ORM value.
It must not be confused with a literal string:
default: 'CURRENT_TIMESTAMP'
A string with that content remains a normal text value when allowed by the field type.
Runtime
When a new model contains a DATETIME field with:
default: OField::CURRENT_TIMESTAMP
the ORM resolves it to the current timestamp in:
Y-m-d H:i:s
format when default values are applied before the record is saved.
Migration
There is no new automatic migration step for 9.12.1.
Existing 9.12.0 models do not require changes unless they represent a DATETIME column whose database default is CURRENT_TIMESTAMP.
In that case, generateModelFromDB can now regenerate the definition correctly.
Updating
Update normally through Composer:
composer update osumionline/framework --with-dependencies
After updating, you can run again:
php of generateModelFromDB