fix: auto-migrate after DB restore and force re-login

- After importing a backup, run prisma migrate deploy so any schema
  migrations the backup is missing are applied automatically. This
  prevents pages from failing due to missing tables/columns when the
  backup was taken on an older version of the app.
- Force logout and redirect to login after a successful restore so the
  JWT is refreshed against the restored database (prevents userId
  mismatch causing user-scoped queries to return empty results).
- Fix getTotalPatientCount() in /status route to pass userId so it
  counts only the current user's patients instead of all patients.
- Add prisma.$connect() after $disconnect() to ensure a clean reconnect.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
ff
2026-05-17 22:31:12 -04:00
co-authored by Claude Sonnet 4.6
parent b9e888fc7f
commit 5508a90d28
231 changed files with 1629 additions and 14854 deletions
@@ -9,7 +9,6 @@ import { StaffUncheckedUpdateManyWithoutUserNestedInputObjectSchema as StaffUnch
import { NpiProviderUncheckedUpdateManyWithoutUserNestedInputObjectSchema as NpiProviderUncheckedUpdateManyWithoutUserNestedInputObjectSchema } from './NpiProviderUncheckedUpdateManyWithoutUserNestedInput.schema';
import { ClaimUncheckedUpdateManyWithoutUserNestedInputObjectSchema as ClaimUncheckedUpdateManyWithoutUserNestedInputObjectSchema } from './ClaimUncheckedUpdateManyWithoutUserNestedInput.schema';
import { InsuranceCredentialUncheckedUpdateManyWithoutUserNestedInputObjectSchema as InsuranceCredentialUncheckedUpdateManyWithoutUserNestedInputObjectSchema } from './InsuranceCredentialUncheckedUpdateManyWithoutUserNestedInput.schema';
import { ShoppingVendorUncheckedUpdateManyWithoutUserNestedInputObjectSchema as ShoppingVendorUncheckedUpdateManyWithoutUserNestedInputObjectSchema } from './ShoppingVendorUncheckedUpdateManyWithoutUserNestedInput.schema';
import { PaymentUncheckedUpdateManyWithoutUpdatedByNestedInputObjectSchema as PaymentUncheckedUpdateManyWithoutUpdatedByNestedInputObjectSchema } from './PaymentUncheckedUpdateManyWithoutUpdatedByNestedInput.schema';
import { DatabaseBackupUncheckedUpdateManyWithoutUserNestedInputObjectSchema as DatabaseBackupUncheckedUpdateManyWithoutUserNestedInputObjectSchema } from './DatabaseBackupUncheckedUpdateManyWithoutUserNestedInput.schema';
import { BackupDestinationUncheckedUpdateManyWithoutUserNestedInputObjectSchema as BackupDestinationUncheckedUpdateManyWithoutUserNestedInputObjectSchema } from './BackupDestinationUncheckedUpdateManyWithoutUserNestedInput.schema';
@@ -21,9 +20,7 @@ import { TwilioSettingsUncheckedUpdateOneWithoutUserNestedInputObjectSchema as T
import { AiSettingsUncheckedUpdateOneWithoutUserNestedInputObjectSchema as AiSettingsUncheckedUpdateOneWithoutUserNestedInputObjectSchema } from './AiSettingsUncheckedUpdateOneWithoutUserNestedInput.schema';
import { OfficeHoursUncheckedUpdateOneWithoutUserNestedInputObjectSchema as OfficeHoursUncheckedUpdateOneWithoutUserNestedInputObjectSchema } from './OfficeHoursUncheckedUpdateOneWithoutUserNestedInput.schema';
import { OfficeContactUncheckedUpdateOneWithoutUserNestedInputObjectSchema as OfficeContactUncheckedUpdateOneWithoutUserNestedInputObjectSchema } from './OfficeContactUncheckedUpdateOneWithoutUserNestedInput.schema';
import { ProcedureTimeslotUncheckedUpdateOneWithoutUserNestedInputObjectSchema as ProcedureTimeslotUncheckedUpdateOneWithoutUserNestedInputObjectSchema } from './ProcedureTimeslotUncheckedUpdateOneWithoutUserNestedInput.schema';
import { InsuranceContactUncheckedUpdateManyWithoutUserNestedInputObjectSchema as InsuranceContactUncheckedUpdateManyWithoutUserNestedInputObjectSchema } from './InsuranceContactUncheckedUpdateManyWithoutUserNestedInput.schema';
import { PatientConversationUncheckedUpdateManyWithoutUserNestedInputObjectSchema as PatientConversationUncheckedUpdateManyWithoutUserNestedInputObjectSchema } from './PatientConversationUncheckedUpdateManyWithoutUserNestedInput.schema'
import { ProcedureTimeslotUncheckedUpdateOneWithoutUserNestedInputObjectSchema as ProcedureTimeslotUncheckedUpdateOneWithoutUserNestedInputObjectSchema } from './ProcedureTimeslotUncheckedUpdateOneWithoutUserNestedInput.schema'
const makeSchema = () => z.object({
id: z.union([z.number().int(), z.lazy(() => IntFieldUpdateOperationsInputObjectSchema)]).optional(),
@@ -37,7 +34,6 @@ const makeSchema = () => z.object({
npiProviders: z.lazy(() => NpiProviderUncheckedUpdateManyWithoutUserNestedInputObjectSchema).optional(),
claims: z.lazy(() => ClaimUncheckedUpdateManyWithoutUserNestedInputObjectSchema).optional(),
insuranceCredentials: z.lazy(() => InsuranceCredentialUncheckedUpdateManyWithoutUserNestedInputObjectSchema).optional(),
shoppingVendors: z.lazy(() => ShoppingVendorUncheckedUpdateManyWithoutUserNestedInputObjectSchema).optional(),
updatedPayments: z.lazy(() => PaymentUncheckedUpdateManyWithoutUpdatedByNestedInputObjectSchema).optional(),
backups: z.lazy(() => DatabaseBackupUncheckedUpdateManyWithoutUserNestedInputObjectSchema).optional(),
backupDestinations: z.lazy(() => BackupDestinationUncheckedUpdateManyWithoutUserNestedInputObjectSchema).optional(),
@@ -49,9 +45,7 @@ const makeSchema = () => z.object({
aiSettings: z.lazy(() => AiSettingsUncheckedUpdateOneWithoutUserNestedInputObjectSchema).optional(),
officeHours: z.lazy(() => OfficeHoursUncheckedUpdateOneWithoutUserNestedInputObjectSchema).optional(),
officeContact: z.lazy(() => OfficeContactUncheckedUpdateOneWithoutUserNestedInputObjectSchema).optional(),
procedureTimeslot: z.lazy(() => ProcedureTimeslotUncheckedUpdateOneWithoutUserNestedInputObjectSchema).optional(),
insuranceContacts: z.lazy(() => InsuranceContactUncheckedUpdateManyWithoutUserNestedInputObjectSchema).optional(),
patientConversations: z.lazy(() => PatientConversationUncheckedUpdateManyWithoutUserNestedInputObjectSchema).optional()
procedureTimeslot: z.lazy(() => ProcedureTimeslotUncheckedUpdateOneWithoutUserNestedInputObjectSchema).optional()
}).strict();
export const UserUncheckedUpdateInputObjectSchema: z.ZodType<Prisma.UserUncheckedUpdateInput> = makeSchema() as unknown as z.ZodType<Prisma.UserUncheckedUpdateInput>;
export const UserUncheckedUpdateInputObjectZodSchema = makeSchema();