Add created
to group membership model
#9184
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Add a
created
column tomodels.GroupMembership
.Fixes #9103. This should automatically mean that new group memberships get their created and updated times tracked, without any further changes.
Before we can merge this PR we'll need a migration to add the new columns.
Then after merging this PR we'll need another PR to add the created date to the responses from various APIs.
While we're doing this, might as well add
updated
as well.There's a desire for this column to be nullable so that pre-existing
memberships can have
NULL
in this column, see:https://hypothes-is.slack.com/archives/C4K6M7P5E/p1733330444569829
For that reason we can't use
h.db.mixins.Timestamps
because that mixinadds non-nullable
created
andupdated
columns.I don't think it really matters but if we did change the
GroupMembership
model to inherit from theTimestamps
mixin thatwould add the
created
andupdated
columns to the start of thetable, whereas in the staging and production DBs a migration is going to
add the new columns to the end of the table. Meaning that DBs created
from the models (e.g. in dev and on CI) would actually have the columns
in a different order than staging and production. Not sure if there
would be a way to fix the column order while using
mixins.Timestamps
.Moot point anyway since we need them to be nullable.