From ac59b9b0fad5b156b3d51fe20733a8bc71365d16 Mon Sep 17 00:00:00 2001 From: PxlLoewe <72106766+PxlLoewe@users.noreply.github.com> Date: Fri, 4 Jul 2025 09:32:06 -0700 Subject: [PATCH] =?UTF-8?q?IT=20als=20land=20hinzugef=C3=BCgt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/hub-server/routes/router.ts | 54 ++++++++++--------- .../migration.sql | 11 ++++ .../migration.sql | 2 + .../database/prisma/schema/station.prisma | 1 + 4 files changed, 43 insertions(+), 25 deletions(-) create mode 100644 packages/database/prisma/schema/migrations/20250704162508_add_countries/migration.sql create mode 100644 packages/database/prisma/schema/migrations/20250704163122_add_it_as_country/migration.sql diff --git a/apps/hub-server/routes/router.ts b/apps/hub-server/routes/router.ts index b6d014b4..30bd83f7 100644 --- a/apps/hub-server/routes/router.ts +++ b/apps/hub-server/routes/router.ts @@ -9,32 +9,36 @@ const router: Router = Router(); router.use("/mail", mailRouter); router.use("/event", eventRouter); router.get("/import", (req, res) => { - DATA.forEach((station) => { - prisma.station.create({ - data: { - aircraftRegistration: "D-H", - aircraft: station.aircraft, - aircraftSpeed: station.aircraftSpeed, - atcCallsign: station.atcCallsign, - bosCallsign: station.bosCallsign, - bosCallsignShort: station.bosCallsignShort, - bosRadioArea: station.bosRadioArea, - fir: station.fir, - operator: station.operator, - bosUse: "PRIMARY", - country: station.country as Country, - hasNvg: station.hasNvg, - hasRope: station.hasRope, - hasWinch: station.hasWinch, - is24h: station.is24h, - hideRangeRings: station.hideRangeRings, - locationState: station.locationState, - locationStateShort: station.locationStateShort, + DATA.forEach(async (station) => { + try { + await prisma.station.create({ + data: { + aircraftRegistration: "D-H", + aircraft: station.aircraft, + aircraftSpeed: station.aircraftSpeed, + atcCallsign: station.atcCallsign, + bosCallsign: station.bosCallsign, + bosCallsignShort: station.bosCallsignShort, + bosRadioArea: station.bosRadioArea, + fir: station.fir, + operator: station.operator, + bosUse: "PRIMARY", + country: station.country as Country, + hasNvg: station.hasNvg, + hasRope: station.hasRope, + hasWinch: station.hasWinch, + is24h: station.is24h, + hideRangeRings: station.hideRangeRings, + locationState: station.locationState, + locationStateShort: station.locationStateShort, - latitude: station.latitude, - longitude: station.longitude, - }, - }); + latitude: station.latitude, + longitude: station.longitude, + }, + }); + } catch (error) { + console.error(`Error creating station ${station.aircraft}:`, error); + } }); }); diff --git a/packages/database/prisma/schema/migrations/20250704162508_add_countries/migration.sql b/packages/database/prisma/schema/migrations/20250704162508_add_countries/migration.sql new file mode 100644 index 00000000..83d0abcb --- /dev/null +++ b/packages/database/prisma/schema/migrations/20250704162508_add_countries/migration.sql @@ -0,0 +1,11 @@ +-- AlterEnum +-- This migration adds more than one value to an enum. +-- With PostgreSQL versions 11 and earlier, this is not possible +-- in a single migration. This can be worked around by creating +-- multiple migrations, each migration adding only one value to +-- the enum. + + +ALTER TYPE "Country" ADD VALUE 'NL'; +ALTER TYPE "Country" ADD VALUE 'LU'; +ALTER TYPE "Country" ADD VALUE 'LI'; diff --git a/packages/database/prisma/schema/migrations/20250704163122_add_it_as_country/migration.sql b/packages/database/prisma/schema/migrations/20250704163122_add_it_as_country/migration.sql new file mode 100644 index 00000000..998ed0de --- /dev/null +++ b/packages/database/prisma/schema/migrations/20250704163122_add_it_as_country/migration.sql @@ -0,0 +1,2 @@ +-- AlterEnum +ALTER TYPE "Country" ADD VALUE 'IT'; diff --git a/packages/database/prisma/schema/station.prisma b/packages/database/prisma/schema/station.prisma index 13f818e6..718c41fd 100644 --- a/packages/database/prisma/schema/station.prisma +++ b/packages/database/prisma/schema/station.prisma @@ -11,6 +11,7 @@ enum Country { NL LU LI + IT } model Station {