# Tidy up the schema and front end code https://www.sanity.io/learn/course/handling-schema-changes-confidently/tidy-up-the-schema-and-front-end-code.md Tidy up the document form by hiding the old field. Update your front end to only query and access the new field name. With the successful content migration, you can now clean up the event document type and the front end query. For real projects, you can either remove the field completely or add `hidden: true` to hide it from content creators, keep its presence in code in cases where legacy data might enter the dataset, and you want to prevent the “unknown field” warning. 1. Remove the `eventType` field in `eventType.ts` or add `hidden: true` to hide it visually for content creators. ```typescript:apps/studio/schemaTypes/eventType.ts defineField({ name: 'eventType', type: 'string', title: 'Event type', deprecated: { reason: 'Use the "Event format" field instead.', }, readOnly: true, hidden: true, // hide from content creators, but keep it in code options: { list: ['in-person', 'virtual'], layout: 'radio', }, }), ``` 1. Remove the `"eventType": coalesce(format, eventType)` line in the GROQ query 2. Replace the `event.eventType` variable in your front end with the new `event.format` variable. Note that if you have used this same front end code for [Day one content operations](https://www.sanity.io/learn/course/day-one-with-sanity-studio) your query and components may look a little different. Adapt as required! ```tsx:apps/web/src/app/events/[slug]/page.tsx import { defineQuery, PortableText } from "next-sanity"; import Link from "next/link"; import { notFound } from "next/navigation"; import Image from "next/image"; import { sanityFetch } from "@/sanity/live"; import { urlFor } from "@/sanity/image"; const EVENT_QUERY = defineQuery(`*[ _type == "event" && slug.current == $slug ][0]{ ..., "date": coalesce(date, now()), "doorsOpen": coalesce(doorsOpen, 0), headline->, venue-> }`); export default async function EventPage({ params, }: { params: Promise<{ slug: string }>; }) { const { data: event } = await sanityFetch({ query: EVENT_QUERY, params: await params, }); if (!event) { notFound(); } const { name, date, headline, details, format, doorsOpen, venue, tickets } = event; const eventDate = new Date(date).toDateString(); const eventTime = new Date(date).toLocaleTimeString(); const doorsOpenTime = new Date( new Date(date).getTime() - doorsOpen * 60000 ).toLocaleTimeString(); const imageUrl = headline?.photo ? urlFor(headline.photo) .height(310) .width(550) .quality(80) .auto("format") .url() : "https://placehold.co/550x310/png"; return (
← Back to events
{name
{format ? (
{format.replace("-", " ")}
) : null} {name ? (

{name}

) : null} {headline?.name ? (
Artist
{headline?.name}
) : null}
Date
{eventDate &&
{eventDate}
} {eventTime &&
{eventTime}
}
{doorsOpenTime ? (
Doors Open
Doors Open
{doorsOpenTime}
) : null} {venue?.name ? (
Venue
{venue.name}
) : null}
{details && details.length > 0 && (
)} {tickets && ( Buy Tickets )}
); } ```