gradido/database/migrations/0079-fill_linked_user_id_of_contributions.ts
einhorn_b 2ea5df0fcf lint
2024-01-04 11:34:47 +01:00

14 lines
496 B
TypeScript

export async function upgrade(queryFn: (query: string, values?: any[]) => Promise<Array<any>>) {
await queryFn(
`UPDATE \`transactions\` AS t
JOIN \`contributions\` AS c ON t.id = c.transaction_id
SET t.linked_user_id = c.confirmed_by
WHERE t.type_id = ?`,
[1],
)
}
export async function downgrade(queryFn: (query: string, values?: any[]) => Promise<Array<any>>) {
await queryFn(`UPDATE \`transactions\` SET \`linked_user_id\` = NULL where \`type_id\` = ?;`, [1])
}