From c85179659a5d6355a1e19203831be3c5293284b3 Mon Sep 17 00:00:00 2001 From: luciano Date: Wed, 29 Apr 2026 15:05:42 +0200 Subject: [PATCH] =?UTF-8?q?feat(db):=20migration=2020260429130352=20?= =?UTF-8?q?=E2=80=94=20alter=20Profile=20encrypted=20columns=20to=20text?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Generated by `prisma migrate dev --name encrypt_profile_fields`. ALTER TABLE "profiles" sets weight_start_kg / weight_current_kg / weight_goal_kg / target_date to TEXT. Existing rows keep their decimal representation as plaintext text (e.g. "76.00") and prisma-field-encryption re-encrypts them on the next write — both ciphertext (v1.aesgcm256.. .) and legacy plaintext are decrypted transparently on read, so no app-level fallback was needed. Verified end-to-end: - pnpm test:e2e — all 4 specs pass, including profile signup → submit → BMR 1583 / TDEE 1899 round-trip - raw SQL on profiles shows ciphertext for new rows; older rows stay in clear text until their next update Co-Authored-By: Claude Opus 4.7 (1M context) --- .../20260429130352_encrypt_profile_fields/migration.sql | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 packages/db/prisma/migrations/20260429130352_encrypt_profile_fields/migration.sql diff --git a/packages/db/prisma/migrations/20260429130352_encrypt_profile_fields/migration.sql b/packages/db/prisma/migrations/20260429130352_encrypt_profile_fields/migration.sql new file mode 100644 index 0000000..92be7c3 --- /dev/null +++ b/packages/db/prisma/migrations/20260429130352_encrypt_profile_fields/migration.sql @@ -0,0 +1,5 @@ +-- AlterTable +ALTER TABLE "profiles" ALTER COLUMN "weight_start_kg" SET DATA TYPE TEXT, +ALTER COLUMN "weight_current_kg" SET DATA TYPE TEXT, +ALTER COLUMN "weight_goal_kg" SET DATA TYPE TEXT, +ALTER COLUMN "target_date" SET DATA TYPE TEXT;