From 40001fa8b253df117bd1661b2e14f43b90917666 Mon Sep 17 00:00:00 2001 From: Arnaud AMBROSELLI Date: Thu, 8 Aug 2024 14:56:41 +0200 Subject: [PATCH] fix: appDevice user field --- api/package.json | 1 + api/prisma/migrations/20240808125617_app_device/migration.sql | 2 ++ api/prisma/schema.prisma | 1 + api/src/controllers/event.js | 2 ++ 4 files changed, 6 insertions(+) create mode 100644 api/prisma/migrations/20240808125617_app_device/migration.sql diff --git a/api/package.json b/api/package.json index 305da6e79..7eb6030f6 100644 --- a/api/package.json +++ b/api/package.json @@ -13,6 +13,7 @@ "test-notification": "cross-env NODE_ENV=development node ./src/scripts/test-notification.js", "dev-cron": "nodemon ./src/cronjobs.js ", "create-migration": "cross-env NODE_ENV=development npx prisma migrate dev --name", + "apply-migration-on-new-dev-db": "cross-env NODE_ENV=development npx prisma migrate deploy", "start": "NODE_ENV=production npx prisma migrate deploy && NODE_ENV=production node ./src/server.js", "postinstall": "prisma generate", "test": "jest", diff --git a/api/prisma/migrations/20240808125617_app_device/migration.sql b/api/prisma/migrations/20240808125617_app_device/migration.sql new file mode 100644 index 000000000..35401592b --- /dev/null +++ b/api/prisma/migrations/20240808125617_app_device/migration.sql @@ -0,0 +1,2 @@ +-- AlterTable +ALTER TABLE "User" ADD COLUMN "appDevice" TEXT; diff --git a/api/prisma/schema.prisma b/api/prisma/schema.prisma index 5c3f1f5c1..17725b3cd 100644 --- a/api/prisma/schema.prisma +++ b/api/prisma/schema.prisma @@ -33,6 +33,7 @@ model User { updatedAt DateTime @default(now()) @updatedAt drinksContextRequests DrinksContextRequest[] appVersion String? + appDevice String? strategies Strategy[] isOverWritten Boolean @default(false) diff --git a/api/src/controllers/event.js b/api/src/controllers/event.js index a32d51115..c766f4c77 100644 --- a/api/src/controllers/event.js +++ b/api/src/controllers/event.js @@ -20,10 +20,12 @@ router.post( if (action === "APP_OPEN") { const appVersion = req.headers.appversion; + const appDevice = req.headers.appdevice; await prisma.user.update({ where: { matomo_id: matomoId }, data: { appVersion: appVersion, + appDevice: appDevice, }, }); }