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:
@@ -6,7 +6,6 @@ import { StaffCreateNestedManyWithoutUserInputObjectSchema as StaffCreateNestedM
|
||||
import { NpiProviderCreateNestedManyWithoutUserInputObjectSchema as NpiProviderCreateNestedManyWithoutUserInputObjectSchema } from './NpiProviderCreateNestedManyWithoutUserInput.schema';
|
||||
import { ClaimCreateNestedManyWithoutUserInputObjectSchema as ClaimCreateNestedManyWithoutUserInputObjectSchema } from './ClaimCreateNestedManyWithoutUserInput.schema';
|
||||
import { InsuranceCredentialCreateNestedManyWithoutUserInputObjectSchema as InsuranceCredentialCreateNestedManyWithoutUserInputObjectSchema } from './InsuranceCredentialCreateNestedManyWithoutUserInput.schema';
|
||||
import { ShoppingVendorCreateNestedManyWithoutUserInputObjectSchema as ShoppingVendorCreateNestedManyWithoutUserInputObjectSchema } from './ShoppingVendorCreateNestedManyWithoutUserInput.schema';
|
||||
import { PaymentCreateNestedManyWithoutUpdatedByInputObjectSchema as PaymentCreateNestedManyWithoutUpdatedByInputObjectSchema } from './PaymentCreateNestedManyWithoutUpdatedByInput.schema';
|
||||
import { DatabaseBackupCreateNestedManyWithoutUserInputObjectSchema as DatabaseBackupCreateNestedManyWithoutUserInputObjectSchema } from './DatabaseBackupCreateNestedManyWithoutUserInput.schema';
|
||||
import { BackupDestinationCreateNestedManyWithoutUserInputObjectSchema as BackupDestinationCreateNestedManyWithoutUserInputObjectSchema } from './BackupDestinationCreateNestedManyWithoutUserInput.schema';
|
||||
@@ -17,9 +16,7 @@ import { TwilioSettingsCreateNestedOneWithoutUserInputObjectSchema as TwilioSett
|
||||
import { AiSettingsCreateNestedOneWithoutUserInputObjectSchema as AiSettingsCreateNestedOneWithoutUserInputObjectSchema } from './AiSettingsCreateNestedOneWithoutUserInput.schema';
|
||||
import { OfficeHoursCreateNestedOneWithoutUserInputObjectSchema as OfficeHoursCreateNestedOneWithoutUserInputObjectSchema } from './OfficeHoursCreateNestedOneWithoutUserInput.schema';
|
||||
import { OfficeContactCreateNestedOneWithoutUserInputObjectSchema as OfficeContactCreateNestedOneWithoutUserInputObjectSchema } from './OfficeContactCreateNestedOneWithoutUserInput.schema';
|
||||
import { ProcedureTimeslotCreateNestedOneWithoutUserInputObjectSchema as ProcedureTimeslotCreateNestedOneWithoutUserInputObjectSchema } from './ProcedureTimeslotCreateNestedOneWithoutUserInput.schema';
|
||||
import { InsuranceContactCreateNestedManyWithoutUserInputObjectSchema as InsuranceContactCreateNestedManyWithoutUserInputObjectSchema } from './InsuranceContactCreateNestedManyWithoutUserInput.schema';
|
||||
import { PatientConversationCreateNestedManyWithoutUserInputObjectSchema as PatientConversationCreateNestedManyWithoutUserInputObjectSchema } from './PatientConversationCreateNestedManyWithoutUserInput.schema'
|
||||
import { ProcedureTimeslotCreateNestedOneWithoutUserInputObjectSchema as ProcedureTimeslotCreateNestedOneWithoutUserInputObjectSchema } from './ProcedureTimeslotCreateNestedOneWithoutUserInput.schema'
|
||||
|
||||
const makeSchema = () => z.object({
|
||||
username: z.string(),
|
||||
@@ -32,7 +29,6 @@ const makeSchema = () => z.object({
|
||||
npiProviders: z.lazy(() => NpiProviderCreateNestedManyWithoutUserInputObjectSchema).optional(),
|
||||
claims: z.lazy(() => ClaimCreateNestedManyWithoutUserInputObjectSchema).optional(),
|
||||
insuranceCredentials: z.lazy(() => InsuranceCredentialCreateNestedManyWithoutUserInputObjectSchema).optional(),
|
||||
shoppingVendors: z.lazy(() => ShoppingVendorCreateNestedManyWithoutUserInputObjectSchema).optional(),
|
||||
updatedPayments: z.lazy(() => PaymentCreateNestedManyWithoutUpdatedByInputObjectSchema).optional(),
|
||||
backups: z.lazy(() => DatabaseBackupCreateNestedManyWithoutUserInputObjectSchema).optional(),
|
||||
backupDestinations: z.lazy(() => BackupDestinationCreateNestedManyWithoutUserInputObjectSchema).optional(),
|
||||
@@ -43,9 +39,7 @@ const makeSchema = () => z.object({
|
||||
aiSettings: z.lazy(() => AiSettingsCreateNestedOneWithoutUserInputObjectSchema).optional(),
|
||||
officeHours: z.lazy(() => OfficeHoursCreateNestedOneWithoutUserInputObjectSchema).optional(),
|
||||
officeContact: z.lazy(() => OfficeContactCreateNestedOneWithoutUserInputObjectSchema).optional(),
|
||||
procedureTimeslot: z.lazy(() => ProcedureTimeslotCreateNestedOneWithoutUserInputObjectSchema).optional(),
|
||||
insuranceContacts: z.lazy(() => InsuranceContactCreateNestedManyWithoutUserInputObjectSchema).optional(),
|
||||
patientConversations: z.lazy(() => PatientConversationCreateNestedManyWithoutUserInputObjectSchema).optional()
|
||||
procedureTimeslot: z.lazy(() => ProcedureTimeslotCreateNestedOneWithoutUserInputObjectSchema).optional()
|
||||
}).strict();
|
||||
export const UserCreateWithoutCommunicationsInputObjectSchema: z.ZodType<Prisma.UserCreateWithoutCommunicationsInput> = makeSchema() as unknown as z.ZodType<Prisma.UserCreateWithoutCommunicationsInput>;
|
||||
export const UserCreateWithoutCommunicationsInputObjectZodSchema = makeSchema();
|
||||
|
||||
Reference in New Issue
Block a user