Appearance
Admin Tables Deep Dive ​
Purpose: Describe admin-related tables and their usage scenarios. Audience: Developer, Admin Prerequisites: Supabase project linked; RLS/admin role considerations.
admin_contact_messages (public)
- Columns (source: supabase/backups/remote-schema.sql:2185-2195)
- id uuid PK (gen_random_uuid)
- sender_id uuid NOT NULL
- subject text NOT NULL
- message text NOT NULL
- status text DEFAULT 'new' NOT NULL
- admin_response text
- responded_by uuid
- created_at timestamptz DEFAULT now() NOT NULL
- updated_at timestamptz DEFAULT now() NOT NULL
- Purpose: Store contact messages sent to admin; track response and status.
- UI:
/contact-admin(src/pages/ContactAdmin.tsx) to create; admins view via/admin/logsor a dedicated page.
admin_listing_comments (public)
- Columns (source: supabase/backups/remote-schema.sql:2201-2210)
- id uuid PK
- listing_id uuid NOT NULL
- admin_id uuid NOT NULL
- field_key text NOT NULL
- comment text NOT NULL
- is_resolved boolean DEFAULT false NOT NULL
- created_at timestamptz DEFAULT now() NOT NULL
- updated_at timestamptz DEFAULT now() NOT NULL
- Purpose: Field-level moderation feedback for listings.
- UI: Admin Listings (src/pages/admin/AdminListings.tsx) and listing detail; referenced by components under
src/components/admin/listings/*.
admin_messages (public)
- Columns (source: supabase/backups/remote-schema.sql:2216-2233)
- id uuid PK
- listing_id uuid NOT NULL
- admin_id uuid NOT NULL
- recipient_id uuid NOT NULL
- subject text DEFAULT 'Mesaj admin privind listarea' NOT NULL
- message text NOT NULL
- sent_at timestamptz DEFAULT now() NOT NULL
- read_at timestamptz
- email_sent boolean DEFAULT false NOT NULL
- notification_sent boolean DEFAULT false NOT NULL
- page_source text DEFAULT 'admin_listings'
- created_at timestamptz DEFAULT now() NOT NULL
- updated_at timestamptz DEFAULT now() NOT NULL
- Purpose: Persist admin → user messages around listings; tracks email/in-app delivery.
- UI: Admin Templates/Messaging (src/components/admin/templates/AdminDirectMessage.tsx),
/admin/templates.
admin_notification_types (public)
- Columns (source: supabase/backups/remote-schema.sql:2236-2248)
- id uuid PK
- notification_type text NOT NULL
- description_ro text NOT NULL
- description_en text NOT NULL
- frequency text NOT NULL
- is_active boolean DEFAULT true NOT NULL
- cron_schedule text
- last_sent_at timestamptz
- total_sent_count integer DEFAULT 0
- created_at timestamptz DEFAULT now() NOT NULL
- updated_at timestamptz DEFAULT now() NOT NULL
- Purpose: Catalog of admin/system notification categories and scheduling metadata.
- Usage: Referenced by schedulers (e.g., run-daily-tasks) to determine which notifications to send.
Related tables
- email_logs — see docs/architecture/email-templates.md and Data Model
- alerts — additional alerting (supabase/backups/remote-schema.sql:2254)
- reports — user reports (see Data Model)
RLS & security
- Ensure admin-only SELECT/INSERT/UPDATE as appropriate for contact messages and admin messages.
- End-user actions should only INSERT into contact messages (own sender_id) and never read arbitrary admin content.
Next steps
- Add ERD for admin tables and link to moderation flows.
- Consider status transitions and audit logs per action.