Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ref(grouping): Add schema_version to GroupHashMetadata table #85300

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

lobsterkatie
Copy link
Member

As we change or add to the data we store in grouphash metadata, we want to be able to update data for grouphashes created before a given change was made. In order to do that, we need to keep track of which version of the grouphash metadata schema was active when a given grouphash's data was collected. This therefore adds a schema_version field to the table, and populates it for new GroupHashMetadata records.

@github-actions github-actions bot added the Scope: Backend Automatically applied to PRs that change backend components label Feb 14, 2025
@lobsterkatie lobsterkatie force-pushed the kmclb-add-grouphash-metadata-to-existing-grouphashes branch from bd7110d to d1779e0 Compare February 18, 2025 20:44
@lobsterkatie lobsterkatie force-pushed the kmclb-add-schema-version-to-grouphash-metadata-table branch from f7dca7f to c217cae Compare February 18, 2025 20:44
@lobsterkatie lobsterkatie force-pushed the kmclb-add-grouphash-metadata-to-existing-grouphashes branch from d1779e0 to 558d105 Compare February 18, 2025 22:44
@lobsterkatie lobsterkatie force-pushed the kmclb-add-schema-version-to-grouphash-metadata-table branch from c217cae to 4091f58 Compare February 18, 2025 22:44
Base automatically changed from kmclb-add-grouphash-metadata-to-existing-grouphashes to master February 20, 2025 17:20
@lobsterkatie lobsterkatie force-pushed the kmclb-add-schema-version-to-grouphash-metadata-table branch from 4091f58 to 467c959 Compare February 20, 2025 17:32
@getsentry getsentry deleted a comment from github-actions bot Feb 20, 2025
@lobsterkatie lobsterkatie force-pushed the kmclb-add-schema-version-to-grouphash-metadata-table branch from 467c959 to 5616bf8 Compare February 21, 2025 06:25
@lobsterkatie lobsterkatie marked this pull request as ready for review February 21, 2025 06:56
@lobsterkatie lobsterkatie requested review from a team as code owners February 21, 2025 06:56
@@ -53,6 +76,9 @@ class GroupHashMetadata(Model):
# When the grouphash was created. Will be null for grouphashes created before we started
# collecting metadata.
date_added = models.DateTimeField(default=timezone.now, null=True)
# The version of the metadata schema which produced the data. Useful for backfilling when we add
# to or change the data we collect and want to update existing records.
schema_version = models.CharField(null=True)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we planning to remove the null once all records are populated?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed. It'd be nice if postgres had some sort of progressively-non-null designation we could set - so that the constraint could be checked as records are touched in the course of normal operations - but AFAIK no such thing exists, so we'll probably have to just live with the nullability. (This goes for pretty much all the fields in the table.)

Copy link
Member

@markstory markstory left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Migration DDL looks good.

@lobsterkatie lobsterkatie force-pushed the kmclb-add-schema-version-to-grouphash-metadata-table branch from 5616bf8 to 8eea882 Compare February 21, 2025 18:30
Copy link
Contributor

This PR has a migration; here is the generated SQL for src/sentry/migrations/0835_add_schema_version_to_grouphash_metadata.py ()

--
-- Add field schema_version to grouphashmetadata
--
ALTER TABLE "sentry_grouphashmetadata" ADD COLUMN "schema_version" varchar NULL;

@getsentry getsentry deleted a comment from github-actions bot Feb 21, 2025
@lobsterkatie lobsterkatie force-pushed the kmclb-add-schema-version-to-grouphash-metadata-table branch from 8eea882 to f0a33e7 Compare February 22, 2025 01:14
@lobsterkatie lobsterkatie force-pushed the kmclb-add-schema-version-to-grouphash-metadata-table branch from f0a33e7 to 4e9e8e6 Compare February 22, 2025 01:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Scope: Backend Automatically applied to PRs that change backend components
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants