corrected database migration

This commit is contained in:
Ulf Gebhardt 2023-06-20 10:50:48 +02:00
parent d23e1a5aad
commit 6c3b784d45
Signed by: ulfgebhardt
GPG Key ID: DA6B843E748679C9

View File

@ -7,7 +7,7 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
export async function upgrade(queryFn: (query: string, values?: any[]) => Promise<Array<any>>) {
await queryFn('UPDATE `communities` SET `public_key` = UNHEX(publicKey);')
await queryFn('UPDATE `communities` SET `public_key` = UNHEX(public_key);')
await queryFn('ALTER TABLE `communities` MODIFY COLUMN `public_key` binary(32) NOT NULL;')
await queryFn(
'ALTER TABLE `federated_communities` MODIFY COLUMN `public_key` binary(32) NULL DEFAULT NULL;',
@ -16,7 +16,7 @@ export async function upgrade(queryFn: (query: string, values?: any[]) => Promis
export async function downgrade(queryFn: (query: string, values?: any[]) => Promise<Array<any>>) {
await queryFn('ALTER TABLE `communities` MODIFY COLUMN `public_key` binary(64) NOT NULL;')
await queryFn('UPDATE `communities` SET `public_key` = HEX(publicKey);')
await queryFn('UPDATE `communities` SET `public_key` = HEX(public_key);')
await queryFn(
'ALTER TABLE `federated_communities` MODIFY COLUMN `public_key` binary(64) NULL DEFAULT NULL;',
)