iloom-flatten/migrations/20260601_025159_create_check_share_links_expired_function.sql
github-actions[bot] b6e2e526d9 sync: Add files via upload
重大版本更新 (A@029ab8fcd9c4f587ce7a2394252868172d8e5d79)
2026-06-04 13:57:36 +00:00

26 lines
737 B
PL/PgSQL
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

-- ============================================
-- 此文件由 Meoo Cloud 自动生成,请勿修改
-- This file is auto-generated by Meoo Cloud, DO NOT MODIFY
-- ============================================
-- 创建自动检查分享链接过期的函数
CREATE OR REPLACE FUNCTION public.check_share_links_expired()
RETURNS void
LANGUAGE plpgsql
SECURITY DEFINER
AS $function$
BEGIN
-- 更新已过期的分享链接状态
UPDATE share_links
SET status = 'expired'
WHERE status IN ('pending', 'clicked')
AND expires_at < NOW();
END;
$function$;
-- 创建定时触发器(每小时检查一次)
-- 注意Supabase 不支持 pg_cron 扩展,需要在应用层调用此函数
-- 或者使用 Edge Function 定时任务