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:
+2
-8
@@ -6,7 +6,6 @@ import { StaffUncheckedCreateNestedManyWithoutUserInputObjectSchema as StaffUnch
|
||||
import { NpiProviderUncheckedCreateNestedManyWithoutUserInputObjectSchema as NpiProviderUncheckedCreateNestedManyWithoutUserInputObjectSchema } from './NpiProviderUncheckedCreateNestedManyWithoutUserInput.schema';
|
||||
import { ClaimUncheckedCreateNestedManyWithoutUserInputObjectSchema as ClaimUncheckedCreateNestedManyWithoutUserInputObjectSchema } from './ClaimUncheckedCreateNestedManyWithoutUserInput.schema';
|
||||
import { InsuranceCredentialUncheckedCreateNestedManyWithoutUserInputObjectSchema as InsuranceCredentialUncheckedCreateNestedManyWithoutUserInputObjectSchema } from './InsuranceCredentialUncheckedCreateNestedManyWithoutUserInput.schema';
|
||||
import { ShoppingVendorUncheckedCreateNestedManyWithoutUserInputObjectSchema as ShoppingVendorUncheckedCreateNestedManyWithoutUserInputObjectSchema } from './ShoppingVendorUncheckedCreateNestedManyWithoutUserInput.schema';
|
||||
import { PaymentUncheckedCreateNestedManyWithoutUpdatedByInputObjectSchema as PaymentUncheckedCreateNestedManyWithoutUpdatedByInputObjectSchema } from './PaymentUncheckedCreateNestedManyWithoutUpdatedByInput.schema';
|
||||
import { DatabaseBackupUncheckedCreateNestedManyWithoutUserInputObjectSchema as DatabaseBackupUncheckedCreateNestedManyWithoutUserInputObjectSchema } from './DatabaseBackupUncheckedCreateNestedManyWithoutUserInput.schema';
|
||||
import { NotificationUncheckedCreateNestedManyWithoutUserInputObjectSchema as NotificationUncheckedCreateNestedManyWithoutUserInputObjectSchema } from './NotificationUncheckedCreateNestedManyWithoutUserInput.schema';
|
||||
@@ -17,9 +16,7 @@ import { TwilioSettingsUncheckedCreateNestedOneWithoutUserInputObjectSchema as T
|
||||
import { AiSettingsUncheckedCreateNestedOneWithoutUserInputObjectSchema as AiSettingsUncheckedCreateNestedOneWithoutUserInputObjectSchema } from './AiSettingsUncheckedCreateNestedOneWithoutUserInput.schema';
|
||||
import { OfficeHoursUncheckedCreateNestedOneWithoutUserInputObjectSchema as OfficeHoursUncheckedCreateNestedOneWithoutUserInputObjectSchema } from './OfficeHoursUncheckedCreateNestedOneWithoutUserInput.schema';
|
||||
import { OfficeContactUncheckedCreateNestedOneWithoutUserInputObjectSchema as OfficeContactUncheckedCreateNestedOneWithoutUserInputObjectSchema } from './OfficeContactUncheckedCreateNestedOneWithoutUserInput.schema';
|
||||
import { ProcedureTimeslotUncheckedCreateNestedOneWithoutUserInputObjectSchema as ProcedureTimeslotUncheckedCreateNestedOneWithoutUserInputObjectSchema } from './ProcedureTimeslotUncheckedCreateNestedOneWithoutUserInput.schema';
|
||||
import { InsuranceContactUncheckedCreateNestedManyWithoutUserInputObjectSchema as InsuranceContactUncheckedCreateNestedManyWithoutUserInputObjectSchema } from './InsuranceContactUncheckedCreateNestedManyWithoutUserInput.schema';
|
||||
import { PatientConversationUncheckedCreateNestedManyWithoutUserInputObjectSchema as PatientConversationUncheckedCreateNestedManyWithoutUserInputObjectSchema } from './PatientConversationUncheckedCreateNestedManyWithoutUserInput.schema'
|
||||
import { ProcedureTimeslotUncheckedCreateNestedOneWithoutUserInputObjectSchema as ProcedureTimeslotUncheckedCreateNestedOneWithoutUserInputObjectSchema } from './ProcedureTimeslotUncheckedCreateNestedOneWithoutUserInput.schema'
|
||||
|
||||
const makeSchema = () => z.object({
|
||||
id: z.number().int().optional(),
|
||||
@@ -33,7 +30,6 @@ const makeSchema = () => z.object({
|
||||
npiProviders: z.lazy(() => NpiProviderUncheckedCreateNestedManyWithoutUserInputObjectSchema).optional(),
|
||||
claims: z.lazy(() => ClaimUncheckedCreateNestedManyWithoutUserInputObjectSchema).optional(),
|
||||
insuranceCredentials: z.lazy(() => InsuranceCredentialUncheckedCreateNestedManyWithoutUserInputObjectSchema).optional(),
|
||||
shoppingVendors: z.lazy(() => ShoppingVendorUncheckedCreateNestedManyWithoutUserInputObjectSchema).optional(),
|
||||
updatedPayments: z.lazy(() => PaymentUncheckedCreateNestedManyWithoutUpdatedByInputObjectSchema).optional(),
|
||||
backups: z.lazy(() => DatabaseBackupUncheckedCreateNestedManyWithoutUserInputObjectSchema).optional(),
|
||||
notifications: z.lazy(() => NotificationUncheckedCreateNestedManyWithoutUserInputObjectSchema).optional(),
|
||||
@@ -44,9 +40,7 @@ const makeSchema = () => z.object({
|
||||
aiSettings: z.lazy(() => AiSettingsUncheckedCreateNestedOneWithoutUserInputObjectSchema).optional(),
|
||||
officeHours: z.lazy(() => OfficeHoursUncheckedCreateNestedOneWithoutUserInputObjectSchema).optional(),
|
||||
officeContact: z.lazy(() => OfficeContactUncheckedCreateNestedOneWithoutUserInputObjectSchema).optional(),
|
||||
procedureTimeslot: z.lazy(() => ProcedureTimeslotUncheckedCreateNestedOneWithoutUserInputObjectSchema).optional(),
|
||||
insuranceContacts: z.lazy(() => InsuranceContactUncheckedCreateNestedManyWithoutUserInputObjectSchema).optional(),
|
||||
patientConversations: z.lazy(() => PatientConversationUncheckedCreateNestedManyWithoutUserInputObjectSchema).optional()
|
||||
procedureTimeslot: z.lazy(() => ProcedureTimeslotUncheckedCreateNestedOneWithoutUserInputObjectSchema).optional()
|
||||
}).strict();
|
||||
export const UserUncheckedCreateWithoutBackupDestinationsInputObjectSchema: z.ZodType<Prisma.UserUncheckedCreateWithoutBackupDestinationsInput> = makeSchema() as unknown as z.ZodType<Prisma.UserUncheckedCreateWithoutBackupDestinationsInput>;
|
||||
export const UserUncheckedCreateWithoutBackupDestinationsInputObjectZodSchema = makeSchema();
|
||||
|
||||
Reference in New Issue
Block a user