Files
Desktop/ts/sql/migrations/1520-poll-votes-unread.std.ts
2025-11-12 09:26:16 -06:00

19 lines
630 B
TypeScript

// Copyright 2025 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only
import type { Database } from '@signalapp/sqlcipher';
export default function updateToSchemaVersion1510(db: Database): void {
db.exec(`
-- Add hasUnreadPollVotes column to messages table
ALTER TABLE messages ADD COLUMN hasUnreadPollVotes INTEGER NOT NULL DEFAULT 0;
-- Create partial index for efficient queries
-- Only indexes rows where hasUnreadPollVotes = 1
CREATE INDEX messages_unread_poll_votes ON messages (
conversationId,
received_at
) WHERE hasUnreadPollVotes = 1 AND type IS 'outgoing';
`);
}