Skip to content

Feature: disable individual timestamps - #23

Open
circulon wants to merge 6 commits into
masonitedev:3.xfrom
circulon:feature/disable_individual_timestamps
Open

Feature: disable individual timestamps#23
circulon wants to merge 6 commits into
masonitedev:3.xfrom
circulon:feature/disable_individual_timestamps

Conversation

@circulon

@circulon circulon commented Aug 5, 2026

Copy link
Copy Markdown
Collaborator

Summary

Currently when using automatic timestamps it an all or nothing scenario on the Model.
this means that if you want a single timestamp eg craeted_at you must add the column to the migration and the model.
The use case is that some tables like log history only need a craeted attribute and this simplifies things considerably

This PR addresses the following:

  • In Migrations

    • disable individual timestamps via .timestamps(created=False) or .timestamps(updated=False)
      • NOTE: if both parameters are False an Exception is thrown
    • customise the timestamp column names via .timestamps(created="created_on", updated="updated_on")
  • I the Model

    • disable the individual timestamp columns via date_created_at = False or date_updated_at = False
      • this matches the migrations mechanism
      • NOTE: if __timestamps__ = True and both the date_xxx_at attributes are empty then an AttributeError is thrown notinfying the user
    • customising the column names via date_created_at = "created_on" or date_updated_at = "updated_on" then aligns with the migration

Additional:

  • Fixed the Postgres Alter column ignoring the premapped_defaults if they were used generating possibly invalid sql

This also addresses the postgres alter timestamp issue in #19

Allows the ‘date_created_at’ or ‘date_updated_at’ columns to be disabled individually per model.
Throws an AttributeError if timestamps (__timestamps__ = True) and both the ‘date_xxx_at’ attribuses are not set
fix altercolumn was adding  length even if not set
also fixed premapped defaults ignored on altered columns eg “current”, now
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant