Simplify database migrations
This commit is contained in:
parent
46d5b06bfc
commit
e6809c95db
106 changed files with 4661 additions and 6814 deletions
|
@ -1,38 +1,21 @@
|
|||
// Copyright 2025 Signal Messenger, LLC
|
||||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
import type { LoggerType } from '../../types/Logging';
|
||||
import { sql } from '../util';
|
||||
import type { WritableDB } from '../Interface';
|
||||
|
||||
export const version = 1320;
|
||||
export default function updateToSchemaVersion1320(db: WritableDB): void {
|
||||
const [query] = sql`
|
||||
DROP INDEX unprocessed_timestamp;
|
||||
|
||||
export function updateToSchemaVersion1320(
|
||||
currentVersion: number,
|
||||
db: WritableDB,
|
||||
logger: LoggerType
|
||||
): void {
|
||||
if (currentVersion >= 1320) {
|
||||
return;
|
||||
}
|
||||
ALTER TABLE unprocessed
|
||||
ADD COLUMN receivedAtDate INTEGER DEFAULT 0 NOT NULL;
|
||||
|
||||
db.transaction(() => {
|
||||
const [query] = sql`
|
||||
DROP INDEX unprocessed_timestamp;
|
||||
UPDATE unprocessed
|
||||
SET receivedAtDate = timestamp;
|
||||
|
||||
ALTER TABLE unprocessed
|
||||
ADD COLUMN receivedAtDate INTEGER DEFAULT 0 NOT NULL;
|
||||
|
||||
UPDATE unprocessed
|
||||
SET receivedAtDate = timestamp;
|
||||
|
||||
CREATE INDEX unprocessed_byReceivedAtDate ON unprocessed
|
||||
(receivedAtDate);
|
||||
`;
|
||||
db.exec(query);
|
||||
|
||||
db.pragma('user_version = 1320');
|
||||
})();
|
||||
|
||||
logger.info('updateToSchemaVersion1320: success!');
|
||||
CREATE INDEX unprocessed_byReceivedAtDate ON unprocessed
|
||||
(receivedAtDate);
|
||||
`;
|
||||
db.exec(query);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue