Fix incorrect created and created_ts columns in statistics database schema (#88462)

* Remove default from created statistics schema

We were still inserting created times because even though
None was passed when creating the object explictly, the
default would still be used

* adjust column

* preserve original pre sql alc 2.0 behavior
This commit is contained in:
J. Nick Koston 2023-02-19 20:00:49 -06:00 committed by GitHub
parent 68e1aaa0be
commit 9a6bcc2b63
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -513,10 +513,8 @@ class StatisticsBase:
"""Statistics base class."""
id: Mapped[int] = mapped_column(Integer, Identity(), primary_key=True)
created: Mapped[datetime] = mapped_column(
DATETIME_TYPE, default=dt_util.utcnow
) # No longer used
created_ts: Mapped[float] = mapped_column(TIMESTAMP_TYPE, default=time.time)
created: Mapped[datetime | None] = mapped_column(DATETIME_TYPE) # No longer used
created_ts: Mapped[float | None] = mapped_column(TIMESTAMP_TYPE, default=time.time)
metadata_id: Mapped[int | None] = mapped_column(
Integer,
ForeignKey(f"{TABLE_STATISTICS_META}.id", ondelete="CASCADE"),