a tool for shared writing and social publishing

make timestamp cast immutable

+3 -1
+3 -1
supabase/migrations/20260125000000_add_sort_date_column.sql
··· 2 -- This column stores the older of publishedAt (from JSON data) or indexed_at 3 -- Used for sorting feeds chronologically by when content was actually published 4 5 ALTER TABLE documents 6 ADD COLUMN sort_date timestamptz GENERATED ALWAYS AS ( 7 LEAST( 8 - COALESCE((data->>'publishedAt')::timestamptz, indexed_at), 9 indexed_at 10 ) 11 ) STORED;
··· 2 -- This column stores the older of publishedAt (from JSON data) or indexed_at 3 -- Used for sorting feeds chronologically by when content was actually published 4 5 + -- Note: We use ::timestamp AT TIME ZONE 'UTC' to make the expression immutable 6 + -- (direct ::timestamptz cast is not immutable as it depends on session timezone) 7 ALTER TABLE documents 8 ADD COLUMN sort_date timestamptz GENERATED ALWAYS AS ( 9 LEAST( 10 + COALESCE((data->>'publishedAt')::timestamp AT TIME ZONE 'UTC', indexed_at), 11 indexed_at 12 ) 13 ) STORED;