diff options
| author | Fuwn <[email protected]> | 2026-02-11 06:14:51 -0800 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2026-02-11 06:14:51 -0800 |
| commit | 7b7650ec24b8d9bc76eb8fe57a6e65912151f747 (patch) | |
| tree | 95bd291c2a9a74fcb1f024b807c1bf36224464d9 | |
| parent | feat: add previous/next navigation buttons on mobile detail view (diff) | |
| download | asa.news-7b7650ec24b8d9bc76eb8fe57a6e65912151f747.tar.xz asa.news-7b7650ec24b8d9bc76eb8fe57a6e65912151f747.zip | |
Redump latest Supabase schema
| -rw-r--r-- | supabase/schema.sql | 75 |
1 files changed, 42 insertions, 33 deletions
diff --git a/supabase/schema.sql b/supabase/schema.sql index 506c127..7d2fa6c 100644 --- a/supabase/schema.sql +++ b/supabase/schema.sql @@ -2,7 +2,7 @@ -- PostgreSQL database dump -- --- \restrict 0mmsTcufp2FI3XpIMChzPAZKFqddFPKhI5BSvb2hP6z6YzXtiBKaTn2Wpanvc7Q +-- \restrict WfBftBa2FBaIUQXqx7Cp1KF3Bwxh3O5RTj1axY30px9LdUnvAINNXEbxzkAHb3i -- Dumped from database version 17.6 -- Dumped by pg_dump version 17.6 @@ -850,48 +850,57 @@ $$; ALTER FUNCTION "public"."handle_new_user"() OWNER TO "postgres"; -- --- Name: mark_all_as_read("uuid", "uuid", boolean); Type: FUNCTION; Schema: public; Owner: postgres +-- Name: mark_all_as_read("uuid", "uuid", boolean, "uuid"[]); Type: FUNCTION; Schema: public; Owner: postgres -- -CREATE OR REPLACE FUNCTION "public"."mark_all_as_read"("p_feed_id" "uuid" DEFAULT NULL::"uuid", "p_folder_id" "uuid" DEFAULT NULL::"uuid", "p_read_state" boolean DEFAULT true) RETURNS bigint +CREATE OR REPLACE FUNCTION "public"."mark_all_as_read"("p_feed_id" "uuid" DEFAULT NULL::"uuid", "p_folder_id" "uuid" DEFAULT NULL::"uuid", "p_read_state" boolean DEFAULT true, "p_entry_ids" "uuid"[] DEFAULT NULL::"uuid"[]) RETURNS "uuid"[] LANGUAGE "plpgsql" SECURITY DEFINER SET "search_path" TO 'public' AS $$ DECLARE - affected_count bigint; + affected_ids uuid[]; BEGIN IF p_read_state THEN - INSERT INTO user_entry_states (user_id, entry_id, read, saved) - SELECT auth.uid(), e.id, true, false - FROM entries e - INNER JOIN subscriptions s ON s.feed_id = e.feed_id AND s.user_id = auth.uid() - LEFT JOIN user_entry_states ues ON ues.entry_id = e.id AND ues.user_id = auth.uid() - WHERE (ues.read IS NULL OR ues.read = false) - AND (p_feed_id IS NULL OR e.feed_id = p_feed_id) - AND (p_folder_id IS NULL OR s.folder_id = p_folder_id) - ON CONFLICT (user_id, entry_id) - DO UPDATE SET read = true; + WITH affected AS ( + INSERT INTO user_entry_states (user_id, entry_id, read, saved) + SELECT auth.uid(), e.id, true, false + FROM entries e + INNER JOIN subscriptions s ON s.feed_id = e.feed_id AND s.user_id = auth.uid() + LEFT JOIN user_entry_states ues ON ues.entry_id = e.id AND ues.user_id = auth.uid() + WHERE (ues.read IS NULL OR ues.read = false) + AND (p_entry_ids IS NULL OR e.id = ANY(p_entry_ids)) + AND (p_feed_id IS NULL OR e.feed_id = p_feed_id) + AND (p_folder_id IS NULL OR s.folder_id = p_folder_id) + ON CONFLICT (user_id, entry_id) + DO UPDATE SET read = true + RETURNING entry_id + ) + SELECT array_agg(entry_id) INTO affected_ids FROM affected; ELSE - UPDATE user_entry_states - SET read = false - WHERE user_id = auth.uid() - AND read = true - AND entry_id IN ( - SELECT e.id - FROM entries e - INNER JOIN subscriptions s ON s.feed_id = e.feed_id AND s.user_id = auth.uid() - WHERE (p_feed_id IS NULL OR e.feed_id = p_feed_id) - AND (p_folder_id IS NULL OR s.folder_id = p_folder_id) - ); + WITH affected AS ( + UPDATE user_entry_states + SET read = false + WHERE user_id = auth.uid() + AND read = true + AND (p_entry_ids IS NULL OR entry_id = ANY(p_entry_ids)) + AND entry_id IN ( + SELECT e.id + FROM entries e + INNER JOIN subscriptions s ON s.feed_id = e.feed_id AND s.user_id = auth.uid() + WHERE (p_feed_id IS NULL OR e.feed_id = p_feed_id) + AND (p_folder_id IS NULL OR s.folder_id = p_folder_id) + ) + RETURNING entry_id + ) + SELECT array_agg(entry_id) INTO affected_ids FROM affected; END IF; - GET DIAGNOSTICS affected_count = ROW_COUNT; - RETURN affected_count; + RETURN COALESCE(affected_ids, ARRAY[]::uuid[]); END; $$; -ALTER FUNCTION "public"."mark_all_as_read"("p_feed_id" "uuid", "p_folder_id" "uuid", "p_read_state" boolean) OWNER TO "postgres"; +ALTER FUNCTION "public"."mark_all_as_read"("p_feed_id" "uuid", "p_folder_id" "uuid", "p_read_state" boolean, "p_entry_ids" "uuid"[]) OWNER TO "postgres"; -- -- Name: prevent_billing_column_modification(); Type: FUNCTION; Schema: public; Owner: postgres @@ -3338,12 +3347,12 @@ GRANT ALL ON FUNCTION "public"."handle_new_user"() TO "service_role"; -- --- Name: FUNCTION "mark_all_as_read"("p_feed_id" "uuid", "p_folder_id" "uuid", "p_read_state" boolean); Type: ACL; Schema: public; Owner: postgres +-- Name: FUNCTION "mark_all_as_read"("p_feed_id" "uuid", "p_folder_id" "uuid", "p_read_state" boolean, "p_entry_ids" "uuid"[]); Type: ACL; Schema: public; Owner: postgres -- -REVOKE ALL ON FUNCTION "public"."mark_all_as_read"("p_feed_id" "uuid", "p_folder_id" "uuid", "p_read_state" boolean) FROM PUBLIC; -GRANT ALL ON FUNCTION "public"."mark_all_as_read"("p_feed_id" "uuid", "p_folder_id" "uuid", "p_read_state" boolean) TO "authenticated"; -GRANT ALL ON FUNCTION "public"."mark_all_as_read"("p_feed_id" "uuid", "p_folder_id" "uuid", "p_read_state" boolean) TO "service_role"; +GRANT ALL ON FUNCTION "public"."mark_all_as_read"("p_feed_id" "uuid", "p_folder_id" "uuid", "p_read_state" boolean, "p_entry_ids" "uuid"[]) TO "anon"; +GRANT ALL ON FUNCTION "public"."mark_all_as_read"("p_feed_id" "uuid", "p_folder_id" "uuid", "p_read_state" boolean, "p_entry_ids" "uuid"[]) TO "authenticated"; +GRANT ALL ON FUNCTION "public"."mark_all_as_read"("p_feed_id" "uuid", "p_folder_id" "uuid", "p_read_state" boolean, "p_entry_ids" "uuid"[]) TO "service_role"; -- @@ -3719,5 +3728,5 @@ ALTER DEFAULT PRIVILEGES FOR ROLE "postgres" IN SCHEMA "public" GRANT ALL ON TAB -- PostgreSQL database dump complete -- --- \unrestrict 0mmsTcufp2FI3XpIMChzPAZKFqddFPKhI5BSvb2hP6z6YzXtiBKaTn2Wpanvc7Q +-- \unrestrict WfBftBa2FBaIUQXqx7Cp1KF3Bwxh3O5RTj1axY30px9LdUnvAINNXEbxzkAHb3i |