Skip to content

Commit a8b3c8f

Browse files
authored
Roam: Eng-450 remove unused db functions (#315)
* drop unused functions * one slipped * address review * don't remove any embedding function * chore: trigger CI build
1 parent c340f12 commit a8b3c8f

File tree

6 files changed

+13
-641
lines changed

6 files changed

+13
-641
lines changed

packages/database/supabase/config.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ schema_paths = [
5858
'./schemas/concept.sql',
5959
'./schemas/contributor.sql',
6060
'./schemas/sync.sql',
61-
'./schemas/upload_temp.sql',
6261
'./schemas/access_token.sql',
6362
]
6463

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
drop function if exists "public"."alpha_delete_by_source_local_ids"(p_space_name text, p_source_local_ids text[]);
2+
3+
drop function if exists "public"."alpha_get_last_update_time"(p_space_name text);
4+
5+
drop function if exists "public"."alpha_upsert_discourse_nodes"(p_space_name text, p_user_email text, p_user_name text, p_nodes jsonb);
6+
7+
drop function if exists "public"."upsert_discourse_nodes"(p_space_name text, p_user_email text, p_user_name text, p_nodes jsonb, p_platform_name text, p_platform_url text, p_space_url text, p_agent_type text, p_content_scale text, p_embedding_model text, p_document_source_id text);
8+
9+
drop function if exists "public"."get_nodes_needing_sync"(nodes_from_roam jsonb);

packages/database/supabase/schemas/embedding.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,4 +106,4 @@ ALTER TABLE public."ContentEmbedding_openai_text_embedding_3_small_1536" ENABLE
106106

107107
DROP POLICY IF EXISTS embedding_openai_te3s_1536_policy ON public."ContentEmbedding_openai_text_embedding_3_small_1536" ;
108108
CREATE POLICY embedding_openai_te3s_1536_policy ON public."ContentEmbedding_openai_text_embedding_3_small_1536"
109-
FOR ALL USING (public.content_in_space (target_id)) ;
109+
FOR ALL USING (public.content_in_space (target_id)) ;

packages/database/supabase/schemas/sync.sql

Lines changed: 0 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -169,45 +169,6 @@ ALTER FUNCTION public.propose_sync_task(
169169
"task_interval" interval
170170
) OWNER TO "postgres";
171171

172-
CREATE OR REPLACE FUNCTION public.get_nodes_needing_sync(nodes_from_roam jsonb)
173-
RETURNS TABLE (uid_to_sync text)
174-
SET search_path = ''
175-
LANGUAGE plpgsql
176-
AS $function$
177-
DECLARE
178-
node_info jsonb;
179-
roam_node_uid TEXT;
180-
roam_node_edit_epoch_ms BIGINT;
181-
content_db_last_modified_epoch_ms BIGINT;
182-
BEGIN
183-
FOR node_info IN SELECT * FROM jsonb_array_elements(nodes_from_roam)
184-
LOOP
185-
roam_node_uid := (node_info->>'uid')::text;
186-
roam_node_edit_epoch_ms := (node_info->>'roam_edit_time')::bigint;
187-
188-
-- Get the last_modified time from your Content table for the current node, converting it to epoch milliseconds
189-
-- Assumes your 'last_modified' column in 'Content' is a timestamp type
190-
SELECT EXTRACT(EPOCH FROM c.last_modified) * 1000
191-
INTO content_db_last_modified_epoch_ms
192-
FROM public."Content" c -- Ensure "Content" matches your table name exactly (case-sensitive if quoted)
193-
WHERE c.source_local_id = roam_node_uid;
194-
195-
IF NOT FOUND THEN
196-
-- Node does not exist in Supabase Content table, so it needs sync
197-
uid_to_sync := roam_node_uid;
198-
RETURN NEXT;
199-
ELSE
200-
-- Node exists, compare timestamps
201-
IF roam_node_edit_epoch_ms > content_db_last_modified_epoch_ms THEN
202-
uid_to_sync := roam_node_uid;
203-
RETURN NEXT;
204-
END IF;
205-
END IF;
206-
END LOOP;
207-
RETURN;
208-
END;
209-
$function$
210-
;
211172

212173
GRANT ALL ON TABLE public.sync_info TO "anon";
213174
GRANT ALL ON TABLE public.sync_info TO "authenticated";
@@ -258,10 +219,6 @@ GRANT ALL ON FUNCTION public.propose_sync_task(
258219
"task_interval" interval
259220
) TO "service_role";
260221

261-
GRANT ALL ON FUNCTION public.get_nodes_needing_sync(nodes_from_roam jsonb) TO "anon";
262-
GRANT ALL ON FUNCTION public.get_nodes_needing_sync(nodes_from_roam jsonb) TO "authenticated";
263-
GRANT ALL ON FUNCTION public.get_nodes_needing_sync(nodes_from_roam jsonb) TO "service_role";
264-
265222

266223
CREATE OR REPLACE FUNCTION public.generic_entity_access(target_id BIGINT, target_type public."EntityType") RETURNS boolean
267224
STABLE SECURITY DEFINER

0 commit comments

Comments
 (0)