© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
Drizzle TeamDT
Drizzle Team•16mo ago•
1 reply
uber

Evolving form data and typesafety .

I'm building an app where clients submit forms and professionals can subscribe to them.

The challenge: Each service (cleaning, plumbing, etc.) has its own unique form structure. Professionals can subscribe to specific services and filter based on form fields (e.g., "only show me residential cleaning jobs").
The main problem: When service forms evolve over time (adding/removing/modifying fields), I need to preserve old submissions exactly as they were submitted. However, this breaks TypeScript/Zod type safety.

For example:
// Original cleaning form type
type CleaningForm = {
  propertyType: 'residential' | 'commercial';
  size: number;
}
type CleaningForm = {
  propertyType: 'residential' | 'commercial';
  size: number;
}


// Updated cleaning form type (removed a field field)
type CleaningForm {
  //(propertyType was removed)
  size: number;
}
type CleaningForm {
  //(propertyType was removed)
  size: number;
}

export const project = pgTable("project", {
  id: serial("id").primaryKey(),
  clientId: integer("client_id").notNull(),
  serviceId: text("service_id").notNull(),
  formData: jsonb("data").notNull(), // <---- form data store in schemalass jsonb
});
export const project = pgTable("project", {
  id: serial("id").primaryKey(),
  clientId: integer("client_id").notNull(),
  serviceId: text("service_id").notNull(),
  formData: jsonb("data").notNull(), // <---- form data store in schemalass jsonb
});

Now TypeScript/Zod will complains when accessing old submissions in my database as they dont match updated types

How do you handle this type safety problem when dealing with historical data that doesn't match your current types? Looking for patterns or approaches that maintain type safety across different versions of the same form.
Drizzle TeamJoin
The official Discord for all Drizzle related projects, such as Drizzle ORM, Drizzle Kit, Drizzle Studio and more!
11,879Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

RLS - Typesafety
Drizzle TeamDTDrizzle Team / help
16mo ago
Drizzle and Turso not showing live data.
Drizzle TeamDTDrizzle Team / help
2y ago
Checking Joined Data Directly from Type Recommendation and Retrieved Data in Dynamic findMany
Drizzle TeamDTDrizzle Team / help
3y ago
Data Retrieved As Same Data
Drizzle TeamDTDrizzle Team / help
2y ago