-- Run this in the Supabase REST API (SQL Editor) to create the table for usage_demo.rs

CREATE TABLE public.countries (
    id bigint GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,
    created_at timestamp with time zone DEFAULT timezone('utc'::text, now()) NOT NULL,
    name text NOT NULL,
    iso2 text NOT NULL,
    continent text
);

-- Enable RLS (Optional, but good practice)
ALTER TABLE public.countries ENABLE ROW LEVEL SECURITY;

-- Allow anonymous access for the demo (WARNING: For demo purposes only!)
CREATE POLICY "Enable read access for all users" ON public.countries FOR SELECT USING (true);
CREATE POLICY "Enable insert access for all users" ON public.countries FOR INSERT WITH CHECK (true);

-- Insert fake data
INSERT INTO public.countries (name, iso2, continent)
VALUES 
  ('Brazil', 'BR', 'South America'),
  ('New Zealand', 'NZ', 'Oceania'),
  ('United States', 'US', 'North America'),
  ('France', 'FR', 'Europe'),
  ('Japan', 'JP', 'Asia'),
  ('Egypt', 'EG', 'Africa'),
  ('Antarctica', 'AQ', 'Antarctica');
