signal-desktop/ts/sql/migrations/44-badges.ts

44 lines
955 B
TypeScript
Raw Normal View History

2021-11-02 23:01:13 +00:00
// Copyright 2021 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only
2022-12-14 20:48:36 +00:00
import type { Database } from '@signalapp/better-sqlite3';
2021-11-02 23:01:13 +00:00
import type { LoggerType } from '../../types/Logging';
export default function updateToSchemaVersion44(
currentVersion: number,
db: Database,
logger: LoggerType
): void {
if (currentVersion >= 44) {
return;
}
db.transaction(() => {
db.exec(
`
CREATE TABLE badges(
id TEXT PRIMARY KEY,
category TEXT NOT NULL,
name TEXT NOT NULL,
descriptionTemplate TEXT NOT NULL
);
CREATE TABLE badgeImageFiles(
badgeId TEXT REFERENCES badges(id)
ON DELETE CASCADE
ON UPDATE CASCADE,
'order' INTEGER NOT NULL,
url TEXT NOT NULL,
localPath TEXT,
theme TEXT NOT NULL
);
`
);
db.pragma('user_version = 44');
})();
logger.info('updateToSchemaVersion44: success!');
}