| Asset # | Description | Instrument | Date | Period | Next Due | Result |
|---|
Loading…
Loading…
add logo
Notice Type
| 1 | ||
| 2 | ||
| 3 | ||
| 4 | ||
| 5 |
/ Pass
| Gas Tightness Test | |
| Standing / Working Pressure Test | |
| Gas Installation Visual Check | |
| Meter / Governor Condition | |
| Emergency Control Accessible |
Loading…
Example: Base OHM655 + Month 9 + IG1 1JP score 44 / 1 MARINA POINT → OHM655944/1 MARINA POINT
pat_reportsgas_certsapp_settingscp12_autosave_v1) and PAT data every 15 seconds (pat_autosave). This survives page refresh but is local to this browser only — not synced to the cloud until you click Save.role and is_active columns, sets up admin permissions, and makes mandeepdynamics@gmail.com an admin.
Safe to run multiple times (all steps are idempotent).
-- Step 1: Add columns if they don't exist
ALTER TABLE public.profiles ADD COLUMN IF NOT EXISTS role TEXT NOT NULL DEFAULT 'engineer';
ALTER TABLE public.profiles ADD COLUMN IF NOT EXISTS is_active BOOLEAN NOT NULL DEFAULT true;
-- Step 2: Make mandeepdynamics@gmail.com an admin
UPDATE public.profiles SET role = 'admin'
WHERE email = 'mandeepdynamics@gmail.com';
-- Step 3: Drop old restrictive policies and add admin-read-all policy
DROP POLICY IF EXISTS "Users can read own profile" ON public.profiles;
DROP POLICY IF EXISTS "Admin read all profiles" ON public.profiles;
DROP POLICY IF EXISTS "Admin update profiles" ON public.profiles;
CREATE POLICY "Users can read own profile" ON public.profiles
FOR SELECT USING (auth.uid() = id);
CREATE POLICY "Admin read all profiles" ON public.profiles
FOR SELECT USING (
EXISTS (
SELECT 1 FROM public.profiles
WHERE id = auth.uid() AND role = 'admin'
)
);
CREATE POLICY "Admin update profiles" ON public.profiles
FOR UPDATE USING (
EXISTS (
SELECT 1 FROM public.profiles
WHERE id = auth.uid() AND role = 'admin'
)
);
-- Step 4: Allow admins to insert new profiles (for add-staff flow)
DROP POLICY IF EXISTS "Admin insert profiles" ON public.profiles;
CREATE POLICY "Admin insert profiles" ON public.profiles
FOR INSERT WITH CHECK (
EXISTS (
SELECT 1 FROM public.profiles
WHERE id = auth.uid() AND role = 'admin'
)
);
-- Step 5: Add must_change_password column (first-time login enforcement)
ALTER TABLE public.profiles ADD COLUMN IF NOT EXISTS must_change_password BOOLEAN NOT NULL DEFAULT false;
-- Step 6: Create staff_requests table (anyone can submit, only admins can read/update)
CREATE TABLE IF NOT EXISTS public.staff_requests (
id UUID DEFAULT gen_random_uuid() PRIMARY KEY,
full_name TEXT NOT NULL,
email TEXT NOT NULL,
message TEXT,
status TEXT NOT NULL DEFAULT 'pending',
created_at TIMESTAMPTZ DEFAULT now()
);
ALTER TABLE public.staff_requests ENABLE ROW LEVEL SECURITY;
DROP POLICY IF EXISTS "Anyone can submit request" ON public.staff_requests;
CREATE POLICY "Anyone can submit request" ON public.staff_requests
FOR INSERT WITH CHECK (true);
DROP POLICY IF EXISTS "Admin read requests" ON public.staff_requests;
CREATE POLICY "Admin read requests" ON public.staff_requests
FOR SELECT USING (
EXISTS (SELECT 1 FROM public.profiles WHERE id = auth.uid() AND role = 'admin')
);
DROP POLICY IF EXISTS "Admin update requests" ON public.staff_requests;
CREATE POLICY "Admin update requests" ON public.staff_requests
FOR UPDATE USING (
EXISTS (SELECT 1 FROM public.profiles WHERE id = auth.uid() AND role = 'admin')
);
Loading…
Loading…