magento / magento/magento2-phpstorm-plugin

Please add created_at and updated_at as special property declarations in the entity properties (maybe datetime as type?)

Open
#2,554 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Java
Stars
463
Forks
98
Avg merge
1h 6m
Merged PRs (30d)
3

Description

Is your feature request related to a problem? Please describe.

I think it's very common to have created_at and updated_at dates in a model's properties to track information about when something was modified or for sorting purposes when retrieving the data.

Currently we have to set them as string but there's also a different issue with them. The save model, when the form submits them will treat them as any other property and save over them.

Usually we need to do extra steps to define them after we create the entity or we need to declare them in the dialog as string and then

  • start modifying the SaveEntityInterface to not tamper with them
  • modify the db_schema.xml to add the correct type and declarations

Describe the solution you'd like (*)

I'd like to be able to set created_at and updated_at properties easily as a field, where the db_schema.xml is properly defining it as timestamp

        <column xsi:type="timestamp" name="created_at" nullable="false" default="CURRENT_TIMESTAMP"
                onCreate="CURRENT_TIMESTAMP" comment="Created At Column"/>
        <column xsi:type="timestamp" name="updated_at" nullable="false" default="CURRENT_TIMESTAMP" on_update="true" comment="Updated At Column"/>

Describe alternatives you've considered

So far there's no better alternative than using string as type and modifying multiple files afterwards

Additional context

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing entity property declarations and the SaveEntityInterface behavior described in the issue, then inspect how db_schema.xml represents timestamp columns. Done means created_at and updated_at can be declared as special properties, generate the requested timestamp schema, and are not overwritten by form saves.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, php
Domain
databases, tooling
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.