a tool for shared writing and social publishing

add sort_data column and use it

+16
+1
app/lish/[did]/[publication]/dashboard/PublishedPostsLists.tsx
··· 111 documents: { 112 uri: doc.uri, 113 indexed_at: doc.indexed_at, 114 data: doc.data, 115 }, 116 },
··· 111 documents: { 112 uri: doc.uri, 113 indexed_at: doc.indexed_at, 114 + sort_date: doc.sort_date, 115 data: doc.data, 116 }, 117 },
+1
supabase/database.types.ts
··· 337 Row: { 338 data: Json 339 indexed_at: string 340 uri: string 341 } 342 Insert: {
··· 337 Row: { 338 data: Json 339 indexed_at: string 340 + sort_date: string 341 uri: string 342 } 343 Insert: {
+14
supabase/migrations/20260125000000_add_sort_date_column.sql
···
··· 1 + -- Add sort_date computed column to documents table 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; 12 + 13 + -- Create index on sort_date for efficient ordering 14 + CREATE INDEX documents_sort_date_idx ON documents (sort_date DESC, uri DESC);