update promo

This commit is contained in:
2026-08-25 10:56:46 +07:00
parent d8e4e8a502
commit a61f3c1f23
24 changed files with 697 additions and 134 deletions
@@ -0,0 +1,27 @@
CREATE TABLE IF NOT EXISTS public.visitor_stats (
id text PRIMARY KEY,
count bigint NOT NULL DEFAULT 0
);
INSERT INTO public.visitor_stats (id, count)
VALUES ('global', 0)
ON CONFLICT (id) DO NOTHING;
CREATE OR REPLACE FUNCTION public.increment_visitor()
RETURNS bigint
LANGUAGE sql
AS $$
UPDATE public.visitor_stats
SET count = count + 1
WHERE id = 'global'
RETURNING count;
$$;
ALTER TABLE public.visitor_stats ENABLE ROW LEVEL SECURITY;
CREATE POLICY visitor_stats_select ON public.visitor_stats
FOR SELECT TO anon
USING (true);
GRANT SELECT ON public.visitor_stats TO anon;
GRANT EXECUTE ON FUNCTION public.increment_visitor() TO anon, authenticated;