/* # Create logs table for microservice 1. New Tables - `logs` - `id` (bigint, primary key) - Epoch time identifier - `body` (text) - First 200 characters of log message - `project` (text) - Project name, defaults to "Project 1" - `type` (text) - Log type, defaults to "Info" - `date` (date) - Date of the log entry - `avatar_src` (text) - Avatar source URL, defaults to "/rectangle-15.png" - `owner` (text) - Owner of the log entry, defaults to "N/A" - `description` (text) - Full log message - `created_at` (timestamptz) - Timestamp when record was created - `status` (text) - Status of the log entry, defaults to "Pending" 2. Security - Enable RLS on `logs` table - Add policy for authenticated users to insert and read logs */ CREATE TABLE IF NOT EXISTS logs ( id bigint PRIMARY KEY, body text NOT NULL, project text NOT NULL DEFAULT 'Project 1', type text NOT NULL DEFAULT 'Info', date date NOT NULL, avatar_src text NOT NULL DEFAULT '/rectangle-15.png', owner text NOT NULL DEFAULT 'N/A', description text NOT NULL, created_at timestamptz NOT NULL DEFAULT now(), status text NOT NULL DEFAULT 'Pending' ); ALTER TABLE logs ENABLE ROW LEVEL SECURITY; -- Policy to allow authenticated users to insert logs CREATE POLICY "Allow authenticated users to insert logs" ON logs FOR INSERT TO authenticated WITH CHECK (true); -- Policy to allow authenticated users to read logs CREATE POLICY "Allow authenticated users to read logs" ON logs FOR SELECT TO authenticated USING (true); -- Policy to allow service role to perform all operations CREATE POLICY "Allow service role full access" ON logs FOR ALL TO service_role USING (true);