From 270804d62da698b97de8a1ddefc2fd4ce242b137 Mon Sep 17 00:00:00 2001 From: Fedor Indutny <79877362+indutny-signal@users.noreply.github.com> Date: Mon, 30 Jan 2023 11:55:38 -0800 Subject: [PATCH] Reorder migrations --- ts/sql/migrations/75-noop.ts | 25 +++++++++++++++++++ ...al-tokenizer.ts => 77-signal-tokenizer.ts} | 8 +++--- ts/sql/migrations/index.ts | 4 ++- 3 files changed, 32 insertions(+), 5 deletions(-) create mode 100644 ts/sql/migrations/75-noop.ts rename ts/sql/migrations/{75-signal-tokenizer.ts => 77-signal-tokenizer.ts} (83%) diff --git a/ts/sql/migrations/75-noop.ts b/ts/sql/migrations/75-noop.ts new file mode 100644 index 000000000000..41bb20dc760d --- /dev/null +++ b/ts/sql/migrations/75-noop.ts @@ -0,0 +1,25 @@ +// Copyright 2023 Signal Messenger, LLC +// SPDX-License-Identifier: AGPL-3.0-only + +import type { Database } from '@signalapp/better-sqlite3'; + +import type { LoggerType } from '../../types/Logging'; + +export default function updateToSchemaVersion75( + currentVersion: number, + db: Database, + logger: LoggerType +): void { + if (currentVersion >= 75) { + return; + } + + db.transaction(() => { + // This was previously a FTS5 migration, but we had to reorder the + // migrations for backports. + // See: migrations 76 and 77. + db.pragma('user_version = 75'); + })(); + + logger.info('updateToSchemaVersion75: success!'); +} diff --git a/ts/sql/migrations/75-signal-tokenizer.ts b/ts/sql/migrations/77-signal-tokenizer.ts similarity index 83% rename from ts/sql/migrations/75-signal-tokenizer.ts rename to ts/sql/migrations/77-signal-tokenizer.ts index 149523dbc43f..1470dd866f76 100644 --- a/ts/sql/migrations/75-signal-tokenizer.ts +++ b/ts/sql/migrations/77-signal-tokenizer.ts @@ -5,12 +5,12 @@ import type { Database } from '@signalapp/better-sqlite3'; import type { LoggerType } from '../../types/Logging'; -export default function updateToSchemaVersion75( +export default function updateToSchemaVersion77( currentVersion: number, db: Database, logger: LoggerType ): void { - if (currentVersion >= 75) { + if (currentVersion >= 77) { return; } @@ -37,8 +37,8 @@ export default function updateToSchemaVersion75( ` ); - db.pragma('user_version = 75'); + db.pragma('user_version = 77'); })(); - logger.info('updateToSchemaVersion75: success!'); + logger.info('updateToSchemaVersion77: success!'); } diff --git a/ts/sql/migrations/index.ts b/ts/sql/migrations/index.ts index 6c2595d21594..a45c7eb9ff1d 100644 --- a/ts/sql/migrations/index.ts +++ b/ts/sql/migrations/index.ts @@ -50,8 +50,9 @@ import updateToSchemaVersion71 from './71-merge-notifications'; import updateToSchemaVersion72 from './72-optimize-call-id-message-lookup'; import updateToSchemaVersion73 from './73-remove-phone-number-discovery'; import updateToSchemaVersion74 from './74-optimize-convo-open'; -import updateToSchemaVersion75 from './75-signal-tokenizer'; +import updateToSchemaVersion75 from './75-noop'; import updateToSchemaVersion76 from './76-optimize-convo-open-2'; +import updateToSchemaVersion77 from './77-signal-tokenizer'; function updateToSchemaVersion1( currentVersion: number, @@ -1973,6 +1974,7 @@ export const SCHEMA_VERSIONS = [ updateToSchemaVersion74, updateToSchemaVersion75, updateToSchemaVersion76, + updateToSchemaVersion77, ]; export function updateSchema(db: Database, logger: LoggerType): void {