Index moderation case references for database integrity checks
CI / checks (push) Successful in 7m31s
CI / checks (push) Successful in 7m31s
This commit is contained in:
@@ -34,7 +34,8 @@ import {
|
||||
migrateModerationCaseActions,
|
||||
migrateModerationCaseAssessments,
|
||||
migrateModerationCaseRelationships,
|
||||
migrateModerationCaseFollowups
|
||||
migrateModerationCaseFollowups,
|
||||
migrateModerationCaseReferenceIndexes
|
||||
} from '../moderation/schema.js';
|
||||
import type { Migration } from './migration-runner.js';
|
||||
|
||||
@@ -197,6 +198,11 @@ export const migrations: readonly Migration[] = [
|
||||
version: 34,
|
||||
name: 'moderation follow-up dates and personal updates',
|
||||
run: migrateModerationCaseFollowups
|
||||
},
|
||||
{
|
||||
version: 35,
|
||||
name: 'moderation case foreign key reference indexes',
|
||||
run: migrateModerationCaseReferenceIndexes
|
||||
}
|
||||
];
|
||||
|
||||
|
||||
@@ -223,3 +223,15 @@ export function migrateModerationCaseFollowups(handle: Database.Database): void
|
||||
CREATE INDEX IF NOT EXISTS moderation_case_notifications_case ON moderation_case_notifications(user_id,case_id,read_at,id DESC);
|
||||
`);
|
||||
}
|
||||
|
||||
/** Foreign-key lookups must cover removed relationships and every notification recipient. */
|
||||
export function migrateModerationCaseReferenceIndexes(handle: Database.Database): void {
|
||||
handle.exec(`
|
||||
CREATE INDEX IF NOT EXISTS moderation_case_review_sanction
|
||||
ON moderation_cases(review_sanction_id);
|
||||
CREATE INDEX IF NOT EXISTS moderation_case_relationship_source
|
||||
ON moderation_case_relationships(case_id,removed_at);
|
||||
CREATE INDEX IF NOT EXISTS moderation_case_notifications_parent
|
||||
ON moderation_case_notifications(case_id);
|
||||
`);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user