phinx icon indicating copy to clipboard operation
phinx copied to clipboard

refactor(db): Change timestamp column types to datetime

Open qnnp-me opened this issue 2 months ago • 6 comments

  • Change start_time column type to datetime
  • Change end_time column type to datetime

qnnp-me avatar Dec 08 '25 08:12 qnnp-me

Just for my curious, what problem should these changes fix?)

lutdev avatar Dec 08 '25 12:12 lutdev

Just for my curious, what problem should these changes fix?)

for "2038-01-19 03:14:07 UTC"

qnnp-me avatar Dec 08 '25 15:12 qnnp-me

In general datetime nowadays is sure a better default for normal use. I wonder though if this is BC in this case.

dereuromark avatar Dec 08 '25 16:12 dereuromark

In general datetime nowadays is sure a better default for normal use. I wonder though if this is BC in this case.

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 FeatureFlags::$addTimestampsUseDateTime flag, the system can now dynamically choose between DATETIME and TIMESTAMP column types, ensuring that existing behaviors remain unaffected while allowing the improved default for new implementations.

qnnp-me avatar Dec 09 '25 07:12 qnnp-me

@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 avatar Dec 09 '25 08:12 lutdev

@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.

qnnp-me avatar Dec 09 '25 09:12 qnnp-me

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.

MasterOdin avatar Dec 12 '25 19:12 MasterOdin

@MasterOdin Done. Ready for final review.

qnnp-me avatar Dec 13 '25 13:12 qnnp-me