Repository navigation
Conversation
Seven nullable columns on the message template, and a partial unique index on (team, key) for templates that are not deleted. The index is built concurrently in its own non-atomic migration. Nothing reads or writes the columns yet. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Merging to
After your PR is submitted to the merge queue, this comment will be automatically updated with its status. If the PR fails, failure details will also be posted here |
This was referenced Oct 16, 2026
Closed
Contributor
Author
|
Note 🤖 Claude Opus 5.5 writing on behalf of Michael Closing: #118924 now carries these migrations (0009 and 0010). |
This was referenced Oct 23, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Problem
Developers who keep email templates in their repository have no way to point PostHog at "the
welcometemplate" of a project.A message template has only a UUID, no owner, and no record of which file or content it came from.
The code-managed templates spec (Silthus/posthog#485) needs those columns before any upload or send-by-key route can exist.
Changes
Nothing changes for users yet. This is the migration-only base of the code-managed templates stack.
0007adds seven nullable columns toposthog_messagetemplate:key,managed_by(guiorcode),source_repository,source_path,source_ref,content_hashandsuperseded_content_hashes.0008adds a partial unique index on(team_id, key)for templates that have a key and are not deleted. A deleted template releases its key.0008builds the index withCREATE UNIQUE INDEX CONCURRENTLYthroughCreateIndexConcurrently, in its ownatomic = Falsemigration.help_textnow, so the serializer slice can expose the fields without anotherAlterFieldmigration.Important
#118664 also adds messaging migration
0007. Whichever PR lands second renumbers its migrations.Note
🔵 Merge risk: low · two-way door (merge-risk rubric)
ADD COLUMN ... NULLstatements take a brief lock onposthog_messagetemplate, which is not a hot table.keyis null after0007.0008and0007removes the index and the columns. No code writes them, so no data is lost.How did you test this code?
MessageTemplate.objects.createinproducts/messaging/backend/tests/test_message_template_key.py.MessageTemplate() got unexpected keyword arguments: 'key'.NOT "deleted"clause failstest_the_key_is_free_1_after_the_holder_is_deleted.analyze_migration_risk --fail-on-blocked: both migrations are Safe, none blocked.migrate messaging 0008and back to0005both run cleanly. The index and the columns appear, then disappear.Test rationale: the test catches a constraint that blocks the same key in another team, or that a deleted template keeps holding. No existing test covers message template keys. The test needs Postgres, because the rule lives in a partial index.
sqlmigrateoutputLocal migrate forward and back
Proofs owed per the proof rubric:
0007leaves every key null.Release status
Docs update
None. Nothing user-facing changes.
🤖 Agent context
Autonomy: Human-driven (agent-assisted)
Agent: Claude Code, Claude Opus 5.5
/tdd,/django-migrations,/writing-tests,/pr-description,/writing-pr-descriptions.unique_message_template_key_per_team, not the workflow one, because Postgres index names share one namespacehelp_textsits on the model now, to avoid a later no-SQL migration when the serializer exposes the fieldsmanaged_byusesmax_length=400and the same choices as the workflow columnInvolvement: 1 spec grilling round answered, 1 cross-model review (GPT-6.1 Sol, high: no findings at
a5dbb10), proof captured.🤖 Generated with Claude Code