Fixed migrations
This commit is contained in:
@@ -1,15 +1,21 @@
|
||||
-- Recreate a permissive INSERT policy for authenticated users on task_activity_logs
|
||||
-- Idempotent: drops existing policy and recreates it.
|
||||
|
||||
DO $$
|
||||
BEGIN
|
||||
IF EXISTS (SELECT 1 FROM information_schema.tables WHERE table_name='task_activity_logs') THEN
|
||||
-- enable RLS (idempotent)
|
||||
-- Check specifically in the 'public' schema
|
||||
IF EXISTS (
|
||||
SELECT 1 FROM information_schema.tables
|
||||
WHERE table_schema = 'public' AND table_name = 'task_activity_logs'
|
||||
) THEN
|
||||
|
||||
-- Enable RLS (idempotent)
|
||||
EXECUTE 'ALTER TABLE IF EXISTS public.task_activity_logs ENABLE ROW LEVEL SECURITY';
|
||||
|
||||
-- drop any old policy and recreate permissive insert policy for authenticated role
|
||||
-- Drop any old policy and recreate permissive insert policy for authenticated role
|
||||
EXECUTE 'DROP POLICY IF EXISTS allow_authenticated_inserts ON public.task_activity_logs';
|
||||
EXECUTE 'CREATE POLICY allow_authenticated_inserts ON public.task_activity_logs FOR INSERT TO authenticated USING (true) WITH CHECK (true)';
|
||||
|
||||
-- CREATE POLICY for INSERT strictly uses WITH CHECK
|
||||
EXECUTE 'CREATE POLICY allow_authenticated_inserts ON public.task_activity_logs
|
||||
FOR INSERT TO authenticated WITH CHECK (true)';
|
||||
|
||||
END IF;
|
||||
END
|
||||
$$;
|
||||
$$;
|
||||
Reference in New Issue
Block a user