Simplify database migrations
This commit is contained in:
parent
46d5b06bfc
commit
e6809c95db
106 changed files with 4661 additions and 6814 deletions
|
@ -3,36 +3,20 @@
|
|||
|
||||
import type { Database } from '@signalapp/sqlcipher';
|
||||
|
||||
import type { LoggerType } from '../../types/Logging';
|
||||
export default function updateToSchemaVersion64(db: Database): void {
|
||||
db.exec(
|
||||
`
|
||||
ALTER TABLE preKeys
|
||||
ADD COLUMN ourUuid STRING
|
||||
GENERATED ALWAYS AS (json_extract(json, '$.ourUuid'));
|
||||
|
||||
export default function updateToSchemaVersion64(
|
||||
currentVersion: number,
|
||||
db: Database,
|
||||
logger: LoggerType
|
||||
): void {
|
||||
if (currentVersion >= 64) {
|
||||
return;
|
||||
}
|
||||
CREATE INDEX preKeys_ourUuid ON preKeys (ourUuid);
|
||||
|
||||
db.transaction(() => {
|
||||
db.exec(
|
||||
`
|
||||
ALTER TABLE preKeys
|
||||
ADD COLUMN ourUuid STRING
|
||||
GENERATED ALWAYS AS (json_extract(json, '$.ourUuid'));
|
||||
ALTER TABLE signedPreKeys
|
||||
ADD COLUMN ourUuid STRING
|
||||
GENERATED ALWAYS AS (json_extract(json, '$.ourUuid'));
|
||||
|
||||
CREATE INDEX preKeys_ourUuid ON preKeys (ourUuid);
|
||||
|
||||
ALTER TABLE signedPreKeys
|
||||
ADD COLUMN ourUuid STRING
|
||||
GENERATED ALWAYS AS (json_extract(json, '$.ourUuid'));
|
||||
|
||||
CREATE INDEX signedPreKeys_ourUuid ON signedPreKeys (ourUuid);
|
||||
`
|
||||
);
|
||||
|
||||
db.pragma('user_version = 64');
|
||||
})();
|
||||
|
||||
logger.info('updateToSchemaVersion64: success!');
|
||||
CREATE INDEX signedPreKeys_ourUuid ON signedPreKeys (ourUuid);
|
||||
`
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue