Simplify database migrations
This commit is contained in:
parent
46d5b06bfc
commit
e6809c95db
106 changed files with 4661 additions and 6814 deletions
|
@ -3,37 +3,21 @@
|
|||
|
||||
import type { Database } from '@signalapp/sqlcipher';
|
||||
|
||||
import type { LoggerType } from '../../types/Logging';
|
||||
export default function updateToSchemaVersion74(db: Database): void {
|
||||
db.exec(
|
||||
`
|
||||
-- Previously: (isUserInitiatedMessage)
|
||||
DROP INDEX message_user_initiated;
|
||||
|
||||
export default function updateToSchemaVersion74(
|
||||
currentVersion: number,
|
||||
db: Database,
|
||||
logger: LoggerType
|
||||
): void {
|
||||
if (currentVersion >= 74) {
|
||||
return;
|
||||
}
|
||||
CREATE INDEX message_user_initiated ON messages (conversationId, isUserInitiatedMessage);
|
||||
|
||||
db.transaction(() => {
|
||||
db.exec(
|
||||
`
|
||||
-- Previously: (isUserInitiatedMessage)
|
||||
DROP INDEX message_user_initiated;
|
||||
-- Previously: (unread, conversationId)
|
||||
DROP INDEX reactions_unread;
|
||||
|
||||
CREATE INDEX message_user_initiated ON messages (conversationId, isUserInitiatedMessage);
|
||||
|
||||
-- Previously: (unread, conversationId)
|
||||
DROP INDEX reactions_unread;
|
||||
|
||||
CREATE INDEX reactions_unread ON reactions (
|
||||
conversationId,
|
||||
unread
|
||||
);
|
||||
`
|
||||
CREATE INDEX reactions_unread ON reactions (
|
||||
conversationId,
|
||||
unread
|
||||
);
|
||||
|
||||
db.pragma('user_version = 74');
|
||||
})();
|
||||
|
||||
logger.info('updateToSchemaVersion74: success!');
|
||||
`
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue