mirror of
https://github.com/IT4Change/gradido.git
synced 2026-02-06 09:56:05 +00:00
mirgation to correct missing communityUuid in users
This commit is contained in:
parent
315c082628
commit
f521a38a1c
@ -0,0 +1,17 @@
|
||||
/* 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>>) {
|
||||
// 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 all local users
|
||||
if (result && result[0]) {
|
||||
await queryFn(
|
||||
`UPDATE users as u SET u.community_uuid = "${result[0].community_uuid}" WHERE u.foreign = 0 AND u.community_uuid IS NULL`,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
export async function downgrade(queryFn: (query: string, values?: any[]) => Promise<Array<any>>) {
|
||||
await queryFn('SELECT * FROM dual;')
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user