diff --git a/apps/db/migrations/22_updated_at_renamed.up.sql b/apps/db/migrations/22_updated_at_renamed.up.sql new file mode 100644 index 0000000..7a1c1ab --- /dev/null +++ b/apps/db/migrations/22_updated_at_renamed.up.sql @@ -0,0 +1,10 @@ +DO $$ BEGIN + IF EXISTS ( + SELECT 1 FROM information_schema.columns + WHERE table_schema = 'public' + AND table_name = 'annunci' + AND column_name = 'updated_at' + ) THEN + ALTER TABLE public.annunci RENAME COLUMN "updated_at" TO "media_updated_at"; + END IF; +END $$; \ No newline at end of file diff --git a/apps/infoalloggi/src/components/annunci_map.tsx b/apps/infoalloggi/src/components/annunci_map.tsx index 4f843c4..15a2d4f 100644 --- a/apps/infoalloggi/src/components/annunci_map.tsx +++ b/apps/infoalloggi/src/components/annunci_map.tsx @@ -123,7 +123,7 @@ const SelectedComp = memo( alt="a" className="size-24 rounded-md object-cover sm:size-40" height={500} - src={`/storage-api/get/${selected.images[0].img}?image=true&${selected.updated_at?.toString() || new Date().toString()}`} + src={`/storage-api/get/${selected.images[0].img}?image=true&${selected.media_updated_at?.toString() || new Date().toString()}`} width={500} /> ) : ( diff --git a/apps/infoalloggi/src/components/annuncio_card.tsx b/apps/infoalloggi/src/components/annuncio_card.tsx index 9dfce10..e3e01c0 100644 --- a/apps/infoalloggi/src/components/annuncio_card.tsx +++ b/apps/infoalloggi/src/components/annuncio_card.tsx @@ -54,7 +54,7 @@ export const CardAnnuncio = ({ stato, className, url_video: videos, - updated_at, + media_updated_at, images, homepage, noLink = false, @@ -167,7 +167,7 @@ export const CardAnnuncio = ({ > & { images: Pick<{ img: string; thumb: string }, "img">[]; }; @@ -56,7 +56,9 @@ export const AnnuncioCard = ({ className }: { className?: string }) => { className={className} data={{ ...data, - updated_at: data.updated_at ? new Date(data.updated_at) : null, + media_updated_at: data.media_updated_at + ? new Date(data.media_updated_at) + : null, }} interactions={} /> @@ -90,7 +92,7 @@ export const BasicAnnuncioCard = ({ priority src={ (data?.images[0] && - `/storage-api/get/${data.images[0].img}?image=true&${data.updated_at?.toString() || new Date().toISOString()}`) || + `/storage-api/get/${data.images[0].img}?image=true&${data.media_updated_at?.toString() || new Date().toISOString()}`) || "/fallback-image.png" } width={1920} @@ -180,7 +182,7 @@ const AnnuncioDettaglio = ({ data }: { data: AnnuncioData }) => { className={"h-80 w-full object-contain sm:h-[35rem]"} height={200} priority={idx === 0} - src={`/storage-api/get/${img.img}?image=true&${data.updated_at?.toString() || new Date().toString()}`} + src={`/storage-api/get/${img.img}?image=true&${data.media_updated_at?.toString() || new Date().toString()}`} width={400} /> diff --git a/apps/infoalloggi/src/forms/FormEditAnnuncio.tsx b/apps/infoalloggi/src/forms/FormEditAnnuncio.tsx index 5fc09cd..179fa39 100644 --- a/apps/infoalloggi/src/forms/FormEditAnnuncio.tsx +++ b/apps/infoalloggi/src/forms/FormEditAnnuncio.tsx @@ -236,7 +236,7 @@ export const AnnuncioEditForm = ({ data }: { data: AnnunciWithImages }) => { Annuncio {data.codice} - {data.updated_at?.toLocaleString("it-IT")} + {data.media_updated_at?.toLocaleString("it-IT")}