Write Django ORM queries, raw SQL, and transactions that work on Sentry's production databases. Use when writing or reviewing database access code in Sentry. Not for migration files (use generate-migration) or model design (use django-models).
95%
Does it follow best practices?
Run evals on this skill
Adds up to 20 points to the overall score
Passed
No findings from the security scan
Within a silo, production keeps some tables on separate Postgres databases. The router picks the connection per model, so single-table ORM calls just work, but one SQL statement or one transaction cannot span two databases. Tests rarely catch this: Sentry's test router (TestSiloMultiDatabaseRouter in src/sentry/db/router.py) splits out only the cron monitor tables.
The table-to-database map is _default_db_routing_map in getsentry's getsentry/db/router.py. Unlisted tables are on default, and SENTRY_DB_ROUTING_MAP_OVERRIDES in getsentry/conf/settings/ adds per-environment entries. Read it from a getsentry checkout (usually a sibling of this repo) or with gh api -H "Accept: application/vnd.github.raw" repos/getsentry/getsentry/contents/getsentry/db/router.py. If you cannot read getsentry, say so instead of assuming the tables share a database.
Look up every table involved before you:
id__in=<queryset>, Subquery/Exists, a join across a foreign key, or raw SQL. Across databases, run separate queries and pass IDs through Python (list(qs.values_list("id", flat=True))). For raw SQL, take the connection from the router (connections[router.db_for_read(Model)]), not django.db.connection.transaction.atomic block: it only covers the database named in using, usually router.db_for_write(Model).BoundedBigIntegerField ID column, as ReleaseFile.release_id does. A new table is on default unless it is added to the map.RunPython and SafeRunSQL also need routing hints. Use the generate-migration skill.getsentry/sentry
18139cf
If you maintain this skill, you can claim it as your own. Once claimed, you can manage eval scenarios, bundle related skills, attach documentation or rules, and ensure cross-agent compatibility.