From d53073783c68d3ec7f874b5b3cc7e47e0971104c Mon Sep 17 00:00:00 2001 From: einhorn_b Date: Tue, 19 Sep 2023 21:06:22 +0200 Subject: [PATCH] should prevent crash in empty tables --- .../migrations/0072-add_communityuuid_to_transactions_table.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/database/migrations/0072-add_communityuuid_to_transactions_table.ts b/database/migrations/0072-add_communityuuid_to_transactions_table.ts index 779da77c9..04685141f 100644 --- a/database/migrations/0072-add_communityuuid_to_transactions_table.ts +++ b/database/migrations/0072-add_communityuuid_to_transactions_table.ts @@ -13,7 +13,7 @@ export async function upgrade(queryFn: (query: string, values?: any[]) => Promis // read the community uuid of the homeCommunity const result = await queryFn(`SELECT c.community_uuid from communities as c WHERE c.foreign = 0`) // and if uuid exists enter the home_community_uuid for sender and recipient of each still existing transaction - if (result[0]) { + if (result && result[0]) { await queryFn( `UPDATE transactions as t SET t.user_community_uuid = "${result[0].community_uuid}" WHERE t.user_id IS NOT NULL AND t.user_community_uuid IS NULL`, )