From 580c5940d27f2278a3a0bfb1d3d1b3b6225b8a5a Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Tue, 20 Jun 2023 09:39:54 +0200 Subject: [PATCH] covert public_key according to new standarts unhex/hex --- database/migrations/0068-community_tables_public_key_length.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/database/migrations/0068-community_tables_public_key_length.ts b/database/migrations/0068-community_tables_public_key_length.ts index b51a1e6e0..df70b1182 100644 --- a/database/migrations/0068-community_tables_public_key_length.ts +++ b/database/migrations/0068-community_tables_public_key_length.ts @@ -7,6 +7,7 @@ /* eslint-disable @typescript-eslint/no-explicit-any */ export async function upgrade(queryFn: (query: string, values?: any[]) => Promise>) { + await queryFn('UPDATE `communities` SET `public_key` = UNHEX(publicKey);') 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( @@ -16,6 +17,7 @@ export async function upgrade(queryFn: (query: string, values?: any[]) => Promis export async function downgrade(queryFn: (query: string, values?: any[]) => Promise>) { await queryFn('ALTER TABLE `communities` MODIFY COLUMN `public_key` binary(64) NOT NULL;') + await queryFn('UPDATE `communities` SET `public_key` = HEX(publicKey);') // TODO: see above await queryFn( 'ALTER TABLE `federated_communities` MODIFY COLUMN `public_key` binary(64) NULL DEFAULT NULL;',