created migration to correct public key length

This commit is contained in:
Ulf Gebhardt 2023-05-30 10:59:47 +02:00
parent c44b589df5
commit ad1225998f
Signed by: ulfgebhardt
GPG Key ID: DA6B843E748679C9

View File

@ -0,0 +1,23 @@
/* MIGRATION TO CORRECT THE PUBLIC KEY LENGTHS
*
* This migration corrects the length of the saved public keys to 32 as this is the length it is generated for.
*/
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
/* eslint-disable @typescript-eslint/no-explicit-any */
export async function upgrade(queryFn: (query: string, values?: any[]) => Promise<Array<any>>) {
await queryFn('ALTER TABLE `communities` MODIFY COLUMN `public_key` binary(32) NOT NULL;')
// TODO: it is unclear if this is actually nullable - the model defines "default: null, nullable: true", but the table seems to be created without nullability(?)
await queryFn(
'ALTER TABLE `federated_communities` MODIFY COLUMN `public_key` binary(32) NULL DEFAULT NULL;',
)
}
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;')
// TODO: see above
await queryFn(
'ALTER TABLE `federated_communities` MODIFY COLUMN `public_key` binary(64) NULL DEFAULT NULL;',
)
}