mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-10 05:12:14 +00:00
feat(db): add the v1.43 schema and drop the readable location columns
Migrations 0402 to 0410: AI usage levels, biomarker aliases and merges, medication ingredients (with the supplement label run kind), life circumstance fact kinds, AI sections and AUDIT-C, Dawarich context, the pulse day-mean method, intraday hour buckets, the readable location drop and five relation link tables. Every new column carries its reader or a pending-consumer marker. 0409 refuses to run while any home, location period or stored day still holds a readable location, and names the counts. Locations are read from the sealed copy only; the encryption backfill no longer handles them, and the demo seed writes sealed locations only. The new tables are backed up and wiped, the new sealed columns are in the rotation registry with labels of their own, the AI usage level and the life-circumstance confirmations travel with the backup, and the wellbeing score reads the mental-health screeners only.
This commit is contained in:
1 parent
0b64b80343
commit
6e72de1c35
45 files changed
+1386
-917
No files matched your search
@@ -61,7 +61,6 @@ vi.mock("@/lib/db", () => ({
|
||||
prisma: {
|
||||
user: {
|
||||
findUnique: vi.fn(async () => ({
|
||||
homeLat: null,
|
||||
homeLocationEncrypted: new Uint8Array([1]),
|
||||
homeSince: new Date("2025-01-01T00:00:00Z"),
|
||||
})),
|
||||
|
||||
@@ -63,11 +63,9 @@ export const POST = apiHandler(async (request: NextRequest) => {
|
||||
|
||||
const profile = await prisma.user.findUnique({
|
||||
where: { id: user.id },
|
||||
select: { homeLat: true, homeLocationEncrypted: true, homeSince: true },
|
||||
select: { homeLocationEncrypted: true, homeSince: true },
|
||||
});
|
||||
// The sealed home (v1.42), or the readable one the encryption backfill has
|
||||
// not cleared yet.
|
||||
if (profile?.homeLocationEncrypted == null && profile?.homeLat == null) {
|
||||
if (profile?.homeLocationEncrypted == null) {
|
||||
return apiError("Set a home location before backfilling.", 409, {
|
||||
errorCode: "environment.no_home",
|
||||
});
|
||||
|
||||
@@ -57,9 +57,6 @@ export const PUT = apiHandler(async (request: NextRequest) => {
|
||||
where: { id: user.id },
|
||||
data: {
|
||||
homeLocationEncrypted: sealLocation(home),
|
||||
homeLat: null,
|
||||
homeLon: null,
|
||||
homeLabel: null,
|
||||
homeTimezone: timezone,
|
||||
homeSince,
|
||||
},
|
||||
|
||||
@@ -48,9 +48,6 @@ export const GET = apiHandler(async () => {
|
||||
prisma.user.findUnique({
|
||||
where: { id: user.id },
|
||||
select: {
|
||||
homeLat: true,
|
||||
homeLon: true,
|
||||
homeLabel: true,
|
||||
homeLocationEncrypted: true,
|
||||
homeTimezone: true,
|
||||
homeSince: true,
|
||||
@@ -66,9 +63,6 @@ export const GET = apiHandler(async () => {
|
||||
id: true,
|
||||
startDate: true,
|
||||
endDate: true,
|
||||
lat: true,
|
||||
lon: true,
|
||||
label: true,
|
||||
locationEncrypted: true,
|
||||
},
|
||||
}),
|
||||
@@ -116,14 +110,7 @@ export const GET = apiHandler(async () => {
|
||||
]);
|
||||
|
||||
const homeLocation = profile
|
||||
? readLocation({
|
||||
sealed: profile.homeLocationEncrypted,
|
||||
lat: profile.homeLat,
|
||||
lon: profile.homeLon,
|
||||
// The label may be absent on a pre-v1.42 home; the answer has
|
||||
// always allowed a null label there.
|
||||
label: profile.homeLabel ?? "",
|
||||
})
|
||||
? readLocation(profile.homeLocationEncrypted)
|
||||
: null;
|
||||
const home =
|
||||
profile && homeLocation
|
||||
@@ -139,12 +126,7 @@ export const GET = apiHandler(async () => {
|
||||
: null;
|
||||
|
||||
const travel = travelRows.flatMap((row) => {
|
||||
const location = readLocation({
|
||||
sealed: row.locationEncrypted,
|
||||
lat: row.lat,
|
||||
lon: row.lon,
|
||||
label: row.label,
|
||||
});
|
||||
const location = readLocation(row.locationEncrypted);
|
||||
return location
|
||||
? [
|
||||
{
|
||||
|
||||
@@ -57,9 +57,6 @@ export const POST = apiHandler(async (request: NextRequest) => {
|
||||
startDate: entry.startDate,
|
||||
endDate: entry.endDate,
|
||||
locationEncrypted: sealLocation(location),
|
||||
lat: null,
|
||||
lon: null,
|
||||
label: null,
|
||||
},
|
||||
select: { id: true, startDate: true, endDate: true },
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user