From 8df42e37f8ea16d840a08f9aa42f065fd5bf1cfe Mon Sep 17 00:00:00 2001 From: JohanHjelsethStorstad <82723971+JohanHjelsethStorstad@users.noreply.github.com> Date: Mon, 23 Sep 2024 12:25:34 +0200 Subject: [PATCH 1/4] chore: adds boilerplate for events migration --- .../prismaservice/src/dobbelOmega/dobbelOmega.ts | 2 ++ .../prismaservice/src/dobbelOmega/migrateEvents.ts | 12 ++++++++++++ .../prismaservice/src/dobbelOmega/migrationLimits.ts | 2 ++ 3 files changed, 16 insertions(+) create mode 100644 src/prisma/prismaservice/src/dobbelOmega/migrateEvents.ts diff --git a/src/prisma/prismaservice/src/dobbelOmega/dobbelOmega.ts b/src/prisma/prismaservice/src/dobbelOmega/dobbelOmega.ts index c3f74db12..9929c8428 100644 --- a/src/prisma/prismaservice/src/dobbelOmega/dobbelOmega.ts +++ b/src/prisma/prismaservice/src/dobbelOmega/dobbelOmega.ts @@ -7,6 +7,7 @@ import migrateArticles from './migateArticles' import migrateMailAliases from './migrateMailAlias' import { PrismaClient as PrismaClientVeven } from '@/generated/veven' import type { PrismaClient as PrismaClientPn } from '@/generated/pn' +import migrateEvents from './migrateEvents' /** * !DobbelOmega! @@ -26,6 +27,7 @@ export default async function dobbelOmega(pnPrisma: PrismaClientPn) { await migrateOmegaquotes(pnPrisma, vevenPrisma, limits) await migrateArticles(pnPrisma, vevenPrisma, imageIdMap, limits) await migrateMailAliases(pnPrisma, vevenPrisma, limits) + await migrateEvents(pnPrisma, vevenPrisma, limits) vevenPrisma.$disconnect() console.log('=======Dobbel Omega ferdig, dagen derpÄ=======') diff --git a/src/prisma/prismaservice/src/dobbelOmega/migrateEvents.ts b/src/prisma/prismaservice/src/dobbelOmega/migrateEvents.ts new file mode 100644 index 000000000..3a4031bc3 --- /dev/null +++ b/src/prisma/prismaservice/src/dobbelOmega/migrateEvents.ts @@ -0,0 +1,12 @@ +import type { PrismaClient as PrismaClientPn } from '@/generated/pn' +import type { PrismaClient as PrismaClientVeven } from '@/generated/veven' +import type { IdMapper } from './IdMapper' +import type { Limits } from './migrationLimits' + +export default async function migrateEvents( + pnPrisma: PrismaClientPn, + vevenPrisma: PrismaClientVeven, + limits: Limits +) { + const events = await vevenPrisma.events.findMany({ take: limits.events ? limits.events : undefined }) +} \ No newline at end of file diff --git a/src/prisma/prismaservice/src/dobbelOmega/migrationLimits.ts b/src/prisma/prismaservice/src/dobbelOmega/migrationLimits.ts index b5b007ff4..debee5937 100644 --- a/src/prisma/prismaservice/src/dobbelOmega/migrationLimits.ts +++ b/src/prisma/prismaservice/src/dobbelOmega/migrationLimits.ts @@ -9,6 +9,7 @@ export function getLimits() { omegaquotes: null, articles: 300, mailaliases: null, + events: null, } const nullObj: { [key in keyof typeof limits]: null } = { ombul: null, @@ -16,6 +17,7 @@ export function getLimits() { omegaquotes: null, articles: null, mailaliases: null, + events: null, } const limitsOn = process.env.MIGRATION_WITH_LIMITS !== 'false' From 70a01015b417c1f7e370a1e8d5b151037f61e6c4 Mon Sep 17 00:00:00 2001 From: JohanHjelsethStorstad <82723971+JohanHjelsethStorstad@users.noreply.github.com> Date: Mon, 23 Sep 2024 13:05:13 +0200 Subject: [PATCH 2/4] feat: basic event migration done --- .../src/dobbelOmega/dobbelOmega.ts | 2 +- .../src/dobbelOmega/migateArticles.ts | 19 +--- .../src/dobbelOmega/migrateEvents.ts | 89 ++++++++++++++++++- .../src/dobbelOmega/migrateImages.ts | 2 + .../src/dobbelOmega/upsertOrderBasedOnDate.ts | 30 +++++++ src/prisma/schema/event.prisma | 16 ++-- src/prisma/schema/group.prisma | 1 + src/prisma/schema/user.prisma | 38 ++++---- 8 files changed, 151 insertions(+), 46 deletions(-) create mode 100644 src/prisma/prismaservice/src/dobbelOmega/upsertOrderBasedOnDate.ts diff --git a/src/prisma/prismaservice/src/dobbelOmega/dobbelOmega.ts b/src/prisma/prismaservice/src/dobbelOmega/dobbelOmega.ts index 9929c8428..908e0d763 100644 --- a/src/prisma/prismaservice/src/dobbelOmega/dobbelOmega.ts +++ b/src/prisma/prismaservice/src/dobbelOmega/dobbelOmega.ts @@ -27,7 +27,7 @@ export default async function dobbelOmega(pnPrisma: PrismaClientPn) { await migrateOmegaquotes(pnPrisma, vevenPrisma, limits) await migrateArticles(pnPrisma, vevenPrisma, imageIdMap, limits) await migrateMailAliases(pnPrisma, vevenPrisma, limits) - await migrateEvents(pnPrisma, vevenPrisma, limits) + await migrateEvents(pnPrisma, vevenPrisma, imageIdMap, limits) vevenPrisma.$disconnect() console.log('=======Dobbel Omega ferdig, dagen derpÄ=======') diff --git a/src/prisma/prismaservice/src/dobbelOmega/migateArticles.ts b/src/prisma/prismaservice/src/dobbelOmega/migateArticles.ts index 2581b2d23..36bef45ad 100644 --- a/src/prisma/prismaservice/src/dobbelOmega/migateArticles.ts +++ b/src/prisma/prismaservice/src/dobbelOmega/migateArticles.ts @@ -3,6 +3,7 @@ import type { PrismaClient as PrismaClientPn } from '@/generated/pn' import type { PrismaClient as PrismaClientVeven } from '@/generated/veven' import type { IdMapper } from './IdMapper' import type { Limits } from './migrationLimits' +import upsertOrderBasedOnDate from './upsertOrderBasedOnDate' /** * WARNING: This function is not complete, it does not migrate the InfoPages, only the articles (news) @@ -84,23 +85,7 @@ export default async function migrateArticles( } }) - // The order is assumed to change 1. september, calculate by createdAt - // 1. september 1914 = order 1, 1. september 1915 = order 2, ... - let orderPublished = new Date(article.createdAt).getFullYear() - 1914 - if (new Date(article.createdAt).getMonth() < 8) { - orderPublished-- - } - await pnPrisma.omegaOrder.upsert({ - where: { - order: orderPublished, - }, - update: { - order: orderPublished, - }, - create: { - order: orderPublished, - } - }) + const orderPublished = await upsertOrderBasedOnDate(pnPrisma, article.createdAt) return { ...articlePn, diff --git a/src/prisma/prismaservice/src/dobbelOmega/migrateEvents.ts b/src/prisma/prismaservice/src/dobbelOmega/migrateEvents.ts index 3a4031bc3..0bb4a9ed9 100644 --- a/src/prisma/prismaservice/src/dobbelOmega/migrateEvents.ts +++ b/src/prisma/prismaservice/src/dobbelOmega/migrateEvents.ts @@ -1,12 +1,97 @@ import type { PrismaClient as PrismaClientPn } from '@/generated/pn' import type { PrismaClient as PrismaClientVeven } from '@/generated/veven' -import type { IdMapper } from './IdMapper' +import { vevenIdToPnId, type IdMapper } from './IdMapper' import type { Limits } from './migrationLimits' +import upsertOrderBasedOnDate from './upsertOrderBasedOnDate' export default async function migrateEvents( pnPrisma: PrismaClientPn, vevenPrisma: PrismaClientVeven, + imageIdMap: IdMapper, limits: Limits ) { - const events = await vevenPrisma.events.findMany({ take: limits.events ? limits.events : undefined }) + const events = await vevenPrisma.events.findMany({ + take: limits.events ? limits.events : undefined, + include: { + Images: true, + Committees: true, + EventRegistrations: true, + } + }) + Promise.all(events.map(async event => { + const coverId = vevenIdToPnId(imageIdMap, event.ImageId) + const coverIage = await pnPrisma.cmsImage.create({ + data: { + image: coverId ? { + connect: { + id: coverId, + } + } : undefined + } + }) + const paragraph = await pnPrisma.cmsParagraph.create({ + data: { + contentHtml: event.text || '', + createdAt: event.createdAt, + updatedAt: event.updatedAt, + } + }) + + await pnPrisma.event.create({ + data: { + name: event.title, + order: await upsertOrderBasedOnDate(pnPrisma, event.createdAt), + createdAt: event.createdAt, + updatedAt: event.updatedAt, + canBeViewdBy: 'ALL', + takesRegistration: !!event.places && (event.places > 0), + places: event.places || 0, + eventStart: event.eventDate ?? event.createdAt, + eventEnd: event.eventDate ?? event.createdAt, + registrationStart: event.registrationStart ?? event.createdAt, + registrationEnd: event.registrationDeadline ?? event.createdAt, + coverImageId: coverIage.id, + cmsParagraphId: paragraph.id, + } + }) + })) + + const simpleEvents = await vevenPrisma.simpleEvents.findMany({ + take: limits.events ? limits.events : undefined, + include: { + Committees: true, + } + }) + + Promise.all(simpleEvents.map(async simpleEvent => { + const coverIage = await pnPrisma.cmsImage.create({ + data: { + image: undefined + } + }) + const paragraph = await pnPrisma.cmsParagraph.create({ + data: { + contentHtml: simpleEvent.text || '', + createdAt: simpleEvent.createdAt, + updatedAt: simpleEvent.updatedAt, + } + }) + await pnPrisma.event.create({ + data: { + name: simpleEvent.title, + order: await upsertOrderBasedOnDate(pnPrisma, simpleEvent.createdAt), + createdAt: simpleEvent.createdAt, + updatedAt: simpleEvent.updatedAt, + canBeViewdBy: 'ALL', + takesRegistration: false, + places: 0, + eventStart: simpleEvent.eventDate ?? simpleEvent.createdAt, + eventEnd: simpleEvent.eventDate ?? simpleEvent.createdAt, + registrationStart: simpleEvent.createdAt, + registrationEnd: simpleEvent.createdAt, + coverImageId: coverIage.id, + cmsParagraphId: paragraph.id, + } + }) + })) } \ No newline at end of file diff --git a/src/prisma/prismaservice/src/dobbelOmega/migrateImages.ts b/src/prisma/prismaservice/src/dobbelOmega/migrateImages.ts index a7fbe5cf7..5dbe228ac 100644 --- a/src/prisma/prismaservice/src/dobbelOmega/migrateImages.ts +++ b/src/prisma/prismaservice/src/dobbelOmega/migrateImages.ts @@ -55,6 +55,7 @@ export default async function migrateImages( include: { Ombul: true, Articles: true, + Events: true, } }) @@ -74,6 +75,7 @@ export default async function migrateImages( if (!limits.numberOffFullImageCollections) return true if (image.Ombul.length) return true if (image.Articles.length) return true + if (image.Events.length) return true if (image.collectionId === ombulCollection.id) return true if (image.ImageGroupId && image.ImageGroupId < limits.numberOffFullImageCollections) return true return false diff --git a/src/prisma/prismaservice/src/dobbelOmega/upsertOrderBasedOnDate.ts b/src/prisma/prismaservice/src/dobbelOmega/upsertOrderBasedOnDate.ts new file mode 100644 index 000000000..8ec3b64b4 --- /dev/null +++ b/src/prisma/prismaservice/src/dobbelOmega/upsertOrderBasedOnDate.ts @@ -0,0 +1,30 @@ +import type { PrismaClient as PrismaClientPn } from '@/generated/pn' + +/** + * Veven did not have the consept of omegaOrder. This function infers the order based on a date and + * also upserts the order into the database. + * @param date - Date of thing + */ +export default async function upsertOrderBasedOnDate( + pnPrisma: PrismaClientPn, + date: Date +): Promise { + // The order is assumed to change 1. september, calculate by createdAt + // 1. september 1914 = order 1, 1. september 1915 = order 2, ... + let orderPublished = new Date(date).getFullYear() - 1914 + if (new Date(date).getMonth() < 8) { + orderPublished-- + } + await pnPrisma.omegaOrder.upsert({ + where: { + order: orderPublished, + }, + update: { + order: orderPublished, + }, + create: { + order: orderPublished, + } + }) + return orderPublished +} \ No newline at end of file diff --git a/src/prisma/schema/event.prisma b/src/prisma/schema/event.prisma index b569b389c..4107324f7 100644 --- a/src/prisma/schema/event.prisma +++ b/src/prisma/schema/event.prisma @@ -14,15 +14,17 @@ model Event { coverImageId Int EventTagEvent EventTagEvent[] - eventStart DateTime - eventEnd DateTime - canBeViewdBy EventCanView - - takesRegistration Boolean - places Int @default(0) + eventStart DateTime + eventEnd DateTime + canBeViewdBy EventCanView + hostedByCommitee Committee? @relation(fields: [hostedByCommiteeId], references: [id]) + hostedByCommiteeId Int? + + takesRegistration Boolean + places Int @default(0) registrationStart DateTime registrationEnd DateTime - EventRegistration EventRegistration[] + EventRegistration EventRegistration[] createdAt DateTime @default(now()) updatedAt DateTime @updatedAt diff --git a/src/prisma/schema/group.prisma b/src/prisma/schema/group.prisma index 1104046b9..9011f6abd 100644 --- a/src/prisma/schema/group.prisma +++ b/src/prisma/schema/group.prisma @@ -70,6 +70,7 @@ model Committee { shortName String @unique logoImage CmsImage @relation(fields: [logoImageId], references: [id], onDelete: Restrict, onUpdate: Cascade) logoImageId Int @unique + Event Event[] } model InterestGroup { diff --git a/src/prisma/schema/user.prisma b/src/prisma/schema/user.prisma index 46b1482bc..00a5b899f 100644 --- a/src/prisma/schema/user.prisma +++ b/src/prisma/schema/user.prisma @@ -5,26 +5,26 @@ enum SEX { } model User { - id Int @id @default(autoincrement()) - username String @unique - email String @unique - firstname String @default("[Fjernet]") - lastname String @default("[Fjernet]") - bio String @default("") - acceptedTerms DateTime? - sex SEX? - allergies String? - mobile String? - emailVerified DateTime? - createdAt DateTime @default(now()) - updatedAt DateTime @updatedAt // is also updated manually - image Image? @relation(fields: [imageId], references: [id]) - imageId Int? + id Int @id @default(autoincrement()) + username String @unique + email String @unique + firstname String @default("[Fjernet]") + lastname String @default("[Fjernet]") + bio String @default("") + acceptedTerms DateTime? + sex SEX? + allergies String? + mobile String? + emailVerified DateTime? + createdAt DateTime @default(now()) + updatedAt DateTime @updatedAt // is also updated manually + image Image? @relation(fields: [imageId], references: [id]) + imageId Int? LockerReservation LockerReservation[] - omegaQuote OmegaQuote[] - memberships Membership[] - credentials Credentials? - feideAccount FeideAccount? + omegaQuote OmegaQuote[] + memberships Membership[] + credentials Credentials? + feideAccount FeideAccount? notificationSubscriptions NotificationSubscription[] mailingLists MailingListUser[] From 2a7727a8b91b3bbf0a2974882fe90adef569d0b7 Mon Sep 17 00:00:00 2001 From: JohanHjelsethStorstad <82723971+JohanHjelsethStorstad@users.noreply.github.com> Date: Tue, 24 Sep 2024 18:40:49 +0200 Subject: [PATCH 3/4] chore: adds migration --- .../prismaservice/src/dobbelOmega/dobbelOmega.ts | 2 +- .../prismaservice/src/dobbelOmega/migateArticles.ts | 2 +- .../prismaservice/src/dobbelOmega/migrateEvents.ts | 12 ++++++------ .../prismaservice/src/dobbelOmega/migrateImages.ts | 8 ++++++-- .../src/dobbelOmega/migrateMailAlias.ts | 1 + .../prismaservice/src/dobbelOmega/migrationLimits.ts | 2 +- .../src/dobbelOmega/upsertOrderBasedOnDate.ts | 2 +- 7 files changed, 17 insertions(+), 12 deletions(-) diff --git a/src/prisma/prismaservice/src/dobbelOmega/dobbelOmega.ts b/src/prisma/prismaservice/src/dobbelOmega/dobbelOmega.ts index 908e0d763..7fd64db1d 100644 --- a/src/prisma/prismaservice/src/dobbelOmega/dobbelOmega.ts +++ b/src/prisma/prismaservice/src/dobbelOmega/dobbelOmega.ts @@ -5,9 +5,9 @@ import { getLimits } from './migrationLimits' import migrateOmegaquotes from './migrateOmegaquotes' import migrateArticles from './migateArticles' import migrateMailAliases from './migrateMailAlias' +import migrateEvents from './migrateEvents' import { PrismaClient as PrismaClientVeven } from '@/generated/veven' import type { PrismaClient as PrismaClientPn } from '@/generated/pn' -import migrateEvents from './migrateEvents' /** * !DobbelOmega! diff --git a/src/prisma/prismaservice/src/dobbelOmega/migateArticles.ts b/src/prisma/prismaservice/src/dobbelOmega/migateArticles.ts index 36bef45ad..761beff65 100644 --- a/src/prisma/prismaservice/src/dobbelOmega/migateArticles.ts +++ b/src/prisma/prismaservice/src/dobbelOmega/migateArticles.ts @@ -1,9 +1,9 @@ import { vevenIdToPnId } from './IdMapper' +import upsertOrderBasedOnDate from './upsertOrderBasedOnDate' import type { PrismaClient as PrismaClientPn } from '@/generated/pn' import type { PrismaClient as PrismaClientVeven } from '@/generated/veven' import type { IdMapper } from './IdMapper' import type { Limits } from './migrationLimits' -import upsertOrderBasedOnDate from './upsertOrderBasedOnDate' /** * WARNING: This function is not complete, it does not migrate the InfoPages, only the articles (news) diff --git a/src/prisma/prismaservice/src/dobbelOmega/migrateEvents.ts b/src/prisma/prismaservice/src/dobbelOmega/migrateEvents.ts index 0bb4a9ed9..df0f8cc85 100644 --- a/src/prisma/prismaservice/src/dobbelOmega/migrateEvents.ts +++ b/src/prisma/prismaservice/src/dobbelOmega/migrateEvents.ts @@ -1,8 +1,8 @@ +import { vevenIdToPnId, type IdMapper } from './IdMapper' +import upsertOrderBasedOnDate from './upsertOrderBasedOnDate' import type { PrismaClient as PrismaClientPn } from '@/generated/pn' import type { PrismaClient as PrismaClientVeven } from '@/generated/veven' -import { vevenIdToPnId, type IdMapper } from './IdMapper' import type { Limits } from './migrationLimits' -import upsertOrderBasedOnDate from './upsertOrderBasedOnDate' export default async function migrateEvents( pnPrisma: PrismaClientPn, @@ -10,8 +10,8 @@ export default async function migrateEvents( imageIdMap: IdMapper, limits: Limits ) { - const events = await vevenPrisma.events.findMany({ - take: limits.events ? limits.events : undefined, + const events = await vevenPrisma.events.findMany({ + take: limits.events ? limits.events : undefined, include: { Images: true, Committees: true, @@ -36,7 +36,7 @@ export default async function migrateEvents( updatedAt: event.updatedAt, } }) - + await pnPrisma.event.create({ data: { name: event.title, @@ -94,4 +94,4 @@ export default async function migrateEvents( } }) })) -} \ No newline at end of file +} diff --git a/src/prisma/prismaservice/src/dobbelOmega/migrateImages.ts b/src/prisma/prismaservice/src/dobbelOmega/migrateImages.ts index 5dbe228ac..e30085b6e 100644 --- a/src/prisma/prismaservice/src/dobbelOmega/migrateImages.ts +++ b/src/prisma/prismaservice/src/dobbelOmega/migrateImages.ts @@ -37,8 +37,12 @@ export default async function migrateImages( create: { purpose: 'IMAGE', published: true, - regularLevel: {}, - adminLevel: {}, + regularLevel: { + create: {} + }, + adminLevel: { + create: {} + }, } } }, diff --git a/src/prisma/prismaservice/src/dobbelOmega/migrateMailAlias.ts b/src/prisma/prismaservice/src/dobbelOmega/migrateMailAlias.ts index 8b50f7b47..0b9318bc6 100644 --- a/src/prisma/prismaservice/src/dobbelOmega/migrateMailAlias.ts +++ b/src/prisma/prismaservice/src/dobbelOmega/migrateMailAlias.ts @@ -8,6 +8,7 @@ export default async function migrateMailAliases( vevenPrisma: PrismaClientVeven, limits: Limits, ) { + if (limits.mailaliases === 0) return const aliases = await vevenPrisma.mailAliases.findMany({ take: limits.mailaliases ?? undefined, include: { diff --git a/src/prisma/prismaservice/src/dobbelOmega/migrationLimits.ts b/src/prisma/prismaservice/src/dobbelOmega/migrationLimits.ts index debee5937..ad97b751b 100644 --- a/src/prisma/prismaservice/src/dobbelOmega/migrationLimits.ts +++ b/src/prisma/prismaservice/src/dobbelOmega/migrationLimits.ts @@ -8,7 +8,7 @@ export function getLimits() { numberOffFullImageCollections: 3, omegaquotes: null, articles: 300, - mailaliases: null, + mailaliases: 0, events: null, } const nullObj: { [key in keyof typeof limits]: null } = { diff --git a/src/prisma/prismaservice/src/dobbelOmega/upsertOrderBasedOnDate.ts b/src/prisma/prismaservice/src/dobbelOmega/upsertOrderBasedOnDate.ts index 8ec3b64b4..eab14d33f 100644 --- a/src/prisma/prismaservice/src/dobbelOmega/upsertOrderBasedOnDate.ts +++ b/src/prisma/prismaservice/src/dobbelOmega/upsertOrderBasedOnDate.ts @@ -27,4 +27,4 @@ export default async function upsertOrderBasedOnDate( } }) return orderPublished -} \ No newline at end of file +} From 89867aebb6288fb600d1af886ac349d4e212cc79 Mon Sep 17 00:00:00 2001 From: JohanHjelsethStorstad <82723971+JohanHjelsethStorstad@users.noreply.github.com> Date: Thu, 26 Sep 2024 16:38:15 +0200 Subject: [PATCH 4/4] fix: event names of order were not unique --- .../src/dobbelOmega/migrateEvents.ts | 32 ++++++++++++++++--- 1 file changed, 28 insertions(+), 4 deletions(-) diff --git a/src/prisma/prismaservice/src/dobbelOmega/migrateEvents.ts b/src/prisma/prismaservice/src/dobbelOmega/migrateEvents.ts index df0f8cc85..ab9e0db55 100644 --- a/src/prisma/prismaservice/src/dobbelOmega/migrateEvents.ts +++ b/src/prisma/prismaservice/src/dobbelOmega/migrateEvents.ts @@ -18,7 +18,17 @@ export default async function migrateEvents( EventRegistrations: true, } }) - Promise.all(events.map(async event => { + //Make sure no events have same title and order + events.forEach((event) => { + const sameTitle = events.filter(e => e.title === event.title) + if (sameTitle.length > 1) { + sameTitle.forEach((e, i) => { + e.title = `${e.title} (${i + 1})` + }) + } + }) + + await Promise.all(events.map(async event => { const coverId = vevenIdToPnId(imageIdMap, event.ImageId) const coverIage = await pnPrisma.cmsImage.create({ data: { @@ -37,10 +47,12 @@ export default async function migrateEvents( } }) + const order = await upsertOrderBasedOnDate(pnPrisma, event.createdAt) + await pnPrisma.event.create({ data: { name: event.title, - order: await upsertOrderBasedOnDate(pnPrisma, event.createdAt), + order, createdAt: event.createdAt, updatedAt: event.updatedAt, canBeViewdBy: 'ALL', @@ -62,8 +74,17 @@ export default async function migrateEvents( Committees: true, } }) + //Make sure no events have same title and order + simpleEvents.forEach((event) => { + const sameTitle = simpleEvents.filter(e => e.title === event.title) + if (sameTitle.length > 1) { + sameTitle.forEach((e, i) => { + e.title = `${e.title} (${i + 1})` + }) + } + }) - Promise.all(simpleEvents.map(async simpleEvent => { + await Promise.all(simpleEvents.map(async simpleEvent => { const coverIage = await pnPrisma.cmsImage.create({ data: { image: undefined @@ -76,10 +97,13 @@ export default async function migrateEvents( updatedAt: simpleEvent.updatedAt, } }) + + const order = await upsertOrderBasedOnDate(pnPrisma, simpleEvent.createdAt) + await pnPrisma.event.create({ data: { name: simpleEvent.title, - order: await upsertOrderBasedOnDate(pnPrisma, simpleEvent.createdAt), + order, createdAt: simpleEvent.createdAt, updatedAt: simpleEvent.updatedAt, canBeViewdBy: 'ALL',