-
Notifications
You must be signed in to change notification settings - Fork 885
Use timestamp column type for phinxlog if addTimestampsUseDateTime flag disabled #2401
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: 0.x
Are you sure you want to change the base?
Conversation
qnnp-me
commented
Dec 8, 2025
- Change start_time column type to datetime
- Change end_time column type to datetime
- Change start_time column type to datetime - Change end_time column type to datetime
|
Just for my curious, what problem should these changes fix?) |
for "2038-01-19 03:14:07 UTC" |
|
In general datetime nowadays is sure a better default for normal use. |
- Introduce a FeatureFlags class to control the type of timestamp columns - Select DATETIME or TIMESTAMP type based on the addTimestampsUseDateTime flag - Update the timestamp column creation logic in the schema table to support dynamic type selection
Overall, using DATETIME as the default is indeed a better choice for general use today. Regarding your concern about backward compatibility (BC), this has been addressed in the code. By introducing the |
|
@qnnp-me what if it would be possible to change column type automatically?) if feature flag is provided, of course. To update the existing table in the database. |
|
@lutdev I agree with your approach. For new projects, setting the preferred column type early via the feature flag is ideal. For existing projects, automatically changing column types based on the flag could be risky and unexpected. Instead, developers can manually create and run a migration script when needed to update their tables. This keeps control with the developer and avoids unintended changes to production databases. |
MasterOdin
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you update the docs for the feature flag to indicate that it also modifies the behavior of creating the phinxlog table in https://github.com/cakephp/phinx/blob/0.x/docs/en/configuration.rst#feature-flags as well as its docstring (
phinx/src/Phinx/Config/FeatureFlags.php
Line 26 in cea9c12
| * @var bool Should Phinx create datetime columns for addTimestamps instead of timestamp? |
|
When I put out the next version with this PR, I will include in the notes on updating the phinxlog column types manually for those on older versions. I agree that I don't think it's worth trying to automatically migrate folks. |
…mments - Added explanation in the configuration documentation regarding the impact of the `add_timestamps_use_datetime` setting on the schema table - Updated the comments for `addTimestampsUseDateTime` in the FeatureFlags class to clarify its effect on the schema table - Ensured consistency between the documentation and code comments