/*
  # Add admin RLS policies for anonymous operations

  This migration adds RLS policies to allow anonymous users to perform admin operations.
  
  **SECURITY WARNING**: This is intended for development/demo purposes only.
  In production, implement proper Supabase authentication for admin users.

  ## Changes Made
  1. Add policies for anonymous users to insert/update/delete jobs
  2. Add policies for anonymous users to update job applications status
  3. Add policies for anonymous users to insert/update/delete certificates
  4. Add policies for anonymous users to update contact messages status
  5. Add policies for anonymous users to manage portfolio projects and testimonials

  ## Security Notes
  - These policies allow any anonymous user to perform admin operations
  - Consider implementing proper authentication before production deployment
*/

-- Jobs table policies for admin operations
CREATE POLICY "Allow anon insert jobs" ON jobs
  FOR INSERT TO anon
  WITH CHECK (true);

CREATE POLICY "Allow anon update jobs" ON jobs
  FOR UPDATE TO anon
  USING (true)
  WITH CHECK (true);

CREATE POLICY "Allow anon delete jobs" ON jobs
  FOR DELETE TO anon
  USING (true);

-- Job applications policies for status updates
CREATE POLICY "Allow anon update job applications" ON job_applications
  FOR UPDATE TO anon
  USING (true)
  WITH CHECK (true);

-- Certificates table policies for admin operations
CREATE POLICY "Allow anon insert certificates" ON certificates
  FOR INSERT TO anon
  WITH CHECK (true);

CREATE POLICY "Allow anon update certificates" ON certificates
  FOR UPDATE TO anon
  USING (true)
  WITH CHECK (true);

CREATE POLICY "Allow anon delete certificates" ON certificates
  FOR DELETE TO anon
  USING (true);

-- Contact messages policies for status updates
CREATE POLICY "Allow anon update contact messages" ON contact_messages
  FOR UPDATE TO anon
  USING (true)
  WITH CHECK (true);

-- Portfolio projects policies for admin operations
CREATE POLICY "Allow anon insert portfolio" ON portfolio_projects
  FOR INSERT TO anon
  WITH CHECK (true);

CREATE POLICY "Allow anon update portfolio" ON portfolio_projects
  FOR UPDATE TO anon
  USING (true)
  WITH CHECK (true);

CREATE POLICY "Allow anon delete portfolio" ON portfolio_projects
  FOR DELETE TO anon
  USING (true);

-- Testimonials policies for admin operations
CREATE POLICY "Allow anon insert testimonials" ON testimonials
  FOR INSERT TO anon
  WITH CHECK (true);

CREATE POLICY "Allow anon update testimonials" ON testimonials
  FOR UPDATE TO anon
  USING (true)
  WITH CHECK (true);

CREATE POLICY "Allow anon delete testimonials" ON testimonials
  FOR DELETE TO anon
  USING (true);