fix(mana-events): cascade rate buckets when an event is unpublished

Add an ON DELETE CASCADE FK from rsvp_rate_buckets.token to
events_published.token. Without it, deleting a snapshot left orphaned
rate-limit rows behind, slowly leaking storage. Verified with a
direct SQL cascade test.
This commit is contained in:
Till JS 2026-04-07 16:20:05 +02:00
parent 59a9c05872
commit e7585fb870

View file

@ -74,7 +74,9 @@ export const publicRsvps = eventsSchema.table(
export const rsvpRateBuckets = eventsSchema.table(
'rsvp_rate_buckets',
{
token: text('token').notNull(),
token: text('token')
.notNull()
.references(() => eventsPublished.token, { onDelete: 'cascade' }),
hourBucket: text('hour_bucket').notNull(), // YYYY-MM-DDTHH
count: integer('count').default(0).notNull(),
},