--
-- PostgreSQL database dump
--

\restrict LV0qnjUH3SWL0aBPGm6cy1ZkmlSzDJdVUfB9wNeKmjDM3b1Te6x9rqoVJJo161S

-- Dumped from database version 17.6
-- Dumped by pg_dump version 17.6

SET statement_timeout = 0;
SET lock_timeout = 0;
SET idle_in_transaction_session_timeout = 0;
SET transaction_timeout = 0;
SET client_encoding = 'UTF8';
SET standard_conforming_strings = on;
SELECT pg_catalog.set_config('search_path', '', false);
SET check_function_bodies = false;
SET xmloption = content;
SET client_min_messages = warning;
SET row_security = off;

DROP EVENT TRIGGER IF EXISTS pgrst_drop_watch;
DROP EVENT TRIGGER IF EXISTS pgrst_ddl_watch;
DROP EVENT TRIGGER IF EXISTS issue_pg_net_access;
DROP EVENT TRIGGER IF EXISTS issue_pg_graphql_access;
DROP EVENT TRIGGER IF EXISTS issue_pg_cron_access;
DROP EVENT TRIGGER IF EXISTS issue_graphql_placeholder;
DROP PUBLICATION IF EXISTS supabase_realtime_messages_publication;
DROP PUBLICATION IF EXISTS supabase_realtime;
DROP POLICY IF EXISTS frigate_models_update ON storage.objects;
DROP POLICY IF EXISTS frigate_models_select ON storage.objects;
DROP POLICY IF EXISTS frigate_models_insert ON storage.objects;
DROP POLICY IF EXISTS frigate_models_delete ON storage.objects;
DROP POLICY IF EXISTS "Users can view model files" ON storage.objects;
DROP POLICY IF EXISTS "Users can upload to their folder (form-attachments)" ON storage.objects;
DROP POLICY IF EXISTS "Users can update their own files (form-attachments)" ON storage.objects;
DROP POLICY IF EXISTS "Users can update their form logos" ON storage.objects;
DROP POLICY IF EXISTS "Users can delete their own files (form-attachments)" ON storage.objects;
DROP POLICY IF EXISTS "Users can delete their form logos" ON storage.objects;
DROP POLICY IF EXISTS "Super admin can manage model files" ON storage.objects;
DROP POLICY IF EXISTS "Public can view form attachments" ON storage.objects;
DROP POLICY IF EXISTS "Public can read model-files" ON storage.objects;
DROP POLICY IF EXISTS "Enable upload for authenticated users on test uploads" ON storage.objects;
DROP POLICY IF EXISTS "Enable upload for authenticated users on model files" ON storage.objects;
DROP POLICY IF EXISTS "Enable update for authenticated users on test uploads" ON storage.objects;
DROP POLICY IF EXISTS "Enable update for authenticated users on model files" ON storage.objects;
DROP POLICY IF EXISTS "Enable read for all users on test uploads" ON storage.objects;
DROP POLICY IF EXISTS "Enable read for all users on model files" ON storage.objects;
DROP POLICY IF EXISTS "Enable delete for authenticated users on test uploads" ON storage.objects;
DROP POLICY IF EXISTS "Enable delete for authenticated users on model files" ON storage.objects;
DROP POLICY IF EXISTS "Authenticated users can upload to model-files" ON storage.objects;
DROP POLICY IF EXISTS "Authenticated users can upload form logos" ON storage.objects;
DROP POLICY IF EXISTS "Authenticated users can update model-files" ON storage.objects;
DROP POLICY IF EXISTS "Authenticated users can delete model-files" ON storage.objects;
DROP POLICY IF EXISTS "Anyone can view form logos" ON storage.objects;
DROP POLICY IF EXISTS super_admin_system_settings_policy ON public.system_settings;
DROP POLICY IF EXISTS org_settings_view ON public.organization_settings;
DROP POLICY IF EXISTS org_settings_manage ON public.organization_settings;
DROP POLICY IF EXISTS frigate_triggers_all ON public.frigate_triggers;
DROP POLICY IF EXISTS frigate_sync_logs_all ON public.frigate_sync_logs;
DROP POLICY IF EXISTS frigate_stats_history_all ON public.frigate_stats_history;
DROP POLICY IF EXISTS frigate_model_sync_log_all ON public.frigate_model_sync_log;
DROP POLICY IF EXISTS frigate_model_registry_all ON public.frigate_model_registry;
DROP POLICY IF EXISTS frigate_model_deployments_all ON public.frigate_model_deployments;
DROP POLICY IF EXISTS frigate_deployed_models_all ON public.frigate_deployed_models;
DROP POLICY IF EXISTS autosync_view ON public.auto_sync_settings;
DROP POLICY IF EXISTS autosync_update ON public.auto_sync_settings;
DROP POLICY IF EXISTS aman_view_super_admin ON public.aman_instances;
DROP POLICY IF EXISTS aman_view_rep ON public.aman_instances;
DROP POLICY IF EXISTS aman_view_org_admin ON public.aman_instances;
DROP POLICY IF EXISTS aman_update_super ON public.aman_instances;
DROP POLICY IF EXISTS aman_update_org ON public.aman_instances;
DROP POLICY IF EXISTS aman_insert_super ON public.aman_instances;
DROP POLICY IF EXISTS aman_insert_org ON public.aman_instances;
DROP POLICY IF EXISTS aman_delete_super ON public.aman_instances;
DROP POLICY IF EXISTS aman_delete_org ON public.aman_instances;
DROP POLICY IF EXISTS "Users with admin/manager role can insert cameras" ON public.cameras;
DROP POLICY IF EXISTS "Users can view zones in their organization cameras" ON public.frigate_zones;
DROP POLICY IF EXISTS "Users can view timeline in their organization cameras" ON public.frigate_timeline;
DROP POLICY IF EXISTS "Users can view their own subscriptions" ON public.subscribers;
DROP POLICY IF EXISTS "Users can view their own subscription" ON public.subscribers;
DROP POLICY IF EXISTS "Users can view their own scan results" ON public.network_scan_results;
DROP POLICY IF EXISTS "Users can view their own roles" ON public.user_roles;
DROP POLICY IF EXISTS "Users can view their own branch roles" ON public.branch_roles;
DROP POLICY IF EXISTS "Users can view their own branch access" ON public.user_branch_access;
DROP POLICY IF EXISTS "Users can view their organization" ON public.organizations;
DROP POLICY IF EXISTS "Users can view security zones in their organization" ON public.security_zones;
DROP POLICY IF EXISTS "Users can view notification methods" ON public.notification_methods;
DROP POLICY IF EXISTS "Users can view license plates in their organization cameras" ON public.frigate_license_plates;
DROP POLICY IF EXISTS "Users can view groups in their organization" ON public.user_groups;
DROP POLICY IF EXISTS "Users can view group members in their organization" ON public.user_group_members;
DROP POLICY IF EXISTS "Users can view frigate instances in their organization" ON public.frigate_instances;
DROP POLICY IF EXISTS "Users can view form distribution in their organization" ON public.form_distribution_settings;
DROP POLICY IF EXISTS "Users can view faces in their organization cameras" ON public.frigate_faces;
DROP POLICY IF EXISTS "Users can view events in their organization" ON public.events;
DROP POLICY IF EXISTS "Users can view event types" ON public.event_types;
DROP POLICY IF EXISTS "Users can view detection rules in their organization" ON public.detection_rules;
DROP POLICY IF EXISTS "Users can view cameras in their organization" ON public.cameras;
DROP POLICY IF EXISTS "Users can view camera sources" ON public.camera_sources;
DROP POLICY IF EXISTS "Users can view camera event assignments in their organization" ON public.camera_event_assignments;
DROP POLICY IF EXISTS "Users can view camera alert assignments in their organization" ON public.camera_alert_assignments;
DROP POLICY IF EXISTS "Users can view branches in their organization" ON public.branches;
DROP POLICY IF EXISTS "Users can view all industries" ON public.industries;
DROP POLICY IF EXISTS "Users can view all frigate_reviews" ON public.frigate_reviews;
DROP POLICY IF EXISTS "Users can view all frigate_recordings" ON public.frigate_recordings;
DROP POLICY IF EXISTS "Users can view all frigate_previews" ON public.frigate_previews;
DROP POLICY IF EXISTS "Users can view all frigate_exports" ON public.frigate_exports;
DROP POLICY IF EXISTS "Users can view alert templates for their industry" ON public.alert_templates;
DROP POLICY IF EXISTS "Users can view alert template industries in their organization" ON public.alert_template_industries;
DROP POLICY IF EXISTS "Users can view alert template events" ON public.alert_template_events;
DROP POLICY IF EXISTS "Users can view alert rules in their organization cameras" ON public.frigate_alert_rules;
DROP POLICY IF EXISTS "Users can view active workflow forms" ON public.workflow_forms;
DROP POLICY IF EXISTS "Users can view active notification labels" ON public.notification_labels;
DROP POLICY IF EXISTS "Users can view Aman instances in their organization" ON public.aman_instances;
DROP POLICY IF EXISTS "Users can view AI models in their organization" ON public.ai_models;
DROP POLICY IF EXISTS "Users can view AI analysis logs in their org" ON public.ai_analysis_logs;
DROP POLICY IF EXISTS "Users can update their own subscriptions" ON public.subscribers;
DROP POLICY IF EXISTS "Users can update their own subscription" ON public.subscribers;
DROP POLICY IF EXISTS "Users can update frigate_reviews" ON public.frigate_reviews;
DROP POLICY IF EXISTS "Users can update frigate_recordings" ON public.frigate_recordings;
DROP POLICY IF EXISTS "Users can update frigate_previews" ON public.frigate_previews;
DROP POLICY IF EXISTS "Users can update frigate_exports" ON public.frigate_exports;
DROP POLICY IF EXISTS "Users can update event reviewed" ON public.events;
DROP POLICY IF EXISTS "Users can manage their own preferences" ON public.user_preferences;
DROP POLICY IF EXISTS "Users can insert their own scan results" ON public.network_scan_results;
DROP POLICY IF EXISTS "Users can insert frigate_reviews" ON public.frigate_reviews;
DROP POLICY IF EXISTS "Users can insert frigate_recordings" ON public.frigate_recordings;
DROP POLICY IF EXISTS "Users can insert frigate_previews" ON public.frigate_previews;
DROP POLICY IF EXISTS "Users can insert frigate_exports" ON public.frigate_exports;
DROP POLICY IF EXISTS "Users can delete frigate_reviews" ON public.frigate_reviews;
DROP POLICY IF EXISTS "Users can delete frigate_recordings" ON public.frigate_recordings;
DROP POLICY IF EXISTS "Users can delete frigate_previews" ON public.frigate_previews;
DROP POLICY IF EXISTS "Users can delete frigate_exports" ON public.frigate_exports;
DROP POLICY IF EXISTS "Users can create their own subscriptions" ON public.subscribers;
DROP POLICY IF EXISTS "Users can create security zones in their organization" ON public.security_zones;
DROP POLICY IF EXISTS "System can insert new subscribers" ON public.subscribers;
DROP POLICY IF EXISTS "System can insert frigate_timeline" ON public.frigate_timeline;
DROP POLICY IF EXISTS "System can insert frigate_reviews" ON public.frigate_reviews;
DROP POLICY IF EXISTS "System can insert frigate_recordings" ON public.frigate_recordings;
DROP POLICY IF EXISTS "System can insert frigate_previews" ON public.frigate_previews;
DROP POLICY IF EXISTS "System can insert events during sync" ON public.events;
DROP POLICY IF EXISTS "System can insert cameras during sync" ON public.cameras;
DROP POLICY IF EXISTS "Super admins can manage legal documents" ON public.legal_documents;
DROP POLICY IF EXISTS "Super admin can view and manage all messages" ON public.chat_messages;
DROP POLICY IF EXISTS "Super admin can view all pinned dashboards" ON public.pinned_dashboards;
DROP POLICY IF EXISTS "Super admin can view all form assignments" ON public.form_assignments;
DROP POLICY IF EXISTS "Super admin can view all branches" ON public.branches;
DROP POLICY IF EXISTS "Super admin can manage workflow forms" ON public.workflow_forms;
DROP POLICY IF EXISTS "Super admin can manage storage configs" ON public.storage_configs;
DROP POLICY IF EXISTS "Super admin can manage screen permissions" ON public.screen_permissions;
DROP POLICY IF EXISTS "Super admin can manage notification methods" ON public.notification_methods;
DROP POLICY IF EXISTS "Super admin can manage notification labels" ON public.notification_labels;
DROP POLICY IF EXISTS "Super admin can manage knowledge base" ON public.chatbot_knowledge_base;
DROP POLICY IF EXISTS "Super admin can manage form distribution" ON public.form_distribution_settings;
DROP POLICY IF EXISTS "Super admin can manage camera sources" ON public.camera_sources;
DROP POLICY IF EXISTS "Super admin can manage branch roles" ON public.branch_roles;
DROP POLICY IF EXISTS "Super admin can manage all user roles" ON public.user_roles;
DROP POLICY IF EXISTS "Super admin can manage all subscribers" ON public.subscribers;
DROP POLICY IF EXISTS "Super admin can manage all participants" ON public.chat_thread_participants;
DROP POLICY IF EXISTS "Super admin can manage all organizations" ON public.organizations;
DROP POLICY IF EXISTS "Super admin can manage all industries" ON public.industries;
DROP POLICY IF EXISTS "Super admin can manage all frigate zones" ON public.frigate_zones;
DROP POLICY IF EXISTS "Super admin can manage all frigate timeline" ON public.frigate_timeline;
DROP POLICY IF EXISTS "Super admin can manage all frigate license plates" ON public.frigate_license_plates;
DROP POLICY IF EXISTS "Super admin can manage all frigate instances" ON public.frigate_instances;
DROP POLICY IF EXISTS "Super admin can manage all frigate faces" ON public.frigate_faces;
DROP POLICY IF EXISTS "Super admin can manage all frigate alert rules" ON public.frigate_alert_rules;
DROP POLICY IF EXISTS "Super admin can manage all form submissions" ON public.form_submissions;
DROP POLICY IF EXISTS "Super admin can manage all form distribution settings" ON public.form_distribution_settings;
DROP POLICY IF EXISTS "Super admin can manage all event types" ON public.event_types;
DROP POLICY IF EXISTS "Super admin can manage all chat threads" ON public.chat_threads;
DROP POLICY IF EXISTS "Super admin can manage all camera alert assignments" ON public.camera_alert_assignments;
DROP POLICY IF EXISTS "Super admin can manage all branch access" ON public.user_branch_access;
DROP POLICY IF EXISTS "Super admin can manage all alert templates" ON public.alert_templates;
DROP POLICY IF EXISTS "Super admin can manage all Aman instances" ON public.aman_instances;
DROP POLICY IF EXISTS "Super admin can manage alert template industries" ON public.alert_template_industries;
DROP POLICY IF EXISTS "Super admin can manage alert template events" ON public.alert_template_events;
DROP POLICY IF EXISTS "Super admin can manage AI analysis logs" ON public.ai_analysis_logs;
DROP POLICY IF EXISTS "Representatives can view their assignments" ON public.form_assignments;
DROP POLICY IF EXISTS "Representatives can manage their own submissions" ON public.form_submissions;
DROP POLICY IF EXISTS "Participants can view messages in their threads" ON public.chat_messages;
DROP POLICY IF EXISTS "Participants can send messages to their threads" ON public.chat_messages;
DROP POLICY IF EXISTS "Org members can view participants for org threads" ON public.chat_thread_participants;
DROP POLICY IF EXISTS "Org members can view org threads" ON public.chat_threads;
DROP POLICY IF EXISTS "Org members can view form distribution settings" ON public.form_distribution_settings;
DROP POLICY IF EXISTS "Org members can update org threads" ON public.chat_threads;
DROP POLICY IF EXISTS "Org members can create threads in their org" ON public.chat_threads;
DROP POLICY IF EXISTS "Org members can add participants to their org threads" ON public.chat_thread_participants;
DROP POLICY IF EXISTS "Org admins/managers can view org user roles" ON public.user_roles;
DROP POLICY IF EXISTS "Org admins/managers can update submissions" ON public.form_submissions;
DROP POLICY IF EXISTS "Org admins/managers can manage form distribution settings" ON public.form_distribution_settings;
DROP POLICY IF EXISTS "Org admins can view org subscribers" ON public.subscribers;
DROP POLICY IF EXISTS "Org admins can view all subscribers" ON public.subscribers;
DROP POLICY IF EXISTS "Org admins can update subscribers" ON public.subscribers;
DROP POLICY IF EXISTS "Org admins can manage frigate instances in their organization" ON public.frigate_instances;
DROP POLICY IF EXISTS "Org admins and managers can view org pinned dashboards" ON public.pinned_dashboards;
DROP POLICY IF EXISTS "Labels: users can view their own" ON public.pinned_labels;
DROP POLICY IF EXISTS "Labels: users can update their own" ON public.pinned_labels;
DROP POLICY IF EXISTS "Labels: users can insert their own" ON public.pinned_labels;
DROP POLICY IF EXISTS "Labels: users can delete their own" ON public.pinned_labels;
DROP POLICY IF EXISTS "Company admins can manage branch access in their organization" ON public.user_branch_access;
DROP POLICY IF EXISTS "Branch managers can view branch user roles" ON public.user_roles;
DROP POLICY IF EXISTS "Branch managers can view branch pinned dashboards" ON public.pinned_dashboards;
DROP POLICY IF EXISTS "Branch managers can view branch form submissions" ON public.form_submissions;
DROP POLICY IF EXISTS "Branch managers can update branch form submissions" ON public.form_submissions;
DROP POLICY IF EXISTS "Authenticated users can view active screen permissions" ON public.screen_permissions;
DROP POLICY IF EXISTS "Anyone can view legal documents" ON public.legal_documents;
DROP POLICY IF EXISTS "Anyone can view active knowledge base" ON public.chatbot_knowledge_base;
DROP POLICY IF EXISTS "Admins can manage zones in their organization cameras" ON public.frigate_zones;
DROP POLICY IF EXISTS "Admins can manage faces in their organization" ON public.frigate_faces;
DROP POLICY IF EXISTS "Admins can manage alert rules in their organization cameras" ON public.frigate_alert_rules;
DROP POLICY IF EXISTS "Admins can manage AI models" ON public.ai_models;
DROP POLICY IF EXISTS "Admins and managers can view submissions in their organization" ON public.form_submissions;
DROP POLICY IF EXISTS "Admins and managers can update security zones" ON public.security_zones;
DROP POLICY IF EXISTS "Admins and managers can update cameras" ON public.cameras;
DROP POLICY IF EXISTS "Admins and managers can manage groups" ON public.user_groups;
DROP POLICY IF EXISTS "Admins and managers can manage group members" ON public.user_group_members;
DROP POLICY IF EXISTS "Admins and managers can manage form assignments" ON public.form_assignments;
DROP POLICY IF EXISTS "Admins and managers can manage detection rules" ON public.detection_rules;
DROP POLICY IF EXISTS "Admins and managers can manage camera event assignments" ON public.camera_event_assignments;
DROP POLICY IF EXISTS "Admins and managers can manage Aman instances" ON public.aman_instances;
DROP POLICY IF EXISTS "Admins and managers can delete security zones" ON public.security_zones;
DROP POLICY IF EXISTS "Admins and managers can delete cameras" ON public.cameras;
ALTER TABLE IF EXISTS ONLY storage.vector_indexes DROP CONSTRAINT IF EXISTS vector_indexes_bucket_id_fkey;
ALTER TABLE IF EXISTS ONLY storage.s3_multipart_uploads_parts DROP CONSTRAINT IF EXISTS s3_multipart_uploads_parts_upload_id_fkey;
ALTER TABLE IF EXISTS ONLY storage.s3_multipart_uploads_parts DROP CONSTRAINT IF EXISTS s3_multipart_uploads_parts_bucket_id_fkey;
ALTER TABLE IF EXISTS ONLY storage.s3_multipart_uploads DROP CONSTRAINT IF EXISTS s3_multipart_uploads_bucket_id_fkey;
ALTER TABLE IF EXISTS ONLY storage.objects DROP CONSTRAINT IF EXISTS "objects_bucketId_fkey";
ALTER TABLE IF EXISTS ONLY storage.iceberg_tables DROP CONSTRAINT IF EXISTS iceberg_tables_namespace_id_fkey;
ALTER TABLE IF EXISTS ONLY storage.iceberg_tables DROP CONSTRAINT IF EXISTS iceberg_tables_catalog_id_fkey;
ALTER TABLE IF EXISTS ONLY storage.iceberg_namespaces DROP CONSTRAINT IF EXISTS iceberg_namespaces_catalog_id_fkey;
ALTER TABLE IF EXISTS ONLY public.user_roles DROP CONSTRAINT IF EXISTS user_roles_user_id_fkey;
ALTER TABLE IF EXISTS ONLY public.user_roles DROP CONSTRAINT IF EXISTS user_roles_organization_id_fkey;
ALTER TABLE IF EXISTS ONLY public.user_roles DROP CONSTRAINT IF EXISTS user_roles_granted_by_fkey;
ALTER TABLE IF EXISTS ONLY public.user_preferences DROP CONSTRAINT IF EXISTS user_preferences_user_id_fkey;
ALTER TABLE IF EXISTS ONLY public.user_groups DROP CONSTRAINT IF EXISTS user_groups_organization_id_fkey;
ALTER TABLE IF EXISTS ONLY public.user_group_members DROP CONSTRAINT IF EXISTS user_group_members_user_role_id_fkey;
ALTER TABLE IF EXISTS ONLY public.user_group_members DROP CONSTRAINT IF EXISTS user_group_members_group_id_fkey;
ALTER TABLE IF EXISTS ONLY public.user_branch_access DROP CONSTRAINT IF EXISTS user_branch_access_user_id_fkey;
ALTER TABLE IF EXISTS ONLY public.user_branch_access DROP CONSTRAINT IF EXISTS user_branch_access_granted_by_fkey;
ALTER TABLE IF EXISTS ONLY public.user_branch_access DROP CONSTRAINT IF EXISTS user_branch_access_branch_id_fkey;
ALTER TABLE IF EXISTS ONLY public.system_settings DROP CONSTRAINT IF EXISTS system_settings_updated_by_fkey;
ALTER TABLE IF EXISTS ONLY public.subscribers DROP CONSTRAINT IF EXISTS subscribers_user_id_fkey;
ALTER TABLE IF EXISTS ONLY public.subscribers DROP CONSTRAINT IF EXISTS subscribers_organization_id_fkey;
ALTER TABLE IF EXISTS ONLY public.subscribers DROP CONSTRAINT IF EXISTS subscribers_approved_by_fkey;
ALTER TABLE IF EXISTS ONLY public.students DROP CONSTRAINT IF EXISTS students_organization_id_fkey;
ALTER TABLE IF EXISTS ONLY public.students DROP CONSTRAINT IF EXISTS students_branch_id_fkey;
ALTER TABLE IF EXISTS ONLY public.storage_configs DROP CONSTRAINT IF EXISTS storage_configs_created_by_fkey;
ALTER TABLE IF EXISTS ONLY public.security_zones DROP CONSTRAINT IF EXISTS security_zones_branch_id_fkey;
ALTER TABLE IF EXISTS ONLY public.organizations DROP CONSTRAINT IF EXISTS organizations_industry_id_fkey;
ALTER TABLE IF EXISTS ONLY public.organization_settings DROP CONSTRAINT IF EXISTS organization_settings_organization_id_fkey;
ALTER TABLE IF EXISTS ONLY public.notification_methods DROP CONSTRAINT IF EXISTS notification_methods_created_by_fkey;
ALTER TABLE IF EXISTS ONLY public.network_scan_results DROP CONSTRAINT IF EXISTS network_scan_results_user_id_fkey;
ALTER TABLE IF EXISTS ONLY public.legal_documents DROP CONSTRAINT IF EXISTS legal_documents_updated_by_fkey;
ALTER TABLE IF EXISTS ONLY public.legal_documents DROP CONSTRAINT IF EXISTS legal_documents_created_by_fkey;
ALTER TABLE IF EXISTS ONLY public.health_alerts DROP CONSTRAINT IF EXISTS health_alerts_student_id_fkey;
ALTER TABLE IF EXISTS ONLY public.frigate_zones DROP CONSTRAINT IF EXISTS frigate_zones_camera_id_fkey;
ALTER TABLE IF EXISTS ONLY public.frigate_triggers DROP CONSTRAINT IF EXISTS frigate_triggers_frigate_instance_id_fkey;
ALTER TABLE IF EXISTS ONLY public.frigate_timeline DROP CONSTRAINT IF EXISTS frigate_timeline_camera_id_fkey;
ALTER TABLE IF EXISTS ONLY public.frigate_sync_logs DROP CONSTRAINT IF EXISTS frigate_sync_logs_frigate_instance_id_fkey;
ALTER TABLE IF EXISTS ONLY public.frigate_stats_history DROP CONSTRAINT IF EXISTS frigate_stats_history_frigate_instance_id_fkey;
ALTER TABLE IF EXISTS ONLY public.frigate_model_sync_log DROP CONSTRAINT IF EXISTS frigate_model_sync_log_frigate_instance_id_fkey;
ALTER TABLE IF EXISTS ONLY public.frigate_model_deployments DROP CONSTRAINT IF EXISTS frigate_model_deployments_frigate_instance_id_fkey;
ALTER TABLE IF EXISTS ONLY public.frigate_model_deployments DROP CONSTRAINT IF EXISTS frigate_model_deployments_deployed_by_fkey;
ALTER TABLE IF EXISTS ONLY public.frigate_license_plates DROP CONSTRAINT IF EXISTS frigate_license_plates_frigate_instance_id_fkey;
ALTER TABLE IF EXISTS ONLY public.frigate_license_plates DROP CONSTRAINT IF EXISTS frigate_license_plates_camera_id_fkey;
ALTER TABLE IF EXISTS ONLY public.frigate_instances DROP CONSTRAINT IF EXISTS frigate_instances_branch_id_fkey;
ALTER TABLE IF EXISTS ONLY public.frigate_faces DROP CONSTRAINT IF EXISTS frigate_faces_camera_id_fkey;
ALTER TABLE IF EXISTS ONLY public.frigate_deployed_models DROP CONSTRAINT IF EXISTS frigate_deployed_models_frigate_instance_id_fkey;
ALTER TABLE IF EXISTS ONLY public.frigate_alert_rules DROP CONSTRAINT IF EXISTS frigate_alert_rules_camera_id_fkey;
ALTER TABLE IF EXISTS ONLY public.form_submissions DROP CONSTRAINT IF EXISTS form_submissions_form_assignment_id_fkey;
ALTER TABLE IF EXISTS ONLY public.form_distribution_settings DROP CONSTRAINT IF EXISTS form_distribution_settings_workflow_form_id_fkey;
ALTER TABLE IF EXISTS ONLY public.form_assignments DROP CONSTRAINT IF EXISTS form_assignments_workflow_form_id_fkey;
ALTER TABLE IF EXISTS ONLY public.frigate_timeline DROP CONSTRAINT IF EXISTS fk_frigate_timeline_instance;
ALTER TABLE IF EXISTS ONLY public.frigate_reviews DROP CONSTRAINT IF EXISTS fk_frigate_reviews_instance;
ALTER TABLE IF EXISTS ONLY public.frigate_recordings DROP CONSTRAINT IF EXISTS fk_frigate_recordings_instance;
ALTER TABLE IF EXISTS ONLY public.frigate_previews DROP CONSTRAINT IF EXISTS fk_frigate_previews_instance;
ALTER TABLE IF EXISTS ONLY public.frigate_exports DROP CONSTRAINT IF EXISTS fk_frigate_exports_instance;
ALTER TABLE IF EXISTS ONLY public.events DROP CONSTRAINT IF EXISTS events_camera_id_fkey;
ALTER TABLE IF EXISTS ONLY public.detection_rules DROP CONSTRAINT IF EXISTS detection_rules_organization_id_fkey;
ALTER TABLE IF EXISTS ONLY public.chat_threads DROP CONSTRAINT IF EXISTS chat_threads_organization_id_fkey;
ALTER TABLE IF EXISTS ONLY public.chat_thread_participants DROP CONSTRAINT IF EXISTS chat_thread_participants_thread_id_fkey;
ALTER TABLE IF EXISTS ONLY public.chat_messages DROP CONSTRAINT IF EXISTS chat_messages_thread_id_fkey;
ALTER TABLE IF EXISTS ONLY public.cameras DROP CONSTRAINT IF EXISTS cameras_security_zone_id_fkey;
ALTER TABLE IF EXISTS ONLY public.cameras DROP CONSTRAINT IF EXISTS cameras_frigate_instance_id_fkey;
ALTER TABLE IF EXISTS ONLY public.cameras DROP CONSTRAINT IF EXISTS cameras_branch_id_fkey;
ALTER TABLE IF EXISTS ONLY public.camera_sources DROP CONSTRAINT IF EXISTS camera_sources_created_by_fkey;
ALTER TABLE IF EXISTS ONLY public.camera_alert_assignments DROP CONSTRAINT IF EXISTS camera_alert_assignments_alert_template_id_fkey;
ALTER TABLE IF EXISTS ONLY public.branches DROP CONSTRAINT IF EXISTS branches_organization_id_fkey;
ALTER TABLE IF EXISTS ONLY public.branch_roles DROP CONSTRAINT IF EXISTS branch_roles_user_id_fkey;
ALTER TABLE IF EXISTS ONLY public.branch_roles DROP CONSTRAINT IF EXISTS branch_roles_branch_id_fkey;
ALTER TABLE IF EXISTS ONLY public.alert_templates DROP CONSTRAINT IF EXISTS alert_templates_created_by_fkey;
ALTER TABLE IF EXISTS ONLY public.alert_template_industries DROP CONSTRAINT IF EXISTS alert_template_industries_industry_id_fkey;
ALTER TABLE IF EXISTS ONLY public.alert_template_industries DROP CONSTRAINT IF EXISTS alert_template_industries_alert_template_id_fkey;
ALTER TABLE IF EXISTS ONLY public.alert_template_events DROP CONSTRAINT IF EXISTS alert_template_events_event_type_id_fkey;
ALTER TABLE IF EXISTS ONLY public.alert_template_events DROP CONSTRAINT IF EXISTS alert_template_events_alert_template_id_fkey;
ALTER TABLE IF EXISTS ONLY public.ai_analysis_logs DROP CONSTRAINT IF EXISTS ai_analysis_logs_camera_id_fkey;
ALTER TABLE IF EXISTS ONLY public.ai_analysis_logs DROP CONSTRAINT IF EXISTS ai_analysis_logs_alert_template_id_fkey;
ALTER TABLE IF EXISTS ONLY auth.webauthn_credentials DROP CONSTRAINT IF EXISTS webauthn_credentials_user_id_fkey;
ALTER TABLE IF EXISTS ONLY auth.webauthn_challenges DROP CONSTRAINT IF EXISTS webauthn_challenges_user_id_fkey;
ALTER TABLE IF EXISTS ONLY auth.sso_domains DROP CONSTRAINT IF EXISTS sso_domains_sso_provider_id_fkey;
ALTER TABLE IF EXISTS ONLY auth.sessions DROP CONSTRAINT IF EXISTS sessions_user_id_fkey;
ALTER TABLE IF EXISTS ONLY auth.sessions DROP CONSTRAINT IF EXISTS sessions_oauth_client_id_fkey;
ALTER TABLE IF EXISTS ONLY auth.saml_relay_states DROP CONSTRAINT IF EXISTS saml_relay_states_sso_provider_id_fkey;
ALTER TABLE IF EXISTS ONLY auth.saml_relay_states DROP CONSTRAINT IF EXISTS saml_relay_states_flow_state_id_fkey;
ALTER TABLE IF EXISTS ONLY auth.saml_providers DROP CONSTRAINT IF EXISTS saml_providers_sso_provider_id_fkey;
ALTER TABLE IF EXISTS ONLY auth.refresh_tokens DROP CONSTRAINT IF EXISTS refresh_tokens_session_id_fkey;
ALTER TABLE IF EXISTS ONLY auth.one_time_tokens DROP CONSTRAINT IF EXISTS one_time_tokens_user_id_fkey;
ALTER TABLE IF EXISTS ONLY auth.oauth_consents DROP CONSTRAINT IF EXISTS oauth_consents_user_id_fkey;
ALTER TABLE IF EXISTS ONLY auth.oauth_consents DROP CONSTRAINT IF EXISTS oauth_consents_client_id_fkey;
ALTER TABLE IF EXISTS ONLY auth.oauth_authorizations DROP CONSTRAINT IF EXISTS oauth_authorizations_user_id_fkey;
ALTER TABLE IF EXISTS ONLY auth.oauth_authorizations DROP CONSTRAINT IF EXISTS oauth_authorizations_client_id_fkey;
ALTER TABLE IF EXISTS ONLY auth.mfa_factors DROP CONSTRAINT IF EXISTS mfa_factors_user_id_fkey;
ALTER TABLE IF EXISTS ONLY auth.mfa_challenges DROP CONSTRAINT IF EXISTS mfa_challenges_auth_factor_id_fkey;
ALTER TABLE IF EXISTS ONLY auth.mfa_amr_claims DROP CONSTRAINT IF EXISTS mfa_amr_claims_session_id_fkey;
ALTER TABLE IF EXISTS ONLY auth.identities DROP CONSTRAINT IF EXISTS identities_user_id_fkey;
ALTER TABLE IF EXISTS ONLY _realtime.extensions DROP CONSTRAINT IF EXISTS extensions_tenant_external_id_fkey;
DROP TRIGGER IF EXISTS update_objects_updated_at ON storage.objects;
DROP TRIGGER IF EXISTS protect_objects_delete ON storage.objects;
DROP TRIGGER IF EXISTS protect_buckets_delete ON storage.buckets;
DROP TRIGGER IF EXISTS enforce_bucket_name_length_trigger ON storage.buckets;
DROP TRIGGER IF EXISTS tr_check_filters ON realtime.subscription;
DROP TRIGGER IF EXISTS update_workflow_forms_updated_at ON public.workflow_forms;
DROP TRIGGER IF EXISTS update_user_preferences_updated_at ON public.user_preferences;
DROP TRIGGER IF EXISTS update_user_groups_updated_at ON public.user_groups;
DROP TRIGGER IF EXISTS update_system_settings_updated_at ON public.system_settings;
DROP TRIGGER IF EXISTS update_subscribers_updated_at ON public.subscribers;
DROP TRIGGER IF EXISTS update_storage_configs_updated_at ON public.storage_configs;
DROP TRIGGER IF EXISTS update_security_zones_updated_at ON public.security_zones;
DROP TRIGGER IF EXISTS update_pinned_dashboards_updated_at ON public.pinned_dashboards;
DROP TRIGGER IF EXISTS update_organizations_modtime ON public.organizations;
DROP TRIGGER IF EXISTS update_organization_settings_updated_at ON public.organization_settings;
DROP TRIGGER IF EXISTS update_notification_methods_updated_at ON public.notification_methods;
DROP TRIGGER IF EXISTS update_notification_labels_updated_at ON public.notification_labels;
DROP TRIGGER IF EXISTS update_legal_documents_updated_at ON public.legal_documents;
DROP TRIGGER IF EXISTS update_industries_updated_at ON public.industries;
DROP TRIGGER IF EXISTS update_frigate_reviews_updated_at ON public.frigate_reviews;
DROP TRIGGER IF EXISTS update_frigate_recordings_updated_at ON public.frigate_recordings;
DROP TRIGGER IF EXISTS update_frigate_previews_updated_at ON public.frigate_previews;
DROP TRIGGER IF EXISTS update_frigate_instances_updated_at ON public.frigate_instances;
DROP TRIGGER IF EXISTS update_frigate_exports_updated_at ON public.frigate_exports;
DROP TRIGGER IF EXISTS update_form_distribution_settings_updated_at ON public.form_distribution_settings;
DROP TRIGGER IF EXISTS update_form_assignments_updated_at ON public.form_assignments;
DROP TRIGGER IF EXISTS update_event_types_updated_at ON public.event_types;
DROP TRIGGER IF EXISTS update_chatbot_knowledge_base_updated_at ON public.chatbot_knowledge_base;
DROP TRIGGER IF EXISTS update_cameras_updated_at ON public.cameras;
DROP TRIGGER IF EXISTS update_camera_sources_updated_at ON public.camera_sources;
DROP TRIGGER IF EXISTS update_auto_sync_settings_updated_at ON public.auto_sync_settings;
DROP TRIGGER IF EXISTS update_aman_instances_updated_at ON public.aman_instances;
DROP TRIGGER IF EXISTS update_alert_templates_updated_at ON public.alert_templates;
DROP TRIGGER IF EXISTS trg_veedon_bump_cameras ON public.cameras;
DROP TRIGGER IF EXISTS trg_veedon_bump_assignments ON public.camera_event_assignments;
DROP TRIGGER IF EXISTS trg_touch_thread_after_message_insert ON public.chat_messages;
DROP TRIGGER IF EXISTS trg_restrict_events_update ON public.events;
DROP TRIGGER IF EXISTS trg_registry_updated ON public.frigate_model_registry;
DROP TRIGGER IF EXISTS trg_pinned_labels_updated_at ON public.pinned_labels;
DROP TRIGGER IF EXISTS trg_deployments_updated ON public.frigate_model_deployments;
DROP TRIGGER IF EXISTS trg_chat_threads_updated_at ON public.chat_threads;
DROP TRIGGER IF EXISTS touch_thread_on_message_insert ON public.chat_messages;
DROP TRIGGER IF EXISTS set_updated_at_chat_threads ON public.chat_threads;
DROP TRIGGER IF EXISTS set_updated_at ON public.frigate_zones;
DROP TRIGGER IF EXISTS set_updated_at ON public.frigate_license_plates;
DROP TRIGGER IF EXISTS set_updated_at ON public.frigate_faces;
DROP TRIGGER IF EXISTS set_updated_at ON public.frigate_alert_rules;
DROP TRIGGER IF EXISTS handle_screen_permissions_updated_at ON public.screen_permissions;
DROP TRIGGER IF EXISTS update_subscriber_activity_trigger ON auth.sessions;
DROP TRIGGER IF EXISTS on_auth_user_created ON auth.users;
DROP INDEX IF EXISTS supabase_functions.supabase_functions_hooks_request_id_idx;
DROP INDEX IF EXISTS supabase_functions.supabase_functions_hooks_h_table_id_h_name_idx;
DROP INDEX IF EXISTS storage.vector_indexes_name_bucket_id_idx;
DROP INDEX IF EXISTS storage.name_prefix_search;
DROP INDEX IF EXISTS storage.idx_objects_bucket_id_name_lower;
DROP INDEX IF EXISTS storage.idx_objects_bucket_id_name;
DROP INDEX IF EXISTS storage.idx_multipart_uploads_list;
DROP INDEX IF EXISTS storage.idx_iceberg_tables_namespace_id;
DROP INDEX IF EXISTS storage.idx_iceberg_tables_location;
DROP INDEX IF EXISTS storage.idx_iceberg_namespaces_bucket_id;
DROP INDEX IF EXISTS storage.buckets_analytics_unique_name_idx;
DROP INDEX IF EXISTS storage.bucketid_objname;
DROP INDEX IF EXISTS storage.bname;
DROP INDEX IF EXISTS realtime.subscription_subscription_id_entity_filters_action_filter_selec;
DROP INDEX IF EXISTS realtime.messages_inserted_at_topic_index;
DROP INDEX IF EXISTS realtime.ix_realtime_subscription_entity;
DROP INDEX IF EXISTS public.idx_system_settings_key;
DROP INDEX IF EXISTS public.idx_sync_log_started;
DROP INDEX IF EXISTS public.idx_sync_log_instance;
DROP INDEX IF EXISTS public.idx_security_zones_active;
DROP INDEX IF EXISTS public.idx_pinned_labels_user_id;
DROP INDEX IF EXISTS public.idx_pinned_dashboards_user_id;
DROP INDEX IF EXISTS public.idx_org_settings_org_key;
DROP INDEX IF EXISTS public.idx_model_registry_status;
DROP INDEX IF EXISTS public.idx_model_registry_category;
DROP INDEX IF EXISTS public.idx_model_deployments_status;
DROP INDEX IF EXISTS public.idx_model_deployments_model;
DROP INDEX IF EXISTS public.idx_model_deployments_instance;
DROP INDEX IF EXISTS public.idx_health_alerts_time;
DROP INDEX IF EXISTS public.idx_health_alerts_student;
DROP INDEX IF EXISTS public.idx_frigate_zones_camera_id;
DROP INDEX IF EXISTS public.idx_frigate_triggers_instance;
DROP INDEX IF EXISTS public.idx_frigate_timeline_time;
DROP INDEX IF EXISTS public.idx_frigate_timeline_camera_id;
DROP INDEX IF EXISTS public.idx_frigate_sync_logs_started;
DROP INDEX IF EXISTS public.idx_frigate_sync_logs_instance;
DROP INDEX IF EXISTS public.idx_frigate_stats_history_recorded;
DROP INDEX IF EXISTS public.idx_frigate_stats_history_instance;
DROP INDEX IF EXISTS public.idx_frigate_reviews_severity;
DROP INDEX IF EXISTS public.idx_frigate_reviews_reviewed_new;
DROP INDEX IF EXISTS public.idx_frigate_reviews_reviewed;
DROP INDEX IF EXISTS public.idx_frigate_reviews_instance_camera;
DROP INDEX IF EXISTS public.idx_frigate_recordings_time;
DROP INDEX IF EXISTS public.idx_frigate_recordings_instance_camera;
DROP INDEX IF EXISTS public.idx_frigate_previews_time;
DROP INDEX IF EXISTS public.idx_frigate_previews_instance_camera;
DROP INDEX IF EXISTS public.idx_frigate_license_plates_watch;
DROP INDEX IF EXISTS public.idx_frigate_license_plates_plate_number;
DROP INDEX IF EXISTS public.idx_frigate_license_plates_instance;
DROP INDEX IF EXISTS public.idx_frigate_license_plates_camera_id;
DROP INDEX IF EXISTS public.idx_frigate_faces_label;
DROP INDEX IF EXISTS public.idx_frigate_faces_camera_id;
DROP INDEX IF EXISTS public.idx_frigate_exports_status;
DROP INDEX IF EXISTS public.idx_frigate_exports_instance_camera;
DROP INDEX IF EXISTS public.idx_frigate_deployed_models_status;
DROP INDEX IF EXISTS public.idx_frigate_deployed_models_instance;
DROP INDEX IF EXISTS public.idx_frigate_deployed_models_category;
DROP INDEX IF EXISTS public.idx_events_license_plate;
DROP INDEX IF EXISTS public.idx_events_frigate_id;
DROP INDEX IF EXISTS public.idx_events_face_id;
DROP INDEX IF EXISTS public.idx_events_detected_at;
DROP INDEX IF EXISTS public.idx_events_camera_id;
DROP INDEX IF EXISTS public.idx_event_types_feature_key;
DROP INDEX IF EXISTS public.idx_chatbot_knowledge_language_type;
DROP INDEX IF EXISTS public.idx_chatbot_knowledge_active;
DROP INDEX IF EXISTS public.idx_chat_threads_org;
DROP INDEX IF EXISTS public.idx_chat_participants_user;
DROP INDEX IF EXISTS public.idx_chat_participants_thread;
DROP INDEX IF EXISTS public.idx_chat_messages_thread_created;
DROP INDEX IF EXISTS public.idx_cameras_branch_id;
DROP INDEX IF EXISTS public.idx_aman_instances_org;
DROP INDEX IF EXISTS public.idx_aman_instances_branch;
DROP INDEX IF EXISTS auth.webauthn_credentials_user_id_idx;
DROP INDEX IF EXISTS auth.webauthn_credentials_credential_id_key;
DROP INDEX IF EXISTS auth.webauthn_challenges_user_id_idx;
DROP INDEX IF EXISTS auth.webauthn_challenges_expires_at_idx;
DROP INDEX IF EXISTS auth.users_is_anonymous_idx;
DROP INDEX IF EXISTS auth.users_instance_id_idx;
DROP INDEX IF EXISTS auth.users_instance_id_email_idx;
DROP INDEX IF EXISTS auth.users_email_partial_key;
DROP INDEX IF EXISTS auth.user_id_created_at_idx;
DROP INDEX IF EXISTS auth.unique_phone_factor_per_user;
DROP INDEX IF EXISTS auth.sso_providers_resource_id_pattern_idx;
DROP INDEX IF EXISTS auth.sso_providers_resource_id_idx;
DROP INDEX IF EXISTS auth.sso_domains_sso_provider_id_idx;
DROP INDEX IF EXISTS auth.sso_domains_domain_idx;
DROP INDEX IF EXISTS auth.sessions_user_id_idx;
DROP INDEX IF EXISTS auth.sessions_oauth_client_id_idx;
DROP INDEX IF EXISTS auth.sessions_not_after_idx;
DROP INDEX IF EXISTS auth.saml_relay_states_sso_provider_id_idx;
DROP INDEX IF EXISTS auth.saml_relay_states_for_email_idx;
DROP INDEX IF EXISTS auth.saml_relay_states_created_at_idx;
DROP INDEX IF EXISTS auth.saml_providers_sso_provider_id_idx;
DROP INDEX IF EXISTS auth.refresh_tokens_updated_at_idx;
DROP INDEX IF EXISTS auth.refresh_tokens_session_id_revoked_idx;
DROP INDEX IF EXISTS auth.refresh_tokens_parent_idx;
DROP INDEX IF EXISTS auth.refresh_tokens_instance_id_user_id_idx;
DROP INDEX IF EXISTS auth.refresh_tokens_instance_id_idx;
DROP INDEX IF EXISTS auth.recovery_token_idx;
DROP INDEX IF EXISTS auth.reauthentication_token_idx;
DROP INDEX IF EXISTS auth.one_time_tokens_user_id_token_type_key;
DROP INDEX IF EXISTS auth.one_time_tokens_token_hash_hash_idx;
DROP INDEX IF EXISTS auth.one_time_tokens_relates_to_hash_idx;
DROP INDEX IF EXISTS auth.oauth_consents_user_order_idx;
DROP INDEX IF EXISTS auth.oauth_consents_active_user_client_idx;
DROP INDEX IF EXISTS auth.oauth_consents_active_client_idx;
DROP INDEX IF EXISTS auth.oauth_clients_deleted_at_idx;
DROP INDEX IF EXISTS auth.oauth_auth_pending_exp_idx;
DROP INDEX IF EXISTS auth.mfa_factors_user_id_idx;
DROP INDEX IF EXISTS auth.mfa_factors_user_friendly_name_unique;
DROP INDEX IF EXISTS auth.mfa_challenge_created_at_idx;
DROP INDEX IF EXISTS auth.idx_user_id_auth_method;
DROP INDEX IF EXISTS auth.idx_oauth_client_states_created_at;
DROP INDEX IF EXISTS auth.idx_auth_code;
DROP INDEX IF EXISTS auth.identities_user_id_idx;
DROP INDEX IF EXISTS auth.identities_email_idx;
DROP INDEX IF EXISTS auth.flow_state_created_at_idx;
DROP INDEX IF EXISTS auth.factor_id_created_at_idx;
DROP INDEX IF EXISTS auth.email_change_token_new_idx;
DROP INDEX IF EXISTS auth.email_change_token_current_idx;
DROP INDEX IF EXISTS auth.custom_oauth_providers_provider_type_idx;
DROP INDEX IF EXISTS auth.custom_oauth_providers_identifier_idx;
DROP INDEX IF EXISTS auth.custom_oauth_providers_enabled_idx;
DROP INDEX IF EXISTS auth.custom_oauth_providers_created_at_idx;
DROP INDEX IF EXISTS auth.confirmation_token_idx;
DROP INDEX IF EXISTS auth.audit_logs_instance_id_idx;
DROP INDEX IF EXISTS _realtime.tenants_external_id_index;
DROP INDEX IF EXISTS _realtime.feature_flags_name_index;
DROP INDEX IF EXISTS _realtime.extensions_tenant_external_id_type_index;
DROP INDEX IF EXISTS _realtime.extensions_tenant_external_id_index;
ALTER TABLE IF EXISTS ONLY supabase_migrations.schema_migrations DROP CONSTRAINT IF EXISTS schema_migrations_pkey;
ALTER TABLE IF EXISTS ONLY supabase_functions.migrations DROP CONSTRAINT IF EXISTS migrations_pkey;
ALTER TABLE IF EXISTS ONLY supabase_functions.hooks DROP CONSTRAINT IF EXISTS hooks_pkey;
ALTER TABLE IF EXISTS ONLY storage.vector_indexes DROP CONSTRAINT IF EXISTS vector_indexes_pkey;
ALTER TABLE IF EXISTS ONLY storage.s3_multipart_uploads DROP CONSTRAINT IF EXISTS s3_multipart_uploads_pkey;
ALTER TABLE IF EXISTS ONLY storage.s3_multipart_uploads_parts DROP CONSTRAINT IF EXISTS s3_multipart_uploads_parts_pkey;
ALTER TABLE IF EXISTS ONLY storage.objects DROP CONSTRAINT IF EXISTS objects_pkey;
ALTER TABLE IF EXISTS ONLY storage.migrations DROP CONSTRAINT IF EXISTS migrations_pkey;
ALTER TABLE IF EXISTS ONLY storage.migrations DROP CONSTRAINT IF EXISTS migrations_name_key;
ALTER TABLE IF EXISTS ONLY storage.iceberg_tables DROP CONSTRAINT IF EXISTS iceberg_tables_pkey;
ALTER TABLE IF EXISTS ONLY storage.iceberg_namespaces DROP CONSTRAINT IF EXISTS iceberg_namespaces_pkey;
ALTER TABLE IF EXISTS ONLY storage.buckets_vectors DROP CONSTRAINT IF EXISTS buckets_vectors_pkey;
ALTER TABLE IF EXISTS ONLY storage.buckets DROP CONSTRAINT IF EXISTS buckets_pkey;
ALTER TABLE IF EXISTS ONLY storage.buckets_analytics DROP CONSTRAINT IF EXISTS buckets_analytics_pkey;
ALTER TABLE IF EXISTS ONLY realtime.schema_migrations DROP CONSTRAINT IF EXISTS schema_migrations_pkey;
ALTER TABLE IF EXISTS ONLY realtime.subscription DROP CONSTRAINT IF EXISTS pk_subscription;
ALTER TABLE IF EXISTS realtime.messages DROP CONSTRAINT IF EXISTS messages_payload_exclusive;
ALTER TABLE IF EXISTS ONLY realtime.messages_2026_07_08 DROP CONSTRAINT IF EXISTS messages_2026_07_08_pkey;
ALTER TABLE IF EXISTS ONLY realtime.messages_2026_07_07 DROP CONSTRAINT IF EXISTS messages_2026_07_07_pkey;
ALTER TABLE IF EXISTS ONLY realtime.messages_2026_07_06 DROP CONSTRAINT IF EXISTS messages_2026_07_06_pkey;
ALTER TABLE IF EXISTS ONLY realtime.messages_2026_07_05 DROP CONSTRAINT IF EXISTS messages_2026_07_05_pkey;
ALTER TABLE IF EXISTS ONLY realtime.messages_2026_07_04 DROP CONSTRAINT IF EXISTS messages_2026_07_04_pkey;
ALTER TABLE IF EXISTS ONLY realtime.messages_2026_07_03 DROP CONSTRAINT IF EXISTS messages_2026_07_03_pkey;
ALTER TABLE IF EXISTS ONLY realtime.messages_2026_07_02 DROP CONSTRAINT IF EXISTS messages_2026_07_02_pkey;
ALTER TABLE IF EXISTS ONLY realtime.messages DROP CONSTRAINT IF EXISTS messages_pkey;
ALTER TABLE IF EXISTS ONLY public.workflow_forms DROP CONSTRAINT IF EXISTS workflow_forms_pkey;
ALTER TABLE IF EXISTS ONLY public.user_roles DROP CONSTRAINT IF EXISTS user_roles_user_id_organization_id_key;
ALTER TABLE IF EXISTS ONLY public.user_roles DROP CONSTRAINT IF EXISTS user_roles_pkey;
ALTER TABLE IF EXISTS ONLY public.user_preferences DROP CONSTRAINT IF EXISTS user_preferences_user_id_key;
ALTER TABLE IF EXISTS ONLY public.user_preferences DROP CONSTRAINT IF EXISTS user_preferences_pkey;
ALTER TABLE IF EXISTS ONLY public.user_groups DROP CONSTRAINT IF EXISTS user_groups_pkey;
ALTER TABLE IF EXISTS ONLY public.user_group_members DROP CONSTRAINT IF EXISTS user_group_members_pkey;
ALTER TABLE IF EXISTS ONLY public.user_group_members DROP CONSTRAINT IF EXISTS user_group_members_group_id_user_role_id_key;
ALTER TABLE IF EXISTS ONLY public.user_branch_access DROP CONSTRAINT IF EXISTS user_branch_access_user_id_branch_id_key;
ALTER TABLE IF EXISTS ONLY public.user_branch_access DROP CONSTRAINT IF EXISTS user_branch_access_pkey;
ALTER TABLE IF EXISTS ONLY public.system_settings DROP CONSTRAINT IF EXISTS system_settings_setting_key_key;
ALTER TABLE IF EXISTS ONLY public.system_settings DROP CONSTRAINT IF EXISTS system_settings_pkey;
ALTER TABLE IF EXISTS ONLY public.subscribers DROP CONSTRAINT IF EXISTS subscribers_pkey;
ALTER TABLE IF EXISTS ONLY public.subscribers DROP CONSTRAINT IF EXISTS subscribers_email_key;
ALTER TABLE IF EXISTS ONLY public.students DROP CONSTRAINT IF EXISTS students_wearable_id_key;
ALTER TABLE IF EXISTS ONLY public.students DROP CONSTRAINT IF EXISTS students_pkey;
ALTER TABLE IF EXISTS ONLY public.storage_configs DROP CONSTRAINT IF EXISTS storage_configs_pkey;
ALTER TABLE IF EXISTS ONLY public.security_zones DROP CONSTRAINT IF EXISTS security_zones_pkey;
ALTER TABLE IF EXISTS ONLY public.screen_permissions DROP CONSTRAINT IF EXISTS screen_permissions_screen_key_key;
ALTER TABLE IF EXISTS ONLY public.screen_permissions DROP CONSTRAINT IF EXISTS screen_permissions_pkey;
ALTER TABLE IF EXISTS ONLY public.pinned_labels DROP CONSTRAINT IF EXISTS pinned_labels_pkey;
ALTER TABLE IF EXISTS ONLY public.pinned_dashboards DROP CONSTRAINT IF EXISTS pinned_dashboards_pkey;
ALTER TABLE IF EXISTS ONLY public.organizations DROP CONSTRAINT IF EXISTS organizations_pkey;
ALTER TABLE IF EXISTS ONLY public.organization_settings DROP CONSTRAINT IF EXISTS organization_settings_pkey;
ALTER TABLE IF EXISTS ONLY public.organization_settings DROP CONSTRAINT IF EXISTS organization_settings_organization_id_setting_key_key;
ALTER TABLE IF EXISTS ONLY public.notification_methods DROP CONSTRAINT IF EXISTS notification_methods_pkey;
ALTER TABLE IF EXISTS ONLY public.notification_labels DROP CONSTRAINT IF EXISTS notification_labels_pkey;
ALTER TABLE IF EXISTS ONLY public.network_scan_results DROP CONSTRAINT IF EXISTS network_scan_results_pkey;
ALTER TABLE IF EXISTS ONLY public.legal_documents DROP CONSTRAINT IF EXISTS legal_documents_pkey;
ALTER TABLE IF EXISTS ONLY public.legal_documents DROP CONSTRAINT IF EXISTS legal_documents_document_type_key;
ALTER TABLE IF EXISTS ONLY public.industries DROP CONSTRAINT IF EXISTS industries_pkey;
ALTER TABLE IF EXISTS ONLY public.health_alerts DROP CONSTRAINT IF EXISTS health_alerts_pkey;
ALTER TABLE IF EXISTS ONLY public.frigate_zones DROP CONSTRAINT IF EXISTS frigate_zones_pkey;
ALTER TABLE IF EXISTS ONLY public.frigate_triggers DROP CONSTRAINT IF EXISTS frigate_triggers_pkey;
ALTER TABLE IF EXISTS ONLY public.frigate_triggers DROP CONSTRAINT IF EXISTS frigate_triggers_frigate_instance_id_camera_name_key;
ALTER TABLE IF EXISTS ONLY public.frigate_timeline DROP CONSTRAINT IF EXISTS frigate_timeline_pkey;
ALTER TABLE IF EXISTS ONLY public.frigate_sync_logs DROP CONSTRAINT IF EXISTS frigate_sync_logs_pkey;
ALTER TABLE IF EXISTS ONLY public.frigate_stats_history DROP CONSTRAINT IF EXISTS frigate_stats_history_pkey;
ALTER TABLE IF EXISTS ONLY public.frigate_reviews DROP CONSTRAINT IF EXISTS frigate_reviews_review_id_frigate_instance_id_key;
ALTER TABLE IF EXISTS ONLY public.frigate_reviews DROP CONSTRAINT IF EXISTS frigate_reviews_pkey;
ALTER TABLE IF EXISTS ONLY public.frigate_recordings DROP CONSTRAINT IF EXISTS frigate_recordings_recording_id_frigate_instance_id_key;
ALTER TABLE IF EXISTS ONLY public.frigate_recordings DROP CONSTRAINT IF EXISTS frigate_recordings_pkey;
ALTER TABLE IF EXISTS ONLY public.frigate_previews DROP CONSTRAINT IF EXISTS frigate_previews_preview_id_frigate_instance_id_key;
ALTER TABLE IF EXISTS ONLY public.frigate_previews DROP CONSTRAINT IF EXISTS frigate_previews_pkey;
ALTER TABLE IF EXISTS ONLY public.frigate_model_sync_log DROP CONSTRAINT IF EXISTS frigate_model_sync_log_pkey;
ALTER TABLE IF EXISTS ONLY public.frigate_model_registry DROP CONSTRAINT IF EXISTS frigate_model_registry_pkey;
ALTER TABLE IF EXISTS ONLY public.frigate_model_registry DROP CONSTRAINT IF EXISTS frigate_model_registry_model_id_key;
ALTER TABLE IF EXISTS ONLY public.frigate_model_deployments DROP CONSTRAINT IF EXISTS frigate_model_deployments_pkey;
ALTER TABLE IF EXISTS ONLY public.frigate_model_deployments DROP CONSTRAINT IF EXISTS frigate_model_deployments_model_id_frigate_instance_id_key;
ALTER TABLE IF EXISTS ONLY public.frigate_license_plates DROP CONSTRAINT IF EXISTS frigate_license_plates_pkey;
ALTER TABLE IF EXISTS ONLY public.frigate_instances DROP CONSTRAINT IF EXISTS frigate_instances_pkey;
ALTER TABLE IF EXISTS ONLY public.frigate_instances DROP CONSTRAINT IF EXISTS frigate_instances_branch_id_name_key;
ALTER TABLE IF EXISTS ONLY public.frigate_faces DROP CONSTRAINT IF EXISTS frigate_faces_pkey;
ALTER TABLE IF EXISTS ONLY public.frigate_exports DROP CONSTRAINT IF EXISTS frigate_exports_pkey;
ALTER TABLE IF EXISTS ONLY public.frigate_exports DROP CONSTRAINT IF EXISTS frigate_exports_export_id_frigate_instance_id_key;
ALTER TABLE IF EXISTS ONLY public.frigate_deployed_models DROP CONSTRAINT IF EXISTS frigate_deployed_models_pkey;
ALTER TABLE IF EXISTS ONLY public.frigate_deployed_models DROP CONSTRAINT IF EXISTS frigate_deployed_models_frigate_instance_id_model_id_key;
ALTER TABLE IF EXISTS ONLY public.frigate_alert_rules DROP CONSTRAINT IF EXISTS frigate_alert_rules_pkey;
ALTER TABLE IF EXISTS ONLY public.form_submissions DROP CONSTRAINT IF EXISTS form_submissions_pkey;
ALTER TABLE IF EXISTS ONLY public.form_distribution_settings DROP CONSTRAINT IF EXISTS form_distribution_settings_pkey;
ALTER TABLE IF EXISTS ONLY public.form_assignments DROP CONSTRAINT IF EXISTS form_assignments_pkey;
ALTER TABLE IF EXISTS ONLY public.events DROP CONSTRAINT IF EXISTS events_pkey;
ALTER TABLE IF EXISTS ONLY public.event_types DROP CONSTRAINT IF EXISTS event_types_pkey;
ALTER TABLE IF EXISTS ONLY public.detection_rules DROP CONSTRAINT IF EXISTS detection_rules_pkey;
ALTER TABLE IF EXISTS ONLY public.chatbot_knowledge_base DROP CONSTRAINT IF EXISTS chatbot_knowledge_base_pkey;
ALTER TABLE IF EXISTS ONLY public.chatbot_knowledge_base DROP CONSTRAINT IF EXISTS chatbot_knowledge_base_language_content_type_key;
ALTER TABLE IF EXISTS ONLY public.chat_threads DROP CONSTRAINT IF EXISTS chat_threads_pkey;
ALTER TABLE IF EXISTS ONLY public.chat_thread_participants DROP CONSTRAINT IF EXISTS chat_thread_participants_thread_id_user_id_key;
ALTER TABLE IF EXISTS ONLY public.chat_thread_participants DROP CONSTRAINT IF EXISTS chat_thread_participants_pkey;
ALTER TABLE IF EXISTS ONLY public.chat_messages DROP CONSTRAINT IF EXISTS chat_messages_pkey;
ALTER TABLE IF EXISTS ONLY public.cameras DROP CONSTRAINT IF EXISTS cameras_pkey;
ALTER TABLE IF EXISTS ONLY public.camera_sources DROP CONSTRAINT IF EXISTS camera_sources_pkey;
ALTER TABLE IF EXISTS ONLY public.camera_event_assignments DROP CONSTRAINT IF EXISTS camera_event_assignments_pkey;
ALTER TABLE IF EXISTS ONLY public.camera_event_assignments DROP CONSTRAINT IF EXISTS camera_event_assignments_camera_id_event_type_id_key;
ALTER TABLE IF EXISTS ONLY public.camera_alert_assignments DROP CONSTRAINT IF EXISTS camera_alert_assignments_pkey;
ALTER TABLE IF EXISTS ONLY public.camera_alert_assignments DROP CONSTRAINT IF EXISTS camera_alert_assignments_camera_id_alert_template_id_key;
ALTER TABLE IF EXISTS ONLY public.branches DROP CONSTRAINT IF EXISTS branches_pkey;
ALTER TABLE IF EXISTS ONLY public.branches DROP CONSTRAINT IF EXISTS branches_device_token_key;
ALTER TABLE IF EXISTS ONLY public.branch_roles DROP CONSTRAINT IF EXISTS branch_roles_pkey;
ALTER TABLE IF EXISTS ONLY public.auto_sync_settings DROP CONSTRAINT IF EXISTS auto_sync_settings_pkey;
ALTER TABLE IF EXISTS ONLY public.aman_instances DROP CONSTRAINT IF EXISTS aman_instances_pkey;
ALTER TABLE IF EXISTS ONLY public.alert_templates DROP CONSTRAINT IF EXISTS alert_templates_pkey;
ALTER TABLE IF EXISTS ONLY public.alert_template_industries DROP CONSTRAINT IF EXISTS alert_template_industries_pkey;
ALTER TABLE IF EXISTS ONLY public.alert_template_industries DROP CONSTRAINT IF EXISTS alert_template_industries_alert_template_id_industry_id_key;
ALTER TABLE IF EXISTS ONLY public.alert_template_events DROP CONSTRAINT IF EXISTS alert_template_events_pkey;
ALTER TABLE IF EXISTS ONLY public.alert_template_events DROP CONSTRAINT IF EXISTS alert_template_events_alert_template_id_event_type_id_key;
ALTER TABLE IF EXISTS ONLY public.ai_models DROP CONSTRAINT IF EXISTS ai_models_pkey;
ALTER TABLE IF EXISTS ONLY public.ai_analysis_logs DROP CONSTRAINT IF EXISTS ai_analysis_logs_pkey;
ALTER TABLE IF EXISTS ONLY auth.webauthn_credentials DROP CONSTRAINT IF EXISTS webauthn_credentials_pkey;
ALTER TABLE IF EXISTS ONLY auth.webauthn_challenges DROP CONSTRAINT IF EXISTS webauthn_challenges_pkey;
ALTER TABLE IF EXISTS ONLY auth.users DROP CONSTRAINT IF EXISTS users_pkey;
ALTER TABLE IF EXISTS ONLY auth.users DROP CONSTRAINT IF EXISTS users_phone_key;
ALTER TABLE IF EXISTS ONLY auth.sso_providers DROP CONSTRAINT IF EXISTS sso_providers_pkey;
ALTER TABLE IF EXISTS ONLY auth.sso_domains DROP CONSTRAINT IF EXISTS sso_domains_pkey;
ALTER TABLE IF EXISTS ONLY auth.sessions DROP CONSTRAINT IF EXISTS sessions_pkey;
ALTER TABLE IF EXISTS ONLY auth.schema_migrations DROP CONSTRAINT IF EXISTS schema_migrations_pkey;
ALTER TABLE IF EXISTS ONLY auth.saml_relay_states DROP CONSTRAINT IF EXISTS saml_relay_states_pkey;
ALTER TABLE IF EXISTS ONLY auth.saml_providers DROP CONSTRAINT IF EXISTS saml_providers_pkey;
ALTER TABLE IF EXISTS ONLY auth.saml_providers DROP CONSTRAINT IF EXISTS saml_providers_entity_id_key;
ALTER TABLE IF EXISTS ONLY auth.refresh_tokens DROP CONSTRAINT IF EXISTS refresh_tokens_token_unique;
ALTER TABLE IF EXISTS ONLY auth.refresh_tokens DROP CONSTRAINT IF EXISTS refresh_tokens_pkey;
ALTER TABLE IF EXISTS ONLY auth.one_time_tokens DROP CONSTRAINT IF EXISTS one_time_tokens_pkey;
ALTER TABLE IF EXISTS ONLY auth.oauth_consents DROP CONSTRAINT IF EXISTS oauth_consents_user_client_unique;
ALTER TABLE IF EXISTS ONLY auth.oauth_consents DROP CONSTRAINT IF EXISTS oauth_consents_pkey;
ALTER TABLE IF EXISTS ONLY auth.oauth_clients DROP CONSTRAINT IF EXISTS oauth_clients_pkey;
ALTER TABLE IF EXISTS ONLY auth.oauth_client_states DROP CONSTRAINT IF EXISTS oauth_client_states_pkey;
ALTER TABLE IF EXISTS ONLY auth.oauth_authorizations DROP CONSTRAINT IF EXISTS oauth_authorizations_pkey;
ALTER TABLE IF EXISTS ONLY auth.oauth_authorizations DROP CONSTRAINT IF EXISTS oauth_authorizations_authorization_id_key;
ALTER TABLE IF EXISTS ONLY auth.oauth_authorizations DROP CONSTRAINT IF EXISTS oauth_authorizations_authorization_code_key;
ALTER TABLE IF EXISTS ONLY auth.mfa_factors DROP CONSTRAINT IF EXISTS mfa_factors_pkey;
ALTER TABLE IF EXISTS ONLY auth.mfa_factors DROP CONSTRAINT IF EXISTS mfa_factors_last_challenged_at_key;
ALTER TABLE IF EXISTS ONLY auth.mfa_challenges DROP CONSTRAINT IF EXISTS mfa_challenges_pkey;
ALTER TABLE IF EXISTS ONLY auth.mfa_amr_claims DROP CONSTRAINT IF EXISTS mfa_amr_claims_session_id_authentication_method_pkey;
ALTER TABLE IF EXISTS ONLY auth.instances DROP CONSTRAINT IF EXISTS instances_pkey;
ALTER TABLE IF EXISTS ONLY auth.identities DROP CONSTRAINT IF EXISTS identities_provider_id_provider_unique;
ALTER TABLE IF EXISTS ONLY auth.identities DROP CONSTRAINT IF EXISTS identities_pkey;
ALTER TABLE IF EXISTS ONLY auth.flow_state DROP CONSTRAINT IF EXISTS flow_state_pkey;
ALTER TABLE IF EXISTS ONLY auth.custom_oauth_providers DROP CONSTRAINT IF EXISTS custom_oauth_providers_pkey;
ALTER TABLE IF EXISTS ONLY auth.custom_oauth_providers DROP CONSTRAINT IF EXISTS custom_oauth_providers_identifier_key;
ALTER TABLE IF EXISTS ONLY auth.audit_log_entries DROP CONSTRAINT IF EXISTS audit_log_entries_pkey;
ALTER TABLE IF EXISTS ONLY auth.mfa_amr_claims DROP CONSTRAINT IF EXISTS amr_id_pk;
ALTER TABLE IF EXISTS ONLY _realtime.tenants DROP CONSTRAINT IF EXISTS tenants_pkey;
ALTER TABLE IF EXISTS ONLY _realtime.schema_migrations DROP CONSTRAINT IF EXISTS schema_migrations_pkey;
ALTER TABLE IF EXISTS ONLY _realtime.feature_flags DROP CONSTRAINT IF EXISTS feature_flags_pkey;
ALTER TABLE IF EXISTS ONLY _realtime.extensions DROP CONSTRAINT IF EXISTS extensions_pkey;
ALTER TABLE IF EXISTS supabase_functions.hooks ALTER COLUMN id DROP DEFAULT;
ALTER TABLE IF EXISTS auth.refresh_tokens ALTER COLUMN id DROP DEFAULT;
DROP TABLE IF EXISTS supabase_migrations.schema_migrations;
DROP TABLE IF EXISTS supabase_functions.migrations;
DROP SEQUENCE IF EXISTS supabase_functions.hooks_id_seq;
DROP TABLE IF EXISTS supabase_functions.hooks;
DROP TABLE IF EXISTS storage.vector_indexes;
DROP TABLE IF EXISTS storage.s3_multipart_uploads_parts;
DROP TABLE IF EXISTS storage.s3_multipart_uploads;
DROP TABLE IF EXISTS storage.objects;
DROP TABLE IF EXISTS storage.migrations;
DROP TABLE IF EXISTS storage.iceberg_tables;
DROP TABLE IF EXISTS storage.iceberg_namespaces;
DROP TABLE IF EXISTS storage.buckets_vectors;
DROP TABLE IF EXISTS storage.buckets_analytics;
DROP TABLE IF EXISTS storage.buckets;
DROP TABLE IF EXISTS realtime.subscription;
DROP TABLE IF EXISTS realtime.schema_migrations;
DROP TABLE IF EXISTS realtime.messages_2026_07_08;
DROP TABLE IF EXISTS realtime.messages_2026_07_07;
DROP TABLE IF EXISTS realtime.messages_2026_07_06;
DROP TABLE IF EXISTS realtime.messages_2026_07_05;
DROP TABLE IF EXISTS realtime.messages_2026_07_04;
DROP TABLE IF EXISTS realtime.messages_2026_07_03;
DROP TABLE IF EXISTS realtime.messages_2026_07_02;
DROP TABLE IF EXISTS realtime.messages;
DROP TABLE IF EXISTS public.workflow_forms;
DROP TABLE IF EXISTS public.user_roles;
DROP TABLE IF EXISTS public.user_preferences;
DROP TABLE IF EXISTS public.user_groups;
DROP TABLE IF EXISTS public.user_group_members;
DROP TABLE IF EXISTS public.user_branch_access;
DROP TABLE IF EXISTS public.system_settings;
DROP TABLE IF EXISTS public.subscribers;
DROP TABLE IF EXISTS public.students;
DROP TABLE IF EXISTS public.storage_configs;
DROP TABLE IF EXISTS public.security_zones;
DROP TABLE IF EXISTS public.screen_permissions;
DROP TABLE IF EXISTS public.pinned_labels;
DROP TABLE IF EXISTS public.pinned_dashboards;
DROP TABLE IF EXISTS public.organizations;
DROP TABLE IF EXISTS public.organization_settings;
DROP TABLE IF EXISTS public.notification_methods;
DROP TABLE IF EXISTS public.notification_labels;
DROP TABLE IF EXISTS public.network_scan_results;
DROP TABLE IF EXISTS public.legal_documents;
DROP TABLE IF EXISTS public.industries;
DROP TABLE IF EXISTS public.health_alerts;
DROP TABLE IF EXISTS public.frigate_zones;
DROP TABLE IF EXISTS public.frigate_triggers;
DROP TABLE IF EXISTS public.frigate_timeline;
DROP TABLE IF EXISTS public.frigate_sync_logs;
DROP TABLE IF EXISTS public.frigate_stats_history;
DROP TABLE IF EXISTS public.frigate_reviews;
DROP TABLE IF EXISTS public.frigate_recordings;
DROP TABLE IF EXISTS public.frigate_previews;
DROP TABLE IF EXISTS public.frigate_model_sync_log;
DROP TABLE IF EXISTS public.frigate_model_registry;
DROP TABLE IF EXISTS public.frigate_model_deployments;
DROP TABLE IF EXISTS public.frigate_license_plates;
DROP TABLE IF EXISTS public.frigate_instances;
DROP TABLE IF EXISTS public.frigate_faces;
DROP TABLE IF EXISTS public.frigate_exports;
DROP TABLE IF EXISTS public.frigate_deployed_models;
DROP TABLE IF EXISTS public.frigate_alert_rules;
DROP TABLE IF EXISTS public.form_submissions;
DROP TABLE IF EXISTS public.form_distribution_settings;
DROP TABLE IF EXISTS public.form_assignments;
DROP TABLE IF EXISTS public.events;
DROP TABLE IF EXISTS public.event_types;
DROP TABLE IF EXISTS public.detection_rules;
DROP TABLE IF EXISTS public.chatbot_knowledge_base;
DROP TABLE IF EXISTS public.chat_threads;
DROP TABLE IF EXISTS public.chat_thread_participants;
DROP TABLE IF EXISTS public.chat_messages;
DROP TABLE IF EXISTS public.cameras;
DROP TABLE IF EXISTS public.camera_sources;
DROP TABLE IF EXISTS public.camera_event_assignments;
DROP TABLE IF EXISTS public.camera_alert_assignments;
DROP TABLE IF EXISTS public.branches;
DROP TABLE IF EXISTS public.branch_roles;
DROP TABLE IF EXISTS public.auto_sync_settings;
DROP TABLE IF EXISTS public.aman_instances;
DROP TABLE IF EXISTS public.alert_templates;
DROP TABLE IF EXISTS public.alert_template_industries;
DROP TABLE IF EXISTS public.alert_template_events;
DROP TABLE IF EXISTS public.ai_models;
DROP TABLE IF EXISTS public.ai_analysis_logs;
DROP TABLE IF EXISTS auth.webauthn_credentials;
DROP TABLE IF EXISTS auth.webauthn_challenges;
DROP TABLE IF EXISTS auth.users;
DROP TABLE IF EXISTS auth.sso_providers;
DROP TABLE IF EXISTS auth.sso_domains;
DROP TABLE IF EXISTS auth.sessions;
DROP TABLE IF EXISTS auth.schema_migrations;
DROP TABLE IF EXISTS auth.saml_relay_states;
DROP TABLE IF EXISTS auth.saml_providers;
DROP SEQUENCE IF EXISTS auth.refresh_tokens_id_seq;
DROP TABLE IF EXISTS auth.refresh_tokens;
DROP TABLE IF EXISTS auth.one_time_tokens;
DROP TABLE IF EXISTS auth.oauth_consents;
DROP TABLE IF EXISTS auth.oauth_clients;
DROP TABLE IF EXISTS auth.oauth_client_states;
DROP TABLE IF EXISTS auth.oauth_authorizations;
DROP TABLE IF EXISTS auth.mfa_factors;
DROP TABLE IF EXISTS auth.mfa_challenges;
DROP TABLE IF EXISTS auth.mfa_amr_claims;
DROP TABLE IF EXISTS auth.instances;
DROP TABLE IF EXISTS auth.identities;
DROP TABLE IF EXISTS auth.flow_state;
DROP TABLE IF EXISTS auth.custom_oauth_providers;
DROP TABLE IF EXISTS auth.audit_log_entries;
DROP TABLE IF EXISTS _realtime.tenants;
DROP TABLE IF EXISTS _realtime.schema_migrations;
DROP TABLE IF EXISTS _realtime.feature_flags;
DROP TABLE IF EXISTS _realtime.extensions;
DROP FUNCTION IF EXISTS supabase_functions.http_request();
DROP FUNCTION IF EXISTS storage.update_updated_at_column();
DROP FUNCTION IF EXISTS storage.search_v2(prefix text, bucket_name text, limits integer, levels integer, start_after text, sort_order text, sort_column text, sort_column_after text);
DROP FUNCTION IF EXISTS storage.search_by_timestamp(p_prefix text, p_bucket_id text, p_limit integer, p_level integer, p_start_after text, p_sort_order text, p_sort_column text, p_sort_column_after text);
DROP FUNCTION IF EXISTS storage.search(prefix text, bucketname text, limits integer, levels integer, offsets integer, search text, sortcolumn text, sortorder text);
DROP FUNCTION IF EXISTS storage.protect_delete();
DROP FUNCTION IF EXISTS storage.operation();
DROP FUNCTION IF EXISTS storage.list_objects_with_delimiter(_bucket_id text, prefix_param text, delimiter_param text, max_keys integer, start_after text, next_token text, sort_order text);
DROP FUNCTION IF EXISTS storage.list_multipart_uploads_with_delimiter(bucket_id text, prefix_param text, delimiter_param text, max_keys integer, next_key_token text, next_upload_token text);
DROP FUNCTION IF EXISTS storage.get_size_by_bucket();
DROP FUNCTION IF EXISTS storage.get_common_prefix(p_key text, p_prefix text, p_delimiter text);
DROP FUNCTION IF EXISTS storage.foldername(name text);
DROP FUNCTION IF EXISTS storage.filename(name text);
DROP FUNCTION IF EXISTS storage.extension(name text);
DROP FUNCTION IF EXISTS storage.enforce_bucket_name_length();
DROP FUNCTION IF EXISTS storage.can_insert_object(bucketid text, name text, owner uuid, metadata jsonb);
DROP FUNCTION IF EXISTS storage.allow_only_operation(expected_operation text);
DROP FUNCTION IF EXISTS storage.allow_any_operation(expected_operations text[]);
DROP FUNCTION IF EXISTS realtime.wal2json_escape_identifier(name text);
DROP FUNCTION IF EXISTS realtime.topic();
DROP FUNCTION IF EXISTS realtime.to_regrole(role_name text);
DROP FUNCTION IF EXISTS realtime.subscription_check_filters();
DROP FUNCTION IF EXISTS realtime.send_binary(payload bytea, event text, topic text, private boolean);
DROP FUNCTION IF EXISTS realtime.send(payload jsonb, event text, topic text, private boolean);
DROP FUNCTION IF EXISTS realtime.quote_wal2json(entity regclass);
DROP FUNCTION IF EXISTS realtime.list_changes(publication name, slot_name name, max_changes integer, max_record_bytes integer);
DROP FUNCTION IF EXISTS realtime.is_visible_through_filters(columns realtime.wal_column[], filters realtime.user_defined_filter[]);
DROP FUNCTION IF EXISTS realtime.check_equality_op(op realtime.equality_op, type_ regtype, val_1 text, val_2 text);
DROP FUNCTION IF EXISTS realtime."cast"(val text, type_ regtype);
DROP FUNCTION IF EXISTS realtime.build_prepared_statement_sql(prepared_statement_name text, entity regclass, columns realtime.wal_column[]);
DROP FUNCTION IF EXISTS realtime.broadcast_changes(topic_name text, event_name text, operation text, table_name text, table_schema text, new record, old record, level text);
DROP FUNCTION IF EXISTS realtime.apply_rls(wal jsonb, max_record_bytes integer);
DROP FUNCTION IF EXISTS public.veedon_bump_branch_config();
DROP FUNCTION IF EXISTS public.user_is_thread_participant(thread_id uuid);
DROP FUNCTION IF EXISTS public.user_is_org_member_for_thread(thread_id uuid);
DROP FUNCTION IF EXISTS public.update_subscriber_activity();
DROP FUNCTION IF EXISTS public.update_modified_column();
DROP FUNCTION IF EXISTS public.trigger_auto_sync();
DROP FUNCTION IF EXISTS public.trg_touch_updated_at();
DROP FUNCTION IF EXISTS public.touch_chat_thread();
DROP FUNCTION IF EXISTS public.restrict_events_update();
DROP FUNCTION IF EXISTS public.manage_auto_sync_schedule(enabled boolean, interval_minutes integer);
DROP FUNCTION IF EXISTS public.is_super_admin(user_email text);
DROP FUNCTION IF EXISTS public.is_current_user_super_admin();
DROP FUNCTION IF EXISTS public.inc_download_count(mid text);
DROP FUNCTION IF EXISTS public.handle_new_user();
DROP FUNCTION IF EXISTS public.get_user_role(user_id uuid);
DROP FUNCTION IF EXISTS public.current_user_is_org_admin_or_manager(org_id uuid);
DROP FUNCTION IF EXISTS public.current_user_is_branch_manager_for_user(target_user_id uuid);
DROP FUNCTION IF EXISTS public.branch_manager_can_view_submission(_submission_id uuid);
DROP FUNCTION IF EXISTS pgbouncer.get_auth(p_usename text);
DROP FUNCTION IF EXISTS graphql_public.graphql("operationName" text, query text, variables jsonb, extensions jsonb);
DROP FUNCTION IF EXISTS extensions.set_graphql_placeholder();
DROP FUNCTION IF EXISTS extensions.pgrst_drop_watch();
DROP FUNCTION IF EXISTS extensions.pgrst_ddl_watch();
DROP FUNCTION IF EXISTS extensions.grant_pg_net_access();
DROP FUNCTION IF EXISTS extensions.grant_pg_graphql_access();
DROP FUNCTION IF EXISTS extensions.grant_pg_cron_access();
DROP FUNCTION IF EXISTS auth.uid();
DROP FUNCTION IF EXISTS auth.role();
DROP FUNCTION IF EXISTS auth.jwt();
DROP FUNCTION IF EXISTS auth.email();
DROP TYPE IF EXISTS storage.buckettype;
DROP TYPE IF EXISTS realtime.wal_rls;
DROP TYPE IF EXISTS realtime.wal_column;
DROP TYPE IF EXISTS realtime.user_defined_filter;
DROP TYPE IF EXISTS realtime.equality_op;
DROP TYPE IF EXISTS realtime.action;
DROP TYPE IF EXISTS public.user_role;
DROP TYPE IF EXISTS public.subscription_tier;
DROP TYPE IF EXISTS public.detection_method;
DROP TYPE IF EXISTS auth.one_time_token_type;
DROP TYPE IF EXISTS auth.oauth_response_type;
DROP TYPE IF EXISTS auth.oauth_registration_type;
DROP TYPE IF EXISTS auth.oauth_client_type;
DROP TYPE IF EXISTS auth.oauth_authorization_status;
DROP TYPE IF EXISTS auth.factor_type;
DROP TYPE IF EXISTS auth.factor_status;
DROP TYPE IF EXISTS auth.code_challenge_method;
DROP TYPE IF EXISTS auth.aal_level;
DROP EXTENSION IF EXISTS "uuid-ossp";
DROP EXTENSION IF EXISTS supabase_vault;
DROP EXTENSION IF EXISTS pgcrypto;
DROP EXTENSION IF EXISTS pg_stat_statements;
DROP SCHEMA IF EXISTS vault;
DROP SCHEMA IF EXISTS supabase_migrations;
DROP SCHEMA IF EXISTS supabase_functions;
DROP SCHEMA IF EXISTS storage;
DROP SCHEMA IF EXISTS realtime;
DROP SCHEMA IF EXISTS pgbouncer;
DROP EXTENSION IF EXISTS pg_net;
DROP SCHEMA IF EXISTS graphql_public;
DROP SCHEMA IF EXISTS graphql;
DROP SCHEMA IF EXISTS extensions;
DROP SCHEMA IF EXISTS auth;
DROP SCHEMA IF EXISTS _realtime;
--
-- Name: _realtime; Type: SCHEMA; Schema: -; Owner: postgres
--

CREATE SCHEMA _realtime;


ALTER SCHEMA _realtime OWNER TO postgres;

--
-- Name: auth; Type: SCHEMA; Schema: -; Owner: supabase_admin
--

CREATE SCHEMA auth;


ALTER SCHEMA auth OWNER TO supabase_admin;

--
-- Name: extensions; Type: SCHEMA; Schema: -; Owner: postgres
--

CREATE SCHEMA extensions;


ALTER SCHEMA extensions OWNER TO postgres;

--
-- Name: graphql; Type: SCHEMA; Schema: -; Owner: supabase_admin
--

CREATE SCHEMA graphql;


ALTER SCHEMA graphql OWNER TO supabase_admin;

--
-- Name: graphql_public; Type: SCHEMA; Schema: -; Owner: supabase_admin
--

CREATE SCHEMA graphql_public;


ALTER SCHEMA graphql_public OWNER TO supabase_admin;

--
-- Name: pg_net; Type: EXTENSION; Schema: -; Owner: -
--

CREATE EXTENSION IF NOT EXISTS pg_net WITH SCHEMA extensions;


--
-- Name: EXTENSION pg_net; Type: COMMENT; Schema: -; Owner: 
--

COMMENT ON EXTENSION pg_net IS 'Async HTTP';


--
-- Name: pgbouncer; Type: SCHEMA; Schema: -; Owner: pgbouncer
--

CREATE SCHEMA pgbouncer;


ALTER SCHEMA pgbouncer OWNER TO pgbouncer;

--
-- Name: realtime; Type: SCHEMA; Schema: -; Owner: supabase_admin
--

CREATE SCHEMA realtime;


ALTER SCHEMA realtime OWNER TO supabase_admin;

--
-- Name: storage; Type: SCHEMA; Schema: -; Owner: supabase_admin
--

CREATE SCHEMA storage;


ALTER SCHEMA storage OWNER TO supabase_admin;

--
-- Name: supabase_functions; Type: SCHEMA; Schema: -; Owner: supabase_admin
--

CREATE SCHEMA supabase_functions;


ALTER SCHEMA supabase_functions OWNER TO supabase_admin;

--
-- Name: supabase_migrations; Type: SCHEMA; Schema: -; Owner: postgres
--

CREATE SCHEMA supabase_migrations;


ALTER SCHEMA supabase_migrations OWNER TO postgres;

--
-- Name: vault; Type: SCHEMA; Schema: -; Owner: supabase_admin
--

CREATE SCHEMA vault;


ALTER SCHEMA vault OWNER TO supabase_admin;

--
-- Name: pg_stat_statements; Type: EXTENSION; Schema: -; Owner: -
--

CREATE EXTENSION IF NOT EXISTS pg_stat_statements WITH SCHEMA extensions;


--
-- Name: EXTENSION pg_stat_statements; Type: COMMENT; Schema: -; Owner: 
--

COMMENT ON EXTENSION pg_stat_statements IS 'track planning and execution statistics of all SQL statements executed';


--
-- Name: pgcrypto; Type: EXTENSION; Schema: -; Owner: -
--

CREATE EXTENSION IF NOT EXISTS pgcrypto WITH SCHEMA extensions;


--
-- Name: EXTENSION pgcrypto; Type: COMMENT; Schema: -; Owner: 
--

COMMENT ON EXTENSION pgcrypto IS 'cryptographic functions';


--
-- Name: supabase_vault; Type: EXTENSION; Schema: -; Owner: -
--

CREATE EXTENSION IF NOT EXISTS supabase_vault WITH SCHEMA vault;


--
-- Name: EXTENSION supabase_vault; Type: COMMENT; Schema: -; Owner: 
--

COMMENT ON EXTENSION supabase_vault IS 'Supabase Vault Extension';


--
-- Name: uuid-ossp; Type: EXTENSION; Schema: -; Owner: -
--

CREATE EXTENSION IF NOT EXISTS "uuid-ossp" WITH SCHEMA extensions;


--
-- Name: EXTENSION "uuid-ossp"; Type: COMMENT; Schema: -; Owner: 
--

COMMENT ON EXTENSION "uuid-ossp" IS 'generate universally unique identifiers (UUIDs)';


--
-- Name: aal_level; Type: TYPE; Schema: auth; Owner: supabase_auth_admin
--

CREATE TYPE auth.aal_level AS ENUM (
    'aal1',
    'aal2',
    'aal3'
);


ALTER TYPE auth.aal_level OWNER TO supabase_auth_admin;

--
-- Name: code_challenge_method; Type: TYPE; Schema: auth; Owner: supabase_auth_admin
--

CREATE TYPE auth.code_challenge_method AS ENUM (
    's256',
    'plain'
);


ALTER TYPE auth.code_challenge_method OWNER TO supabase_auth_admin;

--
-- Name: factor_status; Type: TYPE; Schema: auth; Owner: supabase_auth_admin
--

CREATE TYPE auth.factor_status AS ENUM (
    'unverified',
    'verified'
);


ALTER TYPE auth.factor_status OWNER TO supabase_auth_admin;

--
-- Name: factor_type; Type: TYPE; Schema: auth; Owner: supabase_auth_admin
--

CREATE TYPE auth.factor_type AS ENUM (
    'totp',
    'webauthn',
    'phone'
);


ALTER TYPE auth.factor_type OWNER TO supabase_auth_admin;

--
-- Name: oauth_authorization_status; Type: TYPE; Schema: auth; Owner: supabase_auth_admin
--

CREATE TYPE auth.oauth_authorization_status AS ENUM (
    'pending',
    'approved',
    'denied',
    'expired'
);


ALTER TYPE auth.oauth_authorization_status OWNER TO supabase_auth_admin;

--
-- Name: oauth_client_type; Type: TYPE; Schema: auth; Owner: supabase_auth_admin
--

CREATE TYPE auth.oauth_client_type AS ENUM (
    'public',
    'confidential'
);


ALTER TYPE auth.oauth_client_type OWNER TO supabase_auth_admin;

--
-- Name: oauth_registration_type; Type: TYPE; Schema: auth; Owner: supabase_auth_admin
--

CREATE TYPE auth.oauth_registration_type AS ENUM (
    'dynamic',
    'manual'
);


ALTER TYPE auth.oauth_registration_type OWNER TO supabase_auth_admin;

--
-- Name: oauth_response_type; Type: TYPE; Schema: auth; Owner: supabase_auth_admin
--

CREATE TYPE auth.oauth_response_type AS ENUM (
    'code'
);


ALTER TYPE auth.oauth_response_type OWNER TO supabase_auth_admin;

--
-- Name: one_time_token_type; Type: TYPE; Schema: auth; Owner: supabase_auth_admin
--

CREATE TYPE auth.one_time_token_type AS ENUM (
    'confirmation_token',
    'reauthentication_token',
    'recovery_token',
    'email_change_token_new',
    'email_change_token_current',
    'phone_change_token'
);


ALTER TYPE auth.one_time_token_type OWNER TO supabase_auth_admin;

--
-- Name: detection_method; Type: TYPE; Schema: public; Owner: postgres
--

CREATE TYPE public.detection_method AS ENUM (
    'file',
    'api'
);


ALTER TYPE public.detection_method OWNER TO postgres;

--
-- Name: subscription_tier; Type: TYPE; Schema: public; Owner: postgres
--

CREATE TYPE public.subscription_tier AS ENUM (
    'basic',
    'professional',
    'enterprise',
    'ai-premium'
);


ALTER TYPE public.subscription_tier OWNER TO postgres;

--
-- Name: user_role; Type: TYPE; Schema: public; Owner: postgres
--

CREATE TYPE public.user_role AS ENUM (
    'admin',
    'manager',
    'viewer',
    'super_admin',
    'company_admin',
    'branch_manager',
    'representative'
);


ALTER TYPE public.user_role OWNER TO postgres;

--
-- Name: action; Type: TYPE; Schema: realtime; Owner: supabase_admin
--

CREATE TYPE realtime.action AS ENUM (
    'INSERT',
    'UPDATE',
    'DELETE',
    'TRUNCATE',
    'ERROR'
);


ALTER TYPE realtime.action OWNER TO supabase_admin;

--
-- Name: equality_op; Type: TYPE; Schema: realtime; Owner: supabase_admin
--

CREATE TYPE realtime.equality_op AS ENUM (
    'eq',
    'neq',
    'lt',
    'lte',
    'gt',
    'gte',
    'in'
);


ALTER TYPE realtime.equality_op OWNER TO supabase_admin;

--
-- Name: user_defined_filter; Type: TYPE; Schema: realtime; Owner: supabase_admin
--

CREATE TYPE realtime.user_defined_filter AS (
	column_name text,
	op realtime.equality_op,
	value text
);


ALTER TYPE realtime.user_defined_filter OWNER TO supabase_admin;

--
-- Name: wal_column; Type: TYPE; Schema: realtime; Owner: supabase_admin
--

CREATE TYPE realtime.wal_column AS (
	name text,
	type_name text,
	type_oid oid,
	value jsonb,
	is_pkey boolean,
	is_selectable boolean
);


ALTER TYPE realtime.wal_column OWNER TO supabase_admin;

--
-- Name: wal_rls; Type: TYPE; Schema: realtime; Owner: supabase_admin
--

CREATE TYPE realtime.wal_rls AS (
	wal jsonb,
	is_rls_enabled boolean,
	subscription_ids uuid[],
	errors text[]
);


ALTER TYPE realtime.wal_rls OWNER TO supabase_admin;

--
-- Name: buckettype; Type: TYPE; Schema: storage; Owner: supabase_storage_admin
--

CREATE TYPE storage.buckettype AS ENUM (
    'STANDARD',
    'ANALYTICS',
    'VECTOR'
);


ALTER TYPE storage.buckettype OWNER TO supabase_storage_admin;

--
-- Name: email(); Type: FUNCTION; Schema: auth; Owner: supabase_auth_admin
--

CREATE FUNCTION auth.email() RETURNS text
    LANGUAGE sql STABLE
    AS $$
  select 
  coalesce(
    nullif(current_setting('request.jwt.claim.email', true), ''),
    (nullif(current_setting('request.jwt.claims', true), '')::jsonb ->> 'email')
  )::text
$$;


ALTER FUNCTION auth.email() OWNER TO supabase_auth_admin;

--
-- Name: FUNCTION email(); Type: COMMENT; Schema: auth; Owner: supabase_auth_admin
--

COMMENT ON FUNCTION auth.email() IS 'Deprecated. Use auth.jwt() -> ''email'' instead.';


--
-- Name: jwt(); Type: FUNCTION; Schema: auth; Owner: supabase_auth_admin
--

CREATE FUNCTION auth.jwt() RETURNS jsonb
    LANGUAGE sql STABLE
    AS $$
  select 
    coalesce(
        nullif(current_setting('request.jwt.claim', true), ''),
        nullif(current_setting('request.jwt.claims', true), '')
    )::jsonb
$$;


ALTER FUNCTION auth.jwt() OWNER TO supabase_auth_admin;

--
-- Name: role(); Type: FUNCTION; Schema: auth; Owner: supabase_auth_admin
--

CREATE FUNCTION auth.role() RETURNS text
    LANGUAGE sql STABLE
    AS $$
  select 
  coalesce(
    nullif(current_setting('request.jwt.claim.role', true), ''),
    (nullif(current_setting('request.jwt.claims', true), '')::jsonb ->> 'role')
  )::text
$$;


ALTER FUNCTION auth.role() OWNER TO supabase_auth_admin;

--
-- Name: FUNCTION role(); Type: COMMENT; Schema: auth; Owner: supabase_auth_admin
--

COMMENT ON FUNCTION auth.role() IS 'Deprecated. Use auth.jwt() -> ''role'' instead.';


--
-- Name: uid(); Type: FUNCTION; Schema: auth; Owner: supabase_auth_admin
--

CREATE FUNCTION auth.uid() RETURNS uuid
    LANGUAGE sql STABLE
    AS $$
  select 
  coalesce(
    nullif(current_setting('request.jwt.claim.sub', true), ''),
    (nullif(current_setting('request.jwt.claims', true), '')::jsonb ->> 'sub')
  )::uuid
$$;


ALTER FUNCTION auth.uid() OWNER TO supabase_auth_admin;

--
-- Name: FUNCTION uid(); Type: COMMENT; Schema: auth; Owner: supabase_auth_admin
--

COMMENT ON FUNCTION auth.uid() IS 'Deprecated. Use auth.jwt() -> ''sub'' instead.';


--
-- Name: grant_pg_cron_access(); Type: FUNCTION; Schema: extensions; Owner: supabase_admin
--

CREATE FUNCTION extensions.grant_pg_cron_access() RETURNS event_trigger
    LANGUAGE plpgsql
    AS $$
BEGIN
  IF EXISTS (
    SELECT
    FROM pg_event_trigger_ddl_commands() AS ev
    JOIN pg_extension AS ext
    ON ev.objid = ext.oid
    WHERE ext.extname = 'pg_cron'
  )
  THEN
    grant usage on schema cron to postgres with grant option;

    alter default privileges in schema cron grant all on tables to postgres with grant option;
    alter default privileges in schema cron grant all on functions to postgres with grant option;
    alter default privileges in schema cron grant all on sequences to postgres with grant option;

    alter default privileges for user supabase_admin in schema cron grant all
        on sequences to postgres with grant option;
    alter default privileges for user supabase_admin in schema cron grant all
        on tables to postgres with grant option;
    alter default privileges for user supabase_admin in schema cron grant all
        on functions to postgres with grant option;

    grant all privileges on all tables in schema cron to postgres with grant option;
    revoke all on table cron.job from postgres;
    grant select on table cron.job to postgres with grant option;
  END IF;
END;
$$;


ALTER FUNCTION extensions.grant_pg_cron_access() OWNER TO supabase_admin;

--
-- Name: FUNCTION grant_pg_cron_access(); Type: COMMENT; Schema: extensions; Owner: supabase_admin
--

COMMENT ON FUNCTION extensions.grant_pg_cron_access() IS 'Grants access to pg_cron';


--
-- Name: grant_pg_graphql_access(); Type: FUNCTION; Schema: extensions; Owner: supabase_admin
--

CREATE FUNCTION extensions.grant_pg_graphql_access() RETURNS event_trigger
    LANGUAGE plpgsql
    AS $_$
begin
    if not exists (
        select 1
        from pg_event_trigger_ddl_commands() ev
        join pg_catalog.pg_extension e on ev.objid = e.oid
        where e.extname = 'pg_graphql'
    ) then
        return;
    end if;

    drop function if exists graphql_public.graphql;
    create or replace function graphql_public.graphql(
        "operationName" text default null,
        query text default null,
        variables jsonb default null,
        extensions jsonb default null
    )
        returns jsonb
        language sql
    as $$
        select graphql.resolve(
            query := query,
            variables := coalesce(variables, '{}'),
            "operationName" := "operationName",
            extensions := extensions
        );
    $$;

    -- Attach the wrapper to the extension so DROP EXTENSION cascades to it,
    -- which in turn triggers set_graphql_placeholder to reinstall the "not enabled" stub.
    alter extension pg_graphql add function graphql_public.graphql(text, text, jsonb, jsonb);

    grant usage on schema graphql to postgres, anon, authenticated, service_role;
    grant execute on function graphql.resolve to postgres, anon, authenticated, service_role;
    grant usage on schema graphql to postgres with grant option;
    grant usage on schema graphql_public to postgres with grant option;
end;
$_$;


ALTER FUNCTION extensions.grant_pg_graphql_access() OWNER TO supabase_admin;

--
-- Name: FUNCTION grant_pg_graphql_access(); Type: COMMENT; Schema: extensions; Owner: supabase_admin
--

COMMENT ON FUNCTION extensions.grant_pg_graphql_access() IS 'Grants access to pg_graphql';


--
-- Name: grant_pg_net_access(); Type: FUNCTION; Schema: extensions; Owner: supabase_admin
--

CREATE FUNCTION extensions.grant_pg_net_access() RETURNS event_trigger
    LANGUAGE plpgsql
    AS $$
BEGIN
  IF EXISTS (
    SELECT 1
    FROM pg_event_trigger_ddl_commands() AS ev
    JOIN pg_extension AS ext
    ON ev.objid = ext.oid
    WHERE ext.extname = 'pg_net'
  )
  THEN
    GRANT USAGE ON SCHEMA net TO supabase_functions_admin, postgres, anon, authenticated, service_role;

    ALTER function net.http_get(url text, params jsonb, headers jsonb, timeout_milliseconds integer) SECURITY DEFINER;
    ALTER function net.http_post(url text, body jsonb, params jsonb, headers jsonb, timeout_milliseconds integer) SECURITY DEFINER;

    ALTER function net.http_get(url text, params jsonb, headers jsonb, timeout_milliseconds integer) SET search_path = net;
    ALTER function net.http_post(url text, body jsonb, params jsonb, headers jsonb, timeout_milliseconds integer) SET search_path = net;

    REVOKE ALL ON FUNCTION net.http_get(url text, params jsonb, headers jsonb, timeout_milliseconds integer) FROM PUBLIC;
    REVOKE ALL ON FUNCTION net.http_post(url text, body jsonb, params jsonb, headers jsonb, timeout_milliseconds integer) FROM PUBLIC;

    GRANT EXECUTE ON FUNCTION net.http_get(url text, params jsonb, headers jsonb, timeout_milliseconds integer) TO supabase_functions_admin, postgres, anon, authenticated, service_role;
    GRANT EXECUTE ON FUNCTION net.http_post(url text, body jsonb, params jsonb, headers jsonb, timeout_milliseconds integer) TO supabase_functions_admin, postgres, anon, authenticated, service_role;
  END IF;
END;
$$;


ALTER FUNCTION extensions.grant_pg_net_access() OWNER TO supabase_admin;

--
-- Name: FUNCTION grant_pg_net_access(); Type: COMMENT; Schema: extensions; Owner: supabase_admin
--

COMMENT ON FUNCTION extensions.grant_pg_net_access() IS 'Grants access to pg_net';


--
-- Name: pgrst_ddl_watch(); Type: FUNCTION; Schema: extensions; Owner: supabase_admin
--

CREATE FUNCTION extensions.pgrst_ddl_watch() RETURNS event_trigger
    LANGUAGE plpgsql
    AS $$
DECLARE
  cmd record;
BEGIN
  FOR cmd IN SELECT * FROM pg_event_trigger_ddl_commands()
  LOOP
    IF cmd.command_tag IN (
      'CREATE SCHEMA', 'ALTER SCHEMA'
    , 'CREATE TABLE', 'CREATE TABLE AS', 'SELECT INTO', 'ALTER TABLE'
    , 'CREATE FOREIGN TABLE', 'ALTER FOREIGN TABLE'
    , 'CREATE VIEW', 'ALTER VIEW'
    , 'CREATE MATERIALIZED VIEW', 'ALTER MATERIALIZED VIEW'
    , 'CREATE FUNCTION', 'ALTER FUNCTION'
    , 'CREATE TRIGGER'
    , 'CREATE TYPE', 'ALTER TYPE'
    , 'CREATE RULE'
    , 'COMMENT'
    )
    -- don't notify in case of CREATE TEMP table or other objects created on pg_temp
    AND cmd.schema_name is distinct from 'pg_temp'
    THEN
      NOTIFY pgrst, 'reload schema';
    END IF;
  END LOOP;
END; $$;


ALTER FUNCTION extensions.pgrst_ddl_watch() OWNER TO supabase_admin;

--
-- Name: pgrst_drop_watch(); Type: FUNCTION; Schema: extensions; Owner: supabase_admin
--

CREATE FUNCTION extensions.pgrst_drop_watch() RETURNS event_trigger
    LANGUAGE plpgsql
    AS $$
DECLARE
  obj record;
BEGIN
  FOR obj IN SELECT * FROM pg_event_trigger_dropped_objects()
  LOOP
    IF obj.object_type IN (
      'schema'
    , 'table'
    , 'foreign table'
    , 'view'
    , 'materialized view'
    , 'function'
    , 'trigger'
    , 'type'
    , 'rule'
    )
    AND obj.is_temporary IS false -- no pg_temp objects
    THEN
      NOTIFY pgrst, 'reload schema';
    END IF;
  END LOOP;
END; $$;


ALTER FUNCTION extensions.pgrst_drop_watch() OWNER TO supabase_admin;

--
-- Name: set_graphql_placeholder(); Type: FUNCTION; Schema: extensions; Owner: supabase_admin
--

CREATE FUNCTION extensions.set_graphql_placeholder() RETURNS event_trigger
    LANGUAGE plpgsql
    AS $_$
    DECLARE
    graphql_is_dropped bool;
    BEGIN
    graphql_is_dropped = (
        SELECT ev.schema_name = 'graphql_public'
        FROM pg_event_trigger_dropped_objects() AS ev
        WHERE ev.schema_name = 'graphql_public'
    );

    IF graphql_is_dropped
    THEN
        create or replace function graphql_public.graphql(
            "operationName" text default null,
            query text default null,
            variables jsonb default null,
            extensions jsonb default null
        )
            returns jsonb
            language plpgsql
        as $$
            DECLARE
                server_version float;
            BEGIN
                server_version = (SELECT (SPLIT_PART((select version()), ' ', 2))::float);

                IF server_version >= 14 THEN
                    RETURN jsonb_build_object(
                        'errors', jsonb_build_array(
                            jsonb_build_object(
                                'message', 'pg_graphql extension is not enabled.'
                            )
                        )
                    );
                ELSE
                    RETURN jsonb_build_object(
                        'errors', jsonb_build_array(
                            jsonb_build_object(
                                'message', 'pg_graphql is only available on projects running Postgres 14 onwards.'
                            )
                        )
                    );
                END IF;
            END;
        $$;
    END IF;

    END;
$_$;


ALTER FUNCTION extensions.set_graphql_placeholder() OWNER TO supabase_admin;

--
-- Name: FUNCTION set_graphql_placeholder(); Type: COMMENT; Schema: extensions; Owner: supabase_admin
--

COMMENT ON FUNCTION extensions.set_graphql_placeholder() IS 'Reintroduces placeholder function for graphql_public.graphql';


--
-- Name: graphql(text, text, jsonb, jsonb); Type: FUNCTION; Schema: graphql_public; Owner: supabase_admin
--

CREATE FUNCTION graphql_public.graphql("operationName" text DEFAULT NULL::text, query text DEFAULT NULL::text, variables jsonb DEFAULT NULL::jsonb, extensions jsonb DEFAULT NULL::jsonb) RETURNS jsonb
    LANGUAGE plpgsql
    AS $$
            DECLARE
                server_version float;
            BEGIN
                server_version = (SELECT (SPLIT_PART((select version()), ' ', 2))::float);

                IF server_version >= 14 THEN
                    RETURN jsonb_build_object(
                        'errors', jsonb_build_array(
                            jsonb_build_object(
                                'message', 'pg_graphql extension is not enabled.'
                            )
                        )
                    );
                ELSE
                    RETURN jsonb_build_object(
                        'errors', jsonb_build_array(
                            jsonb_build_object(
                                'message', 'pg_graphql is only available on projects running Postgres 14 onwards.'
                            )
                        )
                    );
                END IF;
            END;
        $$;


ALTER FUNCTION graphql_public.graphql("operationName" text, query text, variables jsonb, extensions jsonb) OWNER TO supabase_admin;

--
-- Name: get_auth(text); Type: FUNCTION; Schema: pgbouncer; Owner: supabase_admin
--

CREATE FUNCTION pgbouncer.get_auth(p_usename text) RETURNS TABLE(username text, password text)
    LANGUAGE plpgsql SECURITY DEFINER
    SET search_path TO ''
    AS $_$
begin
    raise debug 'PgBouncer auth request: %', p_usename;

    return query
    select 
        rolname::text, 
        case when rolvaliduntil < now() 
            then null 
            else rolpassword::text 
        end 
    from pg_authid 
    where rolname=$1 and rolcanlogin;
end;
$_$;


ALTER FUNCTION pgbouncer.get_auth(p_usename text) OWNER TO supabase_admin;

--
-- Name: branch_manager_can_view_submission(uuid); Type: FUNCTION; Schema: public; Owner: postgres
--

CREATE FUNCTION public.branch_manager_can_view_submission(_submission_id uuid) RETURNS boolean
    LANGUAGE sql STABLE SECURITY DEFINER
    SET search_path TO ''
    AS $$
  WITH fa AS (
    SELECT fa.representative_id
    FROM public.form_assignments fa
    JOIN public.form_submissions fs ON fs.form_assignment_id = fa.id
    WHERE fs.id = _submission_id
  ),
  manager_branches AS (
    SELECT br.branch_id
    FROM public.branch_roles br
    WHERE br.user_id = auth.uid() AND br.role = 'branch_manager'
  ),
  rep_branches AS (
    SELECT br.branch_id
    FROM public.user_roles ur
    JOIN public.branch_roles br ON br.user_id = ur.user_id
    WHERE ur.id = (SELECT representative_id FROM fa)
  )
  SELECT EXISTS (
    SELECT 1 FROM manager_branches mb
    JOIN rep_branches rb ON rb.branch_id = mb.branch_id
  );
$$;


ALTER FUNCTION public.branch_manager_can_view_submission(_submission_id uuid) OWNER TO postgres;

--
-- Name: current_user_is_branch_manager_for_user(uuid); Type: FUNCTION; Schema: public; Owner: postgres
--

CREATE FUNCTION public.current_user_is_branch_manager_for_user(target_user_id uuid) RETURNS boolean
    LANGUAGE sql STABLE SECURITY DEFINER
    SET search_path TO ''
    AS $$
  SELECT EXISTS (
    SELECT 1
    FROM public.branch_roles br_mgr
    JOIN public.branch_roles br_user ON br_user.branch_id = br_mgr.branch_id
    WHERE br_mgr.user_id = auth.uid()
      AND br_mgr.role = 'branch_manager'
      AND br_user.user_id = target_user_id
  );
$$;


ALTER FUNCTION public.current_user_is_branch_manager_for_user(target_user_id uuid) OWNER TO postgres;

--
-- Name: current_user_is_org_admin_or_manager(uuid); Type: FUNCTION; Schema: public; Owner: postgres
--

CREATE FUNCTION public.current_user_is_org_admin_or_manager(org_id uuid) RETURNS boolean
    LANGUAGE sql STABLE SECURITY DEFINER
    SET search_path TO ''
    AS $$
  SELECT EXISTS (
    SELECT 1 FROM public.user_roles ur
    WHERE ur.user_id = auth.uid()
      AND ur.organization_id = org_id
      AND ur.role IN ('admin','manager')
  );
$$;


ALTER FUNCTION public.current_user_is_org_admin_or_manager(org_id uuid) OWNER TO postgres;

--
-- Name: get_user_role(uuid); Type: FUNCTION; Schema: public; Owner: postgres
--

CREATE FUNCTION public.get_user_role(user_id uuid) RETURNS public.user_role
    LANGUAGE sql SECURITY DEFINER
    SET search_path TO ''
    AS $_$
  SELECT role FROM public.user_roles WHERE user_id = $1 LIMIT 1
$_$;


ALTER FUNCTION public.get_user_role(user_id uuid) OWNER TO postgres;

--
-- Name: handle_new_user(); Type: FUNCTION; Schema: public; Owner: postgres
--

CREATE FUNCTION public.handle_new_user() RETURNS trigger
    LANGUAGE plpgsql SECURITY DEFINER
    SET search_path TO ''
    AS $$
DECLARE
  new_org_id UUID;
BEGIN
  -- Create the organization first
  INSERT INTO public.organizations (name, subscription_tier)
  VALUES (
    COALESCE(new.raw_user_meta_data->>'organization_name', 'Default Organization'),
    'basic'
  )
  RETURNING id INTO new_org_id;
  
  -- Create default branch for the organization
  INSERT INTO public.branches (organization_id, name, address)
  VALUES (new_org_id, 'Headquarters', 'Main Location');
  
  -- Add user role as admin for the organization
  INSERT INTO public.user_roles (user_id, organization_id, role)
  VALUES (new.id, new_org_id, 'admin');
  
  -- Create user preferences with default language
  INSERT INTO public.user_preferences (user_id, language)
  VALUES (new.id, COALESCE(new.raw_user_meta_data->>'language', 'en'));
  
  -- Create subscriber record
  INSERT INTO public.subscribers (user_id, email, subscription_tier)
  VALUES (new.id, new.email, 'basic');
  
  RETURN new;
END;
$$;


ALTER FUNCTION public.handle_new_user() OWNER TO postgres;

--
-- Name: inc_download_count(text); Type: FUNCTION; Schema: public; Owner: postgres
--

CREATE FUNCTION public.inc_download_count(mid text) RETURNS void
    LANGUAGE plpgsql SECURITY DEFINER
    AS $$
BEGIN
  UPDATE frigate_model_registry
     SET download_count = COALESCE(download_count, 0) + 1
   WHERE model_id = mid;
END;
$$;


ALTER FUNCTION public.inc_download_count(mid text) OWNER TO postgres;

--
-- Name: is_current_user_super_admin(); Type: FUNCTION; Schema: public; Owner: postgres
--

CREATE FUNCTION public.is_current_user_super_admin() RETURNS boolean
    LANGUAGE sql SECURITY DEFINER
    SET search_path TO 'public'
    AS $$
  SELECT public.is_super_admin((SELECT email FROM auth.users WHERE id = auth.uid()))
$$;


ALTER FUNCTION public.is_current_user_super_admin() OWNER TO postgres;

--
-- Name: is_super_admin(text); Type: FUNCTION; Schema: public; Owner: postgres
--

CREATE FUNCTION public.is_super_admin(user_email text) RETURNS boolean
    LANGUAGE sql SECURITY DEFINER
    SET search_path TO ''
    AS $$
  SELECT LOWER(user_email) IN ('ashraffarid@gmail.com', 'demo@beyondsenses.ai')
$$;


ALTER FUNCTION public.is_super_admin(user_email text) OWNER TO postgres;

--
-- Name: manage_auto_sync_schedule(boolean, integer); Type: FUNCTION; Schema: public; Owner: postgres
--

CREATE FUNCTION public.manage_auto_sync_schedule(enabled boolean, interval_minutes integer DEFAULT 30) RETURNS void
    LANGUAGE plpgsql SECURITY DEFINER
    AS $$
BEGIN
  -- No-op: pg_cron not available in local dev
  NULL;
END;
$$;


ALTER FUNCTION public.manage_auto_sync_schedule(enabled boolean, interval_minutes integer) OWNER TO postgres;

--
-- Name: restrict_events_update(); Type: FUNCTION; Schema: public; Owner: postgres
--

CREATE FUNCTION public.restrict_events_update() RETURNS trigger
    LANGUAGE plpgsql SECURITY DEFINER
    SET search_path TO 'public'
    AS $$
BEGIN
  IF OLD.metadata->>'source' = 'veedon-edge' THEN
    RETURN NEW;
  END IF;
  IF NEW.reviewed IS DISTINCT FROM TRUE THEN
    RAISE EXCEPTION 'Only allowed to set reviewed=true';
  END IF;
  IF OLD.reviewed = TRUE THEN
    RAISE EXCEPTION 'Event already reviewed';
  END IF;
  IF NEW.id <> OLD.id OR
     NEW.camera_id IS DISTINCT FROM OLD.camera_id OR
     NEW.metadata IS DISTINCT FROM OLD.metadata OR
     NEW.detected_at IS DISTINCT FROM OLD.detected_at OR
     NEW.severity IS DISTINCT FROM OLD.severity OR
     NEW.snapshot_url IS DISTINCT FROM OLD.snapshot_url OR
     NEW.event_type IS DISTINCT FROM OLD.event_type THEN
     RAISE EXCEPTION 'Only the reviewed field may be updated';
  END IF;
  RETURN NEW;
END;
$$;


ALTER FUNCTION public.restrict_events_update() OWNER TO postgres;

--
-- Name: touch_chat_thread(); Type: FUNCTION; Schema: public; Owner: postgres
--

CREATE FUNCTION public.touch_chat_thread() RETURNS trigger
    LANGUAGE plpgsql SECURITY DEFINER
    SET search_path TO 'public'
    AS $$
BEGIN
  UPDATE public.chat_threads SET updated_at = now() WHERE id = NEW.thread_id;
  RETURN NEW;
END;
$$;


ALTER FUNCTION public.touch_chat_thread() OWNER TO postgres;

--
-- Name: trg_touch_updated_at(); Type: FUNCTION; Schema: public; Owner: postgres
--

CREATE FUNCTION public.trg_touch_updated_at() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
BEGIN NEW.updated_at = now(); RETURN NEW; END;
$$;


ALTER FUNCTION public.trg_touch_updated_at() OWNER TO postgres;

--
-- Name: trigger_auto_sync(); Type: FUNCTION; Schema: public; Owner: postgres
--

CREATE FUNCTION public.trigger_auto_sync() RETURNS void
    LANGUAGE plpgsql SECURITY DEFINER
    AS $$
BEGIN
  -- Skipped: requires pg_net extension not enabled in local dev
  -- In production, this function calls auto-sync-data edge function via pg_net
  NULL;
END;
$$;


ALTER FUNCTION public.trigger_auto_sync() OWNER TO postgres;

--
-- Name: update_modified_column(); Type: FUNCTION; Schema: public; Owner: postgres
--

CREATE FUNCTION public.update_modified_column() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
BEGIN
    NEW.updated_at = now();
    RETURN NEW;
END;
$$;


ALTER FUNCTION public.update_modified_column() OWNER TO postgres;

--
-- Name: update_subscriber_activity(); Type: FUNCTION; Schema: public; Owner: postgres
--

CREATE FUNCTION public.update_subscriber_activity() RETURNS trigger
    LANGUAGE plpgsql SECURITY DEFINER
    SET search_path TO 'public'
    AS $$
BEGIN
    UPDATE public.subscribers 
    SET last_activity = now() 
    WHERE user_id = NEW.user_id OR user_id = OLD.user_id;
    RETURN COALESCE(NEW, OLD);
END;
$$;


ALTER FUNCTION public.update_subscriber_activity() OWNER TO postgres;

--
-- Name: user_is_org_member_for_thread(uuid); Type: FUNCTION; Schema: public; Owner: postgres
--

CREATE FUNCTION public.user_is_org_member_for_thread(thread_id uuid) RETURNS boolean
    LANGUAGE sql SECURITY DEFINER
    SET search_path TO ''
    AS $$
  SELECT EXISTS (
    SELECT 1
    FROM public.chat_threads t
    JOIN public.user_roles ur ON ur.organization_id = t.organization_id
    WHERE t.id = user_is_org_member_for_thread.thread_id
      AND ur.user_id = auth.uid()
  );
$$;


ALTER FUNCTION public.user_is_org_member_for_thread(thread_id uuid) OWNER TO postgres;

--
-- Name: user_is_thread_participant(uuid); Type: FUNCTION; Schema: public; Owner: postgres
--

CREATE FUNCTION public.user_is_thread_participant(thread_id uuid) RETURNS boolean
    LANGUAGE sql SECURITY DEFINER
    SET search_path TO 'public'
    AS $$
  SELECT EXISTS (
    SELECT 1 FROM public.chat_thread_participants p
    WHERE p.thread_id = user_is_thread_participant.thread_id
      AND p.user_id = auth.uid()
  );
$$;


ALTER FUNCTION public.user_is_thread_participant(thread_id uuid) OWNER TO postgres;

--
-- Name: veedon_bump_branch_config(); Type: FUNCTION; Schema: public; Owner: postgres
--

CREATE FUNCTION public.veedon_bump_branch_config() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
DECLARE
  target_branch uuid;
BEGIN
  IF TG_TABLE_NAME = 'cameras' THEN
    target_branch := COALESCE(NEW.branch_id, OLD.branch_id);
  ELSIF TG_TABLE_NAME = 'camera_event_assignments' THEN
    SELECT branch_id INTO target_branch FROM cameras
      WHERE id = COALESCE(NEW.camera_id, OLD.camera_id);
  END IF;
  IF target_branch IS NOT NULL THEN
    UPDATE branches SET config_version = config_version + 1 WHERE id = target_branch;
  END IF;
  RETURN COALESCE(NEW, OLD);
END;
$$;


ALTER FUNCTION public.veedon_bump_branch_config() OWNER TO postgres;

--
-- Name: apply_rls(jsonb, integer); Type: FUNCTION; Schema: realtime; Owner: supabase_admin
--

CREATE FUNCTION realtime.apply_rls(wal jsonb, max_record_bytes integer DEFAULT (1024 * 1024)) RETURNS SETOF realtime.wal_rls
    LANGUAGE plpgsql
    AS $$
declare
    -- Regclass of the table e.g. public.notes
    entity_ regclass = (quote_ident(wal ->> 'schema') || '.' || quote_ident(wal ->> 'table'))::regclass;

    -- I, U, D, T: insert, update ...
    action realtime.action = (
        case wal ->> 'action'
            when 'I' then 'INSERT'
            when 'U' then 'UPDATE'
            when 'D' then 'DELETE'
            else 'ERROR'
        end
    );

    -- Is row level security enabled for the table
    is_rls_enabled bool = relrowsecurity from pg_class where oid = entity_;

    subscriptions realtime.subscription[] = array_agg(subs)
        from
            realtime.subscription subs
        where
            subs.entity = entity_
            -- Filter by action early - only get subscriptions interested in this action
            -- action_filter column can be: '*' (all), 'INSERT', 'UPDATE', or 'DELETE'
            and (subs.action_filter = '*' or subs.action_filter = action::text);

    -- Subscription vars
    working_role regrole;
    working_selected_columns text[];
    claimed_role regrole;
    claims jsonb;

    subscription_id uuid;
    subscription_has_access bool;
    visible_to_subscription_ids uuid[] = '{}';

    -- structured info for wal's columns
    columns realtime.wal_column[];
    -- previous identity values for update/delete
    old_columns realtime.wal_column[];

    error_record_exceeds_max_size boolean = octet_length(wal::text) > max_record_bytes;

    -- Primary jsonb output for record
    output jsonb;

    -- Loop record for iterating unique roles (outer loop)
    role_record record;
    -- Loop record for iterating unique selected_columns within a role (inner loop)
    cols_record record;
    -- Subscription ids visible at the role level (before fanning out by selected_columns)
    visible_role_sub_ids uuid[] = '{}';

begin
    perform set_config('role', null, true);

    columns =
        array_agg(
            (
                x->>'name',
                x->>'type',
                x->>'typeoid',
                realtime.cast(
                    (x->'value') #>> '{}',
                    coalesce(
                        (x->>'typeoid')::regtype, -- null when wal2json version <= 2.4
                        (x->>'type')::regtype
                    )
                ),
                (pks ->> 'name') is not null,
                true
            )::realtime.wal_column
        )
        from
            jsonb_array_elements(wal -> 'columns') x
            left join jsonb_array_elements(wal -> 'pk') pks
                on (x ->> 'name') = (pks ->> 'name');

    old_columns =
        array_agg(
            (
                x->>'name',
                x->>'type',
                x->>'typeoid',
                realtime.cast(
                    (x->'value') #>> '{}',
                    coalesce(
                        (x->>'typeoid')::regtype, -- null when wal2json version <= 2.4
                        (x->>'type')::regtype
                    )
                ),
                (pks ->> 'name') is not null,
                true
            )::realtime.wal_column
        )
        from
            jsonb_array_elements(wal -> 'identity') x
            left join jsonb_array_elements(wal -> 'pk') pks
                on (x ->> 'name') = (pks ->> 'name');

    for role_record in
        select claims_role
        from (select distinct claims_role from unnest(subscriptions)) t
        order by claims_role::text
    loop
        working_role := role_record.claims_role;

        -- Update `is_selectable` for columns and old_columns (once per role)
        columns =
            array_agg(
                (
                    c.name,
                    c.type_name,
                    c.type_oid,
                    c.value,
                    c.is_pkey,
                    pg_catalog.has_column_privilege(working_role, entity_, c.name, 'SELECT')
                )::realtime.wal_column
            )
            from
                unnest(columns) c;

        old_columns =
                array_agg(
                    (
                        c.name,
                        c.type_name,
                        c.type_oid,
                        c.value,
                        c.is_pkey,
                        pg_catalog.has_column_privilege(working_role, entity_, c.name, 'SELECT')
                    )::realtime.wal_column
                )
                from
                    unnest(old_columns) c;

        if action <> 'DELETE' and count(1) = 0 from unnest(columns) c where c.is_pkey then
            -- Fan out 400 error per distinct selected_columns for this role
            for cols_record in
                select selected_columns
                from (select distinct selected_columns from unnest(subscriptions) s where s.claims_role = working_role) t
                order by coalesce(array_to_string(selected_columns, ','), '')
            loop
                working_selected_columns := cols_record.selected_columns;
                return next (
                    jsonb_build_object(
                        'schema', wal ->> 'schema',
                        'table', wal ->> 'table',
                        'type', action
                    ),
                    is_rls_enabled,
                    (select array_agg(s.subscription_id) from unnest(subscriptions) as s where s.claims_role = working_role and (s.selected_columns is not distinct from working_selected_columns)),
                    array['Error 400: Bad Request, no primary key']
                )::realtime.wal_rls;
            end loop;

        -- The claims role does not have SELECT permission to the primary key of entity
        elsif action <> 'DELETE' and sum(c.is_selectable::int) <> count(1) from unnest(columns) c where c.is_pkey then
            -- Fan out 401 error per distinct selected_columns for this role
            for cols_record in
                select selected_columns
                from (select distinct selected_columns from unnest(subscriptions) s where s.claims_role = working_role) t
                order by coalesce(array_to_string(selected_columns, ','), '')
            loop
                working_selected_columns := cols_record.selected_columns;
                return next (
                    jsonb_build_object(
                        'schema', wal ->> 'schema',
                        'table', wal ->> 'table',
                        'type', action
                    ),
                    is_rls_enabled,
                    (select array_agg(s.subscription_id) from unnest(subscriptions) as s where s.claims_role = working_role and (s.selected_columns is not distinct from working_selected_columns)),
                    array['Error 401: Unauthorized']
                )::realtime.wal_rls;
            end loop;

        else
            -- Create the prepared statement (once per role)
            if is_rls_enabled and action <> 'DELETE' then
                if (select 1 from pg_prepared_statements where name = 'walrus_rls_stmt' limit 1) > 0 then
                    deallocate walrus_rls_stmt;
                end if;
                execute realtime.build_prepared_statement_sql('walrus_rls_stmt', entity_, columns);
            end if;

            -- Collect all visible subscription IDs for this role (filter check + RLS check)
            visible_role_sub_ids = '{}';

            for subscription_id, claims in (
                    select
                        subs.subscription_id,
                        subs.claims
                    from
                        unnest(subscriptions) subs
                    where
                        subs.entity = entity_
                        and subs.claims_role = working_role
                        and (
                            realtime.is_visible_through_filters(columns, subs.filters)
                            or (
                              action = 'DELETE'
                              and realtime.is_visible_through_filters(old_columns, subs.filters)
                            )
                        )
            ) loop

                if not is_rls_enabled or action = 'DELETE' then
                    visible_role_sub_ids = visible_role_sub_ids || subscription_id;
                else
                    -- Check if RLS allows the role to see the record
                    perform
                        -- Trim leading and trailing quotes from working_role because set_config
                        -- doesn't recognize the role as valid if they are included
                        set_config('role', trim(both '"' from working_role::text), true),
                        set_config('request.jwt.claims', claims::text, true);

                    execute 'execute walrus_rls_stmt' into subscription_has_access;

                    if subscription_has_access then
                        visible_role_sub_ids = visible_role_sub_ids || subscription_id;
                    end if;
                end if;
            end loop;

            perform set_config('role', null, true);

            -- Inner loop: per distinct selected_columns for this role
            for cols_record in
                select selected_columns
                from (select distinct selected_columns from unnest(subscriptions) s where s.claims_role = working_role) t
                order by coalesce(array_to_string(selected_columns, ','), '')
            loop
                working_selected_columns := cols_record.selected_columns;

                output = jsonb_build_object(
                    'schema', wal ->> 'schema',
                    'table', wal ->> 'table',
                    'type', action,
                    'commit_timestamp', to_char(
                        ((wal ->> 'timestamp')::timestamptz at time zone 'utc'),
                        'YYYY-MM-DD"T"HH24:MI:SS.MS"Z"'
                    ),
                    'columns', (
                        select
                            jsonb_agg(
                                jsonb_build_object(
                                    'name', pa.attname,
                                    'type', pt.typname
                                )
                                order by pa.attnum asc
                            )
                        from
                            pg_attribute pa
                            join pg_type pt
                                on pa.atttypid = pt.oid
                            left join (
                                select unnest(conkey) as pkey_attnum
                                from pg_constraint
                                where conrelid = entity_ and contype = 'p'
                            ) pk on pk.pkey_attnum = pa.attnum
                        where
                            attrelid = entity_
                            and attnum > 0
                            and pg_catalog.has_column_privilege(working_role, entity_, pa.attname, 'SELECT')
                            and (working_selected_columns is null or pa.attname = any(working_selected_columns) or pk.pkey_attnum is not null)
                    )
                )
                -- Add "record" key for insert and update
                || case
                    when action in ('INSERT', 'UPDATE') then
                        jsonb_build_object(
                            'record',
                            (
                                select
                                    jsonb_object_agg(
                                        -- if unchanged toast, get column name and value from old record
                                        coalesce((c).name, (oc).name),
                                        case
                                            when (c).name is null then (oc).value
                                            else (c).value
                                        end
                                    )
                                from
                                    unnest(columns) c
                                    full outer join unnest(old_columns) oc
                                        on (c).name = (oc).name
                                where
                                    coalesce((c).is_selectable, (oc).is_selectable)
                                    and (working_selected_columns is null or coalesce((c).name, (oc).name) = any(working_selected_columns) or coalesce((c).is_pkey, (oc).is_pkey))
                                    and ( not error_record_exceeds_max_size or (octet_length((c).value::text) <= 64))
                            )
                        )
                    else '{}'::jsonb
                end
                -- Add "old_record" key for update and delete
                || case
                    when action = 'UPDATE' then
                        jsonb_build_object(
                                'old_record',
                                (
                                    select jsonb_object_agg((c).name, (c).value)
                                    from unnest(old_columns) c
                                    where
                                        (c).is_selectable
                                        and (working_selected_columns is null or (c).name = any(working_selected_columns) or (c).is_pkey)
                                        and ( not error_record_exceeds_max_size or (octet_length((c).value::text) <= 64))
                                )
                            )
                    when action = 'DELETE' then
                        jsonb_build_object(
                            'old_record',
                            (
                                select jsonb_object_agg((c).name, (c).value)
                                from unnest(old_columns) c
                                where
                                    (c).is_selectable
                                    and (working_selected_columns is null or (c).name = any(working_selected_columns) or (c).is_pkey)
                                    and ( not error_record_exceeds_max_size or (octet_length((c).value::text) <= 64))
                                    and ( not is_rls_enabled or (c).is_pkey ) -- if RLS enabled, we can't secure deletes so filter to pkey
                            )
                        )
                    else '{}'::jsonb
                end;

                -- Filter visible_role_sub_ids to those matching the current selected_columns group
                visible_to_subscription_ids = coalesce(
                    (
                        select array_agg(s.subscription_id)
                        from unnest(subscriptions) s
                        where s.claims_role = working_role
                          and (s.selected_columns is not distinct from working_selected_columns)
                          and s.subscription_id = any(visible_role_sub_ids)
                    ),
                    '{}'::uuid[]
                );

                return next (
                    output,
                    is_rls_enabled,
                    visible_to_subscription_ids,
                    case
                        when error_record_exceeds_max_size then array['Error 413: Payload Too Large']
                        else '{}'
                    end
                )::realtime.wal_rls;
            end loop;

        end if;
    end loop;

    perform set_config('role', null, true);
end;
$$;


ALTER FUNCTION realtime.apply_rls(wal jsonb, max_record_bytes integer) OWNER TO supabase_admin;

--
-- Name: broadcast_changes(text, text, text, text, text, record, record, text); Type: FUNCTION; Schema: realtime; Owner: supabase_admin
--

CREATE FUNCTION realtime.broadcast_changes(topic_name text, event_name text, operation text, table_name text, table_schema text, new record, old record, level text DEFAULT 'ROW'::text) RETURNS void
    LANGUAGE plpgsql
    AS $$
DECLARE
    -- Declare a variable to hold the JSONB representation of the row
    row_data jsonb := '{}'::jsonb;
BEGIN
    IF level = 'STATEMENT' THEN
        RAISE EXCEPTION 'function can only be triggered for each row, not for each statement';
    END IF;
    -- Check the operation type and handle accordingly
    IF operation = 'INSERT' OR operation = 'UPDATE' OR operation = 'DELETE' THEN
        row_data := jsonb_build_object('old_record', OLD, 'record', NEW, 'operation', operation, 'table', table_name, 'schema', table_schema);
        PERFORM realtime.send (row_data, event_name, topic_name);
    ELSE
        RAISE EXCEPTION 'Unexpected operation type: %', operation;
    END IF;
EXCEPTION
    WHEN OTHERS THEN
        RAISE EXCEPTION 'Failed to process the row: %', SQLERRM;
END;

$$;


ALTER FUNCTION realtime.broadcast_changes(topic_name text, event_name text, operation text, table_name text, table_schema text, new record, old record, level text) OWNER TO supabase_admin;

--
-- Name: build_prepared_statement_sql(text, regclass, realtime.wal_column[]); Type: FUNCTION; Schema: realtime; Owner: supabase_admin
--

CREATE FUNCTION realtime.build_prepared_statement_sql(prepared_statement_name text, entity regclass, columns realtime.wal_column[]) RETURNS text
    LANGUAGE sql
    AS $$
      /*
      Builds a sql string that, if executed, creates a prepared statement to
      tests retrive a row from *entity* by its primary key columns.
      Example
          select realtime.build_prepared_statement_sql('public.notes', '{"id"}'::text[], '{"bigint"}'::text[])
      */
          select
      'prepare ' || prepared_statement_name || ' as
          select
              exists(
                  select
                      1
                  from
                      ' || entity || '
                  where
                      ' || string_agg(quote_ident(pkc.name) || '=' || quote_nullable(pkc.value #>> '{}') , ' and ') || '
              )'
          from
              unnest(columns) pkc
          where
              pkc.is_pkey
          group by
              entity
      $$;


ALTER FUNCTION realtime.build_prepared_statement_sql(prepared_statement_name text, entity regclass, columns realtime.wal_column[]) OWNER TO supabase_admin;

--
-- Name: cast(text, regtype); Type: FUNCTION; Schema: realtime; Owner: supabase_admin
--

CREATE FUNCTION realtime."cast"(val text, type_ regtype) RETURNS jsonb
    LANGUAGE plpgsql IMMUTABLE
    AS $$
declare
  res jsonb;
begin
  if type_::text = 'bytea' then
    return to_jsonb(val);
  end if;
  execute format('select to_jsonb(%L::'|| type_::text || ')', val) into res;
  return res;
end
$$;


ALTER FUNCTION realtime."cast"(val text, type_ regtype) OWNER TO supabase_admin;

--
-- Name: check_equality_op(realtime.equality_op, regtype, text, text); Type: FUNCTION; Schema: realtime; Owner: supabase_admin
--

CREATE FUNCTION realtime.check_equality_op(op realtime.equality_op, type_ regtype, val_1 text, val_2 text) RETURNS boolean
    LANGUAGE plpgsql IMMUTABLE
    AS $$
      /*
      Casts *val_1* and *val_2* as type *type_* and check the *op* condition for truthiness
      */
      declare
          op_symbol text = (
              case
                  when op = 'eq' then '='
                  when op = 'neq' then '!='
                  when op = 'lt' then '<'
                  when op = 'lte' then '<='
                  when op = 'gt' then '>'
                  when op = 'gte' then '>='
                  when op = 'in' then '= any'
                  else 'UNKNOWN OP'
              end
          );
          res boolean;
      begin
          execute format(
              'select %L::'|| type_::text || ' ' || op_symbol
              || ' ( %L::'
              || (
                  case
                      when op = 'in' then type_::text || '[]'
                      else type_::text end
              )
              || ')', val_1, val_2) into res;
          return res;
      end;
      $$;


ALTER FUNCTION realtime.check_equality_op(op realtime.equality_op, type_ regtype, val_1 text, val_2 text) OWNER TO supabase_admin;

--
-- Name: is_visible_through_filters(realtime.wal_column[], realtime.user_defined_filter[]); Type: FUNCTION; Schema: realtime; Owner: supabase_admin
--

CREATE FUNCTION realtime.is_visible_through_filters(columns realtime.wal_column[], filters realtime.user_defined_filter[]) RETURNS boolean
    LANGUAGE sql IMMUTABLE
    AS $_$
    /*
    Should the record be visible (true) or filtered out (false) after *filters* are applied
    */
        select
            -- Default to allowed when no filters present
            $2 is null -- no filters. this should not happen because subscriptions has a default
            or array_length($2, 1) is null -- array length of an empty array is null
            or bool_and(
                coalesce(
                    realtime.check_equality_op(
                        op:=f.op,
                        type_:=coalesce(
                            col.type_oid::regtype, -- null when wal2json version <= 2.4
                            col.type_name::regtype
                        ),
                        -- cast jsonb to text
                        val_1:=col.value #>> '{}',
                        val_2:=f.value
                    ),
                    false -- if null, filter does not match
                )
            )
        from
            unnest(filters) f
            join unnest(columns) col
                on f.column_name = col.name;
    $_$;


ALTER FUNCTION realtime.is_visible_through_filters(columns realtime.wal_column[], filters realtime.user_defined_filter[]) OWNER TO supabase_admin;

--
-- Name: list_changes(name, name, integer, integer); Type: FUNCTION; Schema: realtime; Owner: supabase_admin
--

CREATE FUNCTION realtime.list_changes(publication name, slot_name name, max_changes integer, max_record_bytes integer) RETURNS TABLE(wal jsonb, is_rls_enabled boolean, subscription_ids uuid[], errors text[], slot_changes_count bigint)
    LANGUAGE sql
    SET log_min_messages TO 'fatal'
    AS $$
  WITH pub AS (
    SELECT
      concat_ws(
        ',',
        CASE WHEN bool_or(pubinsert) THEN 'insert' ELSE NULL END,
        CASE WHEN bool_or(pubupdate) THEN 'update' ELSE NULL END,
        CASE WHEN bool_or(pubdelete) THEN 'delete' ELSE NULL END
      ) AS w2j_actions,
      coalesce(
        string_agg(
          realtime.quote_wal2json(format('%I.%I', schemaname, tablename)::regclass),
          ','
        ) filter (WHERE ppt.tablename IS NOT NULL),
        ''
      ) AS w2j_add_tables
    FROM pg_publication pp
    LEFT JOIN pg_publication_tables ppt ON pp.pubname = ppt.pubname
    WHERE pp.pubname = publication
    GROUP BY pp.pubname
    LIMIT 1
  ),
  -- MATERIALIZED ensures pg_logical_slot_get_changes is called exactly once
  w2j AS MATERIALIZED (
    SELECT x.*, pub.w2j_add_tables
    FROM pub,
         pg_logical_slot_get_changes(
           slot_name, null, max_changes,
           'include-pk', 'true',
           'include-transaction', 'false',
           'include-timestamp', 'true',
           'include-type-oids', 'true',
           'format-version', '2',
           'actions', pub.w2j_actions,
           'add-tables', pub.w2j_add_tables
         ) x
  ),
  slot_count AS (
    SELECT count(*)::bigint AS cnt
    FROM w2j
    WHERE w2j.w2j_add_tables <> ''
  ),
  rls_filtered AS (
    SELECT xyz.wal, xyz.is_rls_enabled, xyz.subscription_ids, xyz.errors
    FROM w2j,
         realtime.apply_rls(
           wal := w2j.data::jsonb,
           max_record_bytes := max_record_bytes
         ) xyz(wal, is_rls_enabled, subscription_ids, errors)
    WHERE w2j.w2j_add_tables <> ''
      AND xyz.subscription_ids[1] IS NOT NULL
  )
  SELECT rf.wal, rf.is_rls_enabled, rf.subscription_ids, rf.errors, sc.cnt
  FROM rls_filtered rf, slot_count sc

  UNION ALL

  SELECT null, null, null, null, sc.cnt
  FROM slot_count sc
  WHERE NOT EXISTS (SELECT 1 FROM rls_filtered)
$$;


ALTER FUNCTION realtime.list_changes(publication name, slot_name name, max_changes integer, max_record_bytes integer) OWNER TO supabase_admin;

--
-- Name: quote_wal2json(regclass); Type: FUNCTION; Schema: realtime; Owner: supabase_admin
--

CREATE FUNCTION realtime.quote_wal2json(entity regclass) RETURNS text
    LANGUAGE sql IMMUTABLE STRICT
    AS $$
  SELECT
    realtime.wal2json_escape_identifier(nsp.nspname::text)
    || '.'
    || realtime.wal2json_escape_identifier(pc.relname::text)
  FROM pg_class pc
  JOIN pg_namespace nsp ON pc.relnamespace = nsp.oid
  WHERE pc.oid = entity
$$;


ALTER FUNCTION realtime.quote_wal2json(entity regclass) OWNER TO supabase_admin;

--
-- Name: send(jsonb, text, text, boolean); Type: FUNCTION; Schema: realtime; Owner: supabase_admin
--

CREATE FUNCTION realtime.send(payload jsonb, event text, topic text, private boolean DEFAULT true) RETURNS void
    LANGUAGE plpgsql
    AS $$
DECLARE
  generated_id uuid;
  final_payload jsonb;
BEGIN
  BEGIN
    -- Generate a new UUID for the id
    generated_id := gen_random_uuid();

    -- Check if payload has an 'id' key, if not, add the generated UUID
    IF payload ? 'id' THEN
      final_payload := payload;
    ELSE
      final_payload := jsonb_set(payload, '{id}', to_jsonb(generated_id));
    END IF;

    -- Set the topic configuration
    EXECUTE format('SET LOCAL realtime.topic TO %L', topic);

    -- Attempt to insert the message
    INSERT INTO realtime.messages (id, payload, event, topic, private, extension)
    VALUES (generated_id, final_payload, event, topic, private, 'broadcast');
  EXCEPTION
    WHEN OTHERS THEN
      -- Capture and notify the error
      RAISE WARNING 'ErrorSendingBroadcastMessage: %', SQLERRM;
  END;
END;
$$;


ALTER FUNCTION realtime.send(payload jsonb, event text, topic text, private boolean) OWNER TO supabase_admin;

--
-- Name: send_binary(bytea, text, text, boolean); Type: FUNCTION; Schema: realtime; Owner: supabase_admin
--

CREATE FUNCTION realtime.send_binary(payload bytea, event text, topic text, private boolean DEFAULT true) RETURNS void
    LANGUAGE plpgsql
    AS $$
DECLARE
  generated_id uuid;
BEGIN
  BEGIN
    generated_id := gen_random_uuid();

    EXECUTE format('SET LOCAL realtime.topic TO %L', topic);

    INSERT INTO realtime.messages (id, binary_payload, event, topic, private, extension)
    VALUES (generated_id, payload, event, topic, private, 'broadcast');
  EXCEPTION
    WHEN OTHERS THEN
      RAISE WARNING 'ErrorSendingBroadcastMessage: %', SQLERRM;
  END;
END;
$$;


ALTER FUNCTION realtime.send_binary(payload bytea, event text, topic text, private boolean) OWNER TO supabase_admin;

--
-- Name: subscription_check_filters(); Type: FUNCTION; Schema: realtime; Owner: supabase_admin
--

CREATE FUNCTION realtime.subscription_check_filters() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
declare
    col_names text[] = coalesce(
            array_agg(c.column_name order by c.ordinal_position),
            '{}'::text[]
        )
        from
            information_schema.columns c
        where
            format('%I.%I', c.table_schema, c.table_name)::regclass = new.entity
            and pg_catalog.has_column_privilege(
                (new.claims ->> 'role'),
                format('%I.%I', c.table_schema, c.table_name)::regclass,
                c.column_name,
                'SELECT'
            );
    table_col_names text[] = coalesce(
            array_agg(pa.attname),
            '{}'::text[]
        )
        from
            pg_attribute pa
        where
            pa.attrelid = new.entity
            and pa.attnum > 0;
    filter realtime.user_defined_filter;
    col_type regtype;
    in_val jsonb;
    selected_col text;
begin
    for filter in select * from unnest(new.filters) loop
        -- Filtered column is valid
        if not filter.column_name = any(col_names) then
            raise exception 'invalid column for filter %', filter.column_name;
        end if;

        -- Type is sanitized and safe for string interpolation
        col_type = (
            select atttypid::regtype
            from pg_catalog.pg_attribute
            where attrelid = new.entity
                  and attname = filter.column_name
        );
        if col_type is null then
            raise exception 'failed to lookup type for column %', filter.column_name;
        end if;
        if filter.op = 'in'::realtime.equality_op then
            in_val = realtime.cast(filter.value, (col_type::text || '[]')::regtype);
            if coalesce(jsonb_array_length(in_val), 0) > 100 then
                raise exception 'too many values for `in` filter. Maximum 100';
            end if;
        else
            -- raises an exception if value is not coercable to type
            perform realtime.cast(filter.value, col_type);
        end if;
    end loop;

    -- Validate that selected_columns reference columns the role can SELECT
    if new.selected_columns is not null then
        for selected_col in select * from unnest(new.selected_columns) loop
            if not selected_col = any(col_names) then
                raise exception 'invalid column for select %', selected_col;
            end if;
        end loop;
    end if;

    -- Apply consistent order to filters so the unique constraint on
    -- (subscription_id, entity, filters) can't be tricked by a different filter order
    new.filters = coalesce(
        array_agg(f order by f.column_name, f.op, f.value),
        '{}'
    ) from unnest(new.filters) f;

    -- Normalize selected_columns order so ARRAY['a','b'] and ARRAY['b','a'] are
    -- treated as the same subscription group in apply_rls
    new.selected_columns = (
        select array_agg(c order by c)
        from unnest(new.selected_columns) c
    );

    return new;
end;
$$;


ALTER FUNCTION realtime.subscription_check_filters() OWNER TO supabase_admin;

--
-- Name: to_regrole(text); Type: FUNCTION; Schema: realtime; Owner: supabase_admin
--

CREATE FUNCTION realtime.to_regrole(role_name text) RETURNS regrole
    LANGUAGE sql IMMUTABLE
    AS $$ select role_name::regrole $$;


ALTER FUNCTION realtime.to_regrole(role_name text) OWNER TO supabase_admin;

--
-- Name: topic(); Type: FUNCTION; Schema: realtime; Owner: supabase_realtime_admin
--

CREATE FUNCTION realtime.topic() RETURNS text
    LANGUAGE sql STABLE
    AS $$
select nullif(current_setting('realtime.topic', true), '')::text;
$$;


ALTER FUNCTION realtime.topic() OWNER TO supabase_realtime_admin;

--
-- Name: wal2json_escape_identifier(text); Type: FUNCTION; Schema: realtime; Owner: supabase_admin
--

CREATE FUNCTION realtime.wal2json_escape_identifier(name text) RETURNS text
    LANGUAGE sql IMMUTABLE STRICT
    AS $$
  -- Prefix `\`, `,`, `.`, and any whitespace with `\`
  SELECT regexp_replace(name, '([\\,.[:space:]])', '\\\1', 'g')
$$;


ALTER FUNCTION realtime.wal2json_escape_identifier(name text) OWNER TO supabase_admin;

--
-- Name: allow_any_operation(text[]); Type: FUNCTION; Schema: storage; Owner: supabase_storage_admin
--

CREATE FUNCTION storage.allow_any_operation(expected_operations text[]) RETURNS boolean
    LANGUAGE sql STABLE
    AS $$
  WITH current_operation AS (
    SELECT storage.operation() AS raw_operation
  ),
  normalized AS (
    SELECT CASE
      WHEN raw_operation LIKE 'storage.%' THEN substr(raw_operation, 9)
      ELSE raw_operation
    END AS current_operation
    FROM current_operation
  )
  SELECT EXISTS (
    SELECT 1
    FROM normalized n
    CROSS JOIN LATERAL unnest(expected_operations) AS expected_operation
    WHERE expected_operation IS NOT NULL
      AND expected_operation <> ''
      AND n.current_operation = CASE
        WHEN expected_operation LIKE 'storage.%' THEN substr(expected_operation, 9)
        ELSE expected_operation
      END
  );
$$;


ALTER FUNCTION storage.allow_any_operation(expected_operations text[]) OWNER TO supabase_storage_admin;

--
-- Name: allow_only_operation(text); Type: FUNCTION; Schema: storage; Owner: supabase_storage_admin
--

CREATE FUNCTION storage.allow_only_operation(expected_operation text) RETURNS boolean
    LANGUAGE sql STABLE
    AS $$
  WITH current_operation AS (
    SELECT storage.operation() AS raw_operation
  ),
  normalized AS (
    SELECT
      CASE
        WHEN raw_operation LIKE 'storage.%' THEN substr(raw_operation, 9)
        ELSE raw_operation
      END AS current_operation,
      CASE
        WHEN expected_operation LIKE 'storage.%' THEN substr(expected_operation, 9)
        ELSE expected_operation
      END AS requested_operation
    FROM current_operation
  )
  SELECT CASE
    WHEN requested_operation IS NULL OR requested_operation = '' THEN FALSE
    ELSE COALESCE(current_operation = requested_operation, FALSE)
  END
  FROM normalized;
$$;


ALTER FUNCTION storage.allow_only_operation(expected_operation text) OWNER TO supabase_storage_admin;

--
-- Name: can_insert_object(text, text, uuid, jsonb); Type: FUNCTION; Schema: storage; Owner: supabase_storage_admin
--

CREATE FUNCTION storage.can_insert_object(bucketid text, name text, owner uuid, metadata jsonb) RETURNS void
    LANGUAGE plpgsql
    AS $$
BEGIN
  INSERT INTO "storage"."objects" ("bucket_id", "name", "owner", "metadata") VALUES (bucketid, name, owner, metadata);
  -- hack to rollback the successful insert
  RAISE sqlstate 'PT200' using
  message = 'ROLLBACK',
  detail = 'rollback successful insert';
END
$$;


ALTER FUNCTION storage.can_insert_object(bucketid text, name text, owner uuid, metadata jsonb) OWNER TO supabase_storage_admin;

--
-- Name: enforce_bucket_name_length(); Type: FUNCTION; Schema: storage; Owner: supabase_storage_admin
--

CREATE FUNCTION storage.enforce_bucket_name_length() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
begin
    if length(new.name) > 100 then
        raise exception 'bucket name "%" is too long (% characters). Max is 100.', new.name, length(new.name);
    end if;
    return new;
end;
$$;


ALTER FUNCTION storage.enforce_bucket_name_length() OWNER TO supabase_storage_admin;

--
-- Name: extension(text); Type: FUNCTION; Schema: storage; Owner: supabase_storage_admin
--

CREATE FUNCTION storage.extension(name text) RETURNS text
    LANGUAGE plpgsql IMMUTABLE
    AS $$
DECLARE
    _parts text[];
    _filename text;
BEGIN
    -- Split on "/" to get path segments
    SELECT string_to_array(name, '/') INTO _parts;
    -- Get the last path segment (the actual filename)
    SELECT _parts[array_length(_parts, 1)] INTO _filename;
    -- Extract extension: reverse, split on '.', then reverse again
    RETURN reverse(split_part(reverse(_filename), '.', 1));
END
$$;


ALTER FUNCTION storage.extension(name text) OWNER TO supabase_storage_admin;

--
-- Name: filename(text); Type: FUNCTION; Schema: storage; Owner: supabase_storage_admin
--

CREATE FUNCTION storage.filename(name text) RETURNS text
    LANGUAGE plpgsql
    AS $$
DECLARE
_parts text[];
BEGIN
	select string_to_array(name, '/') into _parts;
	return _parts[array_length(_parts,1)];
END
$$;


ALTER FUNCTION storage.filename(name text) OWNER TO supabase_storage_admin;

--
-- Name: foldername(text); Type: FUNCTION; Schema: storage; Owner: supabase_storage_admin
--

CREATE FUNCTION storage.foldername(name text) RETURNS text[]
    LANGUAGE plpgsql IMMUTABLE
    AS $$
DECLARE
    _parts text[];
BEGIN
    -- Split on "/" to get path segments
    SELECT string_to_array(name, '/') INTO _parts;
    -- Return everything except the last segment
    RETURN _parts[1 : array_length(_parts,1) - 1];
END
$$;


ALTER FUNCTION storage.foldername(name text) OWNER TO supabase_storage_admin;

--
-- Name: get_common_prefix(text, text, text); Type: FUNCTION; Schema: storage; Owner: supabase_storage_admin
--

CREATE FUNCTION storage.get_common_prefix(p_key text, p_prefix text, p_delimiter text) RETURNS text
    LANGUAGE sql IMMUTABLE
    AS $$
SELECT CASE
    WHEN position(p_delimiter IN substring(p_key FROM length(p_prefix) + 1)) > 0
    THEN left(p_key, length(p_prefix) + position(p_delimiter IN substring(p_key FROM length(p_prefix) + 1)))
    ELSE NULL
END;
$$;


ALTER FUNCTION storage.get_common_prefix(p_key text, p_prefix text, p_delimiter text) OWNER TO supabase_storage_admin;

--
-- Name: get_size_by_bucket(); Type: FUNCTION; Schema: storage; Owner: supabase_storage_admin
--

CREATE FUNCTION storage.get_size_by_bucket() RETURNS TABLE(size bigint, bucket_id text)
    LANGUAGE plpgsql STABLE
    AS $$
BEGIN
    return query
        select sum((metadata->>'size')::bigint)::bigint as size, obj.bucket_id
        from "storage".objects as obj
        group by obj.bucket_id;
END
$$;


ALTER FUNCTION storage.get_size_by_bucket() OWNER TO supabase_storage_admin;

--
-- Name: list_multipart_uploads_with_delimiter(text, text, text, integer, text, text); Type: FUNCTION; Schema: storage; Owner: supabase_storage_admin
--

CREATE FUNCTION storage.list_multipart_uploads_with_delimiter(bucket_id text, prefix_param text, delimiter_param text, max_keys integer DEFAULT 100, next_key_token text DEFAULT ''::text, next_upload_token text DEFAULT ''::text) RETURNS TABLE(key text, id text, created_at timestamp with time zone)
    LANGUAGE plpgsql
    AS $_$
BEGIN
    RETURN QUERY EXECUTE
        'SELECT DISTINCT ON(key COLLATE "C") * from (
            SELECT
                CASE
                    WHEN position($2 IN substring(key from length($1) + 1)) > 0 THEN
                        substring(key from 1 for length($1) + position($2 IN substring(key from length($1) + 1)))
                    ELSE
                        key
                END AS key, id, created_at
            FROM
                storage.s3_multipart_uploads
            WHERE
                bucket_id = $5 AND
                key ILIKE $1 || ''%'' AND
                CASE
                    WHEN $4 != '''' AND $6 = '''' THEN
                        CASE
                            WHEN position($2 IN substring(key from length($1) + 1)) > 0 THEN
                                substring(key from 1 for length($1) + position($2 IN substring(key from length($1) + 1))) COLLATE "C" > $4
                            ELSE
                                key COLLATE "C" > $4
                            END
                    ELSE
                        true
                END AND
                CASE
                    WHEN $6 != '''' THEN
                        id COLLATE "C" > $6
                    ELSE
                        true
                    END
            ORDER BY
                key COLLATE "C" ASC, created_at ASC) as e order by key COLLATE "C" LIMIT $3'
        USING prefix_param, delimiter_param, max_keys, next_key_token, bucket_id, next_upload_token;
END;
$_$;


ALTER FUNCTION storage.list_multipart_uploads_with_delimiter(bucket_id text, prefix_param text, delimiter_param text, max_keys integer, next_key_token text, next_upload_token text) OWNER TO supabase_storage_admin;

--
-- Name: list_objects_with_delimiter(text, text, text, integer, text, text, text); Type: FUNCTION; Schema: storage; Owner: supabase_storage_admin
--

CREATE FUNCTION storage.list_objects_with_delimiter(_bucket_id text, prefix_param text, delimiter_param text, max_keys integer DEFAULT 100, start_after text DEFAULT ''::text, next_token text DEFAULT ''::text, sort_order text DEFAULT 'asc'::text) RETURNS TABLE(name text, id uuid, metadata jsonb, updated_at timestamp with time zone, created_at timestamp with time zone, last_accessed_at timestamp with time zone)
    LANGUAGE plpgsql STABLE
    AS $_$
DECLARE
    v_peek_name TEXT;
    v_current RECORD;
    v_common_prefix TEXT;

    -- Configuration
    v_is_asc BOOLEAN;
    v_prefix TEXT;
    v_start TEXT;
    v_upper_bound TEXT;
    v_file_batch_size INT;

    -- Seek state
    v_next_seek TEXT;
    v_count INT := 0;

    -- Dynamic SQL for batch query only
    v_batch_query TEXT;

BEGIN
    -- ========================================================================
    -- INITIALIZATION
    -- ========================================================================
    v_is_asc := lower(coalesce(sort_order, 'asc')) = 'asc';
    v_prefix := coalesce(prefix_param, '');
    v_start := CASE WHEN coalesce(next_token, '') <> '' THEN next_token ELSE coalesce(start_after, '') END;
    v_file_batch_size := LEAST(GREATEST(max_keys * 2, 100), 1000);

    -- Calculate upper bound for prefix filtering (bytewise, using COLLATE "C")
    IF v_prefix = '' THEN
        v_upper_bound := NULL;
    ELSIF right(v_prefix, 1) = delimiter_param THEN
        v_upper_bound := left(v_prefix, -1) || chr(ascii(delimiter_param) + 1);
    ELSE
        v_upper_bound := left(v_prefix, -1) || chr(ascii(right(v_prefix, 1)) + 1);
    END IF;

    -- Build batch query (dynamic SQL - called infrequently, amortized over many rows)
    IF v_is_asc THEN
        IF v_upper_bound IS NOT NULL THEN
            v_batch_query := 'SELECT o.name, o.id, o.updated_at, o.created_at, o.last_accessed_at, o.metadata ' ||
                'FROM storage.objects o WHERE o.bucket_id = $1 AND o.name COLLATE "C" >= $2 ' ||
                'AND o.name COLLATE "C" < $3 ORDER BY o.name COLLATE "C" ASC LIMIT $4';
        ELSE
            v_batch_query := 'SELECT o.name, o.id, o.updated_at, o.created_at, o.last_accessed_at, o.metadata ' ||
                'FROM storage.objects o WHERE o.bucket_id = $1 AND o.name COLLATE "C" >= $2 ' ||
                'ORDER BY o.name COLLATE "C" ASC LIMIT $4';
        END IF;
    ELSE
        IF v_upper_bound IS NOT NULL THEN
            v_batch_query := 'SELECT o.name, o.id, o.updated_at, o.created_at, o.last_accessed_at, o.metadata ' ||
                'FROM storage.objects o WHERE o.bucket_id = $1 AND o.name COLLATE "C" < $2 ' ||
                'AND o.name COLLATE "C" >= $3 ORDER BY o.name COLLATE "C" DESC LIMIT $4';
        ELSE
            v_batch_query := 'SELECT o.name, o.id, o.updated_at, o.created_at, o.last_accessed_at, o.metadata ' ||
                'FROM storage.objects o WHERE o.bucket_id = $1 AND o.name COLLATE "C" < $2 ' ||
                'ORDER BY o.name COLLATE "C" DESC LIMIT $4';
        END IF;
    END IF;

    -- ========================================================================
    -- SEEK INITIALIZATION: Determine starting position
    -- ========================================================================
    IF v_start = '' THEN
        IF v_is_asc THEN
            v_next_seek := v_prefix;
        ELSE
            -- DESC without cursor: find the last item in range
            IF v_upper_bound IS NOT NULL THEN
                SELECT o.name INTO v_next_seek FROM storage.objects o
                WHERE o.bucket_id = _bucket_id AND o.name COLLATE "C" >= v_prefix AND o.name COLLATE "C" < v_upper_bound
                ORDER BY o.name COLLATE "C" DESC LIMIT 1;
            ELSIF v_prefix <> '' THEN
                SELECT o.name INTO v_next_seek FROM storage.objects o
                WHERE o.bucket_id = _bucket_id AND o.name COLLATE "C" >= v_prefix
                ORDER BY o.name COLLATE "C" DESC LIMIT 1;
            ELSE
                SELECT o.name INTO v_next_seek FROM storage.objects o
                WHERE o.bucket_id = _bucket_id
                ORDER BY o.name COLLATE "C" DESC LIMIT 1;
            END IF;

            IF v_next_seek IS NOT NULL THEN
                v_next_seek := v_next_seek || delimiter_param;
            ELSE
                RETURN;
            END IF;
        END IF;
    ELSE
        -- Cursor provided: determine if it refers to a folder or leaf
        IF EXISTS (
            SELECT 1 FROM storage.objects o
            WHERE o.bucket_id = _bucket_id
              AND o.name COLLATE "C" LIKE v_start || delimiter_param || '%'
            LIMIT 1
        ) THEN
            -- Cursor refers to a folder
            IF v_is_asc THEN
                v_next_seek := v_start || chr(ascii(delimiter_param) + 1);
            ELSE
                v_next_seek := v_start || delimiter_param;
            END IF;
        ELSE
            -- Cursor refers to a leaf object
            IF v_is_asc THEN
                v_next_seek := v_start || delimiter_param;
            ELSE
                v_next_seek := v_start;
            END IF;
        END IF;
    END IF;

    -- ========================================================================
    -- MAIN LOOP: Hybrid peek-then-batch algorithm
    -- Uses STATIC SQL for peek (hot path) and DYNAMIC SQL for batch
    -- ========================================================================
    LOOP
        EXIT WHEN v_count >= max_keys;

        -- STEP 1: PEEK using STATIC SQL (plan cached, very fast)
        IF v_is_asc THEN
            IF v_upper_bound IS NOT NULL THEN
                SELECT o.name INTO v_peek_name FROM storage.objects o
                WHERE o.bucket_id = _bucket_id AND o.name COLLATE "C" >= v_next_seek AND o.name COLLATE "C" < v_upper_bound
                ORDER BY o.name COLLATE "C" ASC LIMIT 1;
            ELSE
                SELECT o.name INTO v_peek_name FROM storage.objects o
                WHERE o.bucket_id = _bucket_id AND o.name COLLATE "C" >= v_next_seek
                ORDER BY o.name COLLATE "C" ASC LIMIT 1;
            END IF;
        ELSE
            IF v_upper_bound IS NOT NULL THEN
                SELECT o.name INTO v_peek_name FROM storage.objects o
                WHERE o.bucket_id = _bucket_id AND o.name COLLATE "C" < v_next_seek AND o.name COLLATE "C" >= v_prefix
                ORDER BY o.name COLLATE "C" DESC LIMIT 1;
            ELSIF v_prefix <> '' THEN
                SELECT o.name INTO v_peek_name FROM storage.objects o
                WHERE o.bucket_id = _bucket_id AND o.name COLLATE "C" < v_next_seek AND o.name COLLATE "C" >= v_prefix
                ORDER BY o.name COLLATE "C" DESC LIMIT 1;
            ELSE
                SELECT o.name INTO v_peek_name FROM storage.objects o
                WHERE o.bucket_id = _bucket_id AND o.name COLLATE "C" < v_next_seek
                ORDER BY o.name COLLATE "C" DESC LIMIT 1;
            END IF;
        END IF;

        EXIT WHEN v_peek_name IS NULL;

        -- STEP 2: Check if this is a FOLDER or FILE
        v_common_prefix := storage.get_common_prefix(v_peek_name, v_prefix, delimiter_param);

        IF v_common_prefix IS NOT NULL THEN
            -- FOLDER: Emit and skip to next folder (no heap access needed)
            name := rtrim(v_common_prefix, delimiter_param);
            id := NULL;
            updated_at := NULL;
            created_at := NULL;
            last_accessed_at := NULL;
            metadata := NULL;
            RETURN NEXT;
            v_count := v_count + 1;

            -- Advance seek past the folder range
            IF v_is_asc THEN
                v_next_seek := left(v_common_prefix, -1) || chr(ascii(delimiter_param) + 1);
            ELSE
                v_next_seek := v_common_prefix;
            END IF;
        ELSE
            -- FILE: Batch fetch using DYNAMIC SQL (overhead amortized over many rows)
            -- For ASC: upper_bound is the exclusive upper limit (< condition)
            -- For DESC: prefix is the inclusive lower limit (>= condition)
            FOR v_current IN EXECUTE v_batch_query USING _bucket_id, v_next_seek,
                CASE WHEN v_is_asc THEN COALESCE(v_upper_bound, v_prefix) ELSE v_prefix END, v_file_batch_size
            LOOP
                v_common_prefix := storage.get_common_prefix(v_current.name, v_prefix, delimiter_param);

                IF v_common_prefix IS NOT NULL THEN
                    -- Hit a folder: exit batch, let peek handle it
                    v_next_seek := v_current.name;
                    EXIT;
                END IF;

                -- Emit file
                name := v_current.name;
                id := v_current.id;
                updated_at := v_current.updated_at;
                created_at := v_current.created_at;
                last_accessed_at := v_current.last_accessed_at;
                metadata := v_current.metadata;
                RETURN NEXT;
                v_count := v_count + 1;

                -- Advance seek past this file
                IF v_is_asc THEN
                    v_next_seek := v_current.name || delimiter_param;
                ELSE
                    v_next_seek := v_current.name;
                END IF;

                EXIT WHEN v_count >= max_keys;
            END LOOP;
        END IF;
    END LOOP;
END;
$_$;


ALTER FUNCTION storage.list_objects_with_delimiter(_bucket_id text, prefix_param text, delimiter_param text, max_keys integer, start_after text, next_token text, sort_order text) OWNER TO supabase_storage_admin;

--
-- Name: operation(); Type: FUNCTION; Schema: storage; Owner: supabase_storage_admin
--

CREATE FUNCTION storage.operation() RETURNS text
    LANGUAGE plpgsql STABLE
    AS $$
BEGIN
    RETURN current_setting('storage.operation', true);
END;
$$;


ALTER FUNCTION storage.operation() OWNER TO supabase_storage_admin;

--
-- Name: protect_delete(); Type: FUNCTION; Schema: storage; Owner: supabase_storage_admin
--

CREATE FUNCTION storage.protect_delete() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
BEGIN
    -- Check if storage.allow_delete_query is set to 'true'
    IF COALESCE(current_setting('storage.allow_delete_query', true), 'false') != 'true' THEN
        RAISE EXCEPTION 'Direct deletion from storage tables is not allowed. Use the Storage API instead.'
            USING HINT = 'This prevents accidental data loss from orphaned objects.',
                  ERRCODE = '42501';
    END IF;
    RETURN NULL;
END;
$$;


ALTER FUNCTION storage.protect_delete() OWNER TO supabase_storage_admin;

--
-- Name: search(text, text, integer, integer, integer, text, text, text); Type: FUNCTION; Schema: storage; Owner: supabase_storage_admin
--

CREATE FUNCTION storage.search(prefix text, bucketname text, limits integer DEFAULT 100, levels integer DEFAULT 1, offsets integer DEFAULT 0, search text DEFAULT ''::text, sortcolumn text DEFAULT 'name'::text, sortorder text DEFAULT 'asc'::text) RETURNS TABLE(name text, id uuid, updated_at timestamp with time zone, created_at timestamp with time zone, last_accessed_at timestamp with time zone, metadata jsonb)
    LANGUAGE plpgsql STABLE
    AS $_$
DECLARE
    v_peek_name TEXT;
    v_current RECORD;
    v_common_prefix TEXT;
    v_delimiter CONSTANT TEXT := '/';

    -- Configuration
    v_limit INT;
    v_prefix TEXT;
    v_prefix_lower TEXT;
    v_is_asc BOOLEAN;
    v_order_by TEXT;
    v_sort_order TEXT;
    v_upper_bound TEXT;
    v_file_batch_size INT;

    -- Dynamic SQL for batch query only
    v_batch_query TEXT;

    -- Seek state
    v_next_seek TEXT;
    v_count INT := 0;
    v_skipped INT := 0;
BEGIN
    -- ========================================================================
    -- INITIALIZATION
    -- ========================================================================
    v_limit := LEAST(coalesce(limits, 100), 1500);
    v_prefix := coalesce(prefix, '') || coalesce(search, '');
    v_prefix_lower := lower(v_prefix);
    v_is_asc := lower(coalesce(sortorder, 'asc')) = 'asc';
    v_file_batch_size := LEAST(GREATEST(v_limit * 2, 100), 1000);

    -- Validate sort column
    CASE lower(coalesce(sortcolumn, 'name'))
        WHEN 'name' THEN v_order_by := 'name';
        WHEN 'updated_at' THEN v_order_by := 'updated_at';
        WHEN 'created_at' THEN v_order_by := 'created_at';
        WHEN 'last_accessed_at' THEN v_order_by := 'last_accessed_at';
        ELSE v_order_by := 'name';
    END CASE;

    v_sort_order := CASE WHEN v_is_asc THEN 'asc' ELSE 'desc' END;

    -- ========================================================================
    -- NON-NAME SORTING: Use path_tokens approach (unchanged)
    -- ========================================================================
    IF v_order_by != 'name' THEN
        RETURN QUERY EXECUTE format(
            $sql$
            WITH folders AS (
                SELECT path_tokens[$1] AS folder
                FROM storage.objects
                WHERE objects.name ILIKE $2 || '%%'
                  AND bucket_id = $3
                  AND array_length(objects.path_tokens, 1) <> $1
                GROUP BY folder
                ORDER BY folder %s
            )
            (SELECT folder AS "name",
                   NULL::uuid AS id,
                   NULL::timestamptz AS updated_at,
                   NULL::timestamptz AS created_at,
                   NULL::timestamptz AS last_accessed_at,
                   NULL::jsonb AS metadata FROM folders)
            UNION ALL
            (SELECT path_tokens[$1] AS "name",
                   id, updated_at, created_at, last_accessed_at, metadata
             FROM storage.objects
             WHERE objects.name ILIKE $2 || '%%'
               AND bucket_id = $3
               AND array_length(objects.path_tokens, 1) = $1
             ORDER BY %I %s)
            LIMIT $4 OFFSET $5
            $sql$, v_sort_order, v_order_by, v_sort_order
        ) USING levels, v_prefix, bucketname, v_limit, offsets;
        RETURN;
    END IF;

    -- ========================================================================
    -- NAME SORTING: Hybrid skip-scan with batch optimization
    -- ========================================================================

    -- Calculate upper bound for prefix filtering
    IF v_prefix_lower = '' THEN
        v_upper_bound := NULL;
    ELSIF right(v_prefix_lower, 1) = v_delimiter THEN
        v_upper_bound := left(v_prefix_lower, -1) || chr(ascii(v_delimiter) + 1);
    ELSE
        v_upper_bound := left(v_prefix_lower, -1) || chr(ascii(right(v_prefix_lower, 1)) + 1);
    END IF;

    -- Build batch query (dynamic SQL - called infrequently, amortized over many rows)
    IF v_is_asc THEN
        IF v_upper_bound IS NOT NULL THEN
            v_batch_query := 'SELECT o.name, o.id, o.updated_at, o.created_at, o.last_accessed_at, o.metadata ' ||
                'FROM storage.objects o WHERE o.bucket_id = $1 AND lower(o.name) COLLATE "C" >= $2 ' ||
                'AND lower(o.name) COLLATE "C" < $3 ORDER BY lower(o.name) COLLATE "C" ASC LIMIT $4';
        ELSE
            v_batch_query := 'SELECT o.name, o.id, o.updated_at, o.created_at, o.last_accessed_at, o.metadata ' ||
                'FROM storage.objects o WHERE o.bucket_id = $1 AND lower(o.name) COLLATE "C" >= $2 ' ||
                'ORDER BY lower(o.name) COLLATE "C" ASC LIMIT $4';
        END IF;
    ELSE
        IF v_upper_bound IS NOT NULL THEN
            v_batch_query := 'SELECT o.name, o.id, o.updated_at, o.created_at, o.last_accessed_at, o.metadata ' ||
                'FROM storage.objects o WHERE o.bucket_id = $1 AND lower(o.name) COLLATE "C" < $2 ' ||
                'AND lower(o.name) COLLATE "C" >= $3 ORDER BY lower(o.name) COLLATE "C" DESC LIMIT $4';
        ELSE
            v_batch_query := 'SELECT o.name, o.id, o.updated_at, o.created_at, o.last_accessed_at, o.metadata ' ||
                'FROM storage.objects o WHERE o.bucket_id = $1 AND lower(o.name) COLLATE "C" < $2 ' ||
                'ORDER BY lower(o.name) COLLATE "C" DESC LIMIT $4';
        END IF;
    END IF;

    -- Initialize seek position
    IF v_is_asc THEN
        v_next_seek := v_prefix_lower;
    ELSE
        -- DESC: find the last item in range first (static SQL)
        IF v_upper_bound IS NOT NULL THEN
            SELECT o.name INTO v_peek_name FROM storage.objects o
            WHERE o.bucket_id = bucketname AND lower(o.name) COLLATE "C" >= v_prefix_lower AND lower(o.name) COLLATE "C" < v_upper_bound
            ORDER BY lower(o.name) COLLATE "C" DESC LIMIT 1;
        ELSIF v_prefix_lower <> '' THEN
            SELECT o.name INTO v_peek_name FROM storage.objects o
            WHERE o.bucket_id = bucketname AND lower(o.name) COLLATE "C" >= v_prefix_lower
            ORDER BY lower(o.name) COLLATE "C" DESC LIMIT 1;
        ELSE
            SELECT o.name INTO v_peek_name FROM storage.objects o
            WHERE o.bucket_id = bucketname
            ORDER BY lower(o.name) COLLATE "C" DESC LIMIT 1;
        END IF;

        IF v_peek_name IS NOT NULL THEN
            v_next_seek := lower(v_peek_name) || v_delimiter;
        ELSE
            RETURN;
        END IF;
    END IF;

    -- ========================================================================
    -- MAIN LOOP: Hybrid peek-then-batch algorithm
    -- Uses STATIC SQL for peek (hot path) and DYNAMIC SQL for batch
    -- ========================================================================
    LOOP
        EXIT WHEN v_count >= v_limit;

        -- STEP 1: PEEK using STATIC SQL (plan cached, very fast)
        IF v_is_asc THEN
            IF v_upper_bound IS NOT NULL THEN
                SELECT o.name INTO v_peek_name FROM storage.objects o
                WHERE o.bucket_id = bucketname AND lower(o.name) COLLATE "C" >= v_next_seek AND lower(o.name) COLLATE "C" < v_upper_bound
                ORDER BY lower(o.name) COLLATE "C" ASC LIMIT 1;
            ELSE
                SELECT o.name INTO v_peek_name FROM storage.objects o
                WHERE o.bucket_id = bucketname AND lower(o.name) COLLATE "C" >= v_next_seek
                ORDER BY lower(o.name) COLLATE "C" ASC LIMIT 1;
            END IF;
        ELSE
            IF v_upper_bound IS NOT NULL THEN
                SELECT o.name INTO v_peek_name FROM storage.objects o
                WHERE o.bucket_id = bucketname AND lower(o.name) COLLATE "C" < v_next_seek AND lower(o.name) COLLATE "C" >= v_prefix_lower
                ORDER BY lower(o.name) COLLATE "C" DESC LIMIT 1;
            ELSIF v_prefix_lower <> '' THEN
                SELECT o.name INTO v_peek_name FROM storage.objects o
                WHERE o.bucket_id = bucketname AND lower(o.name) COLLATE "C" < v_next_seek AND lower(o.name) COLLATE "C" >= v_prefix_lower
                ORDER BY lower(o.name) COLLATE "C" DESC LIMIT 1;
            ELSE
                SELECT o.name INTO v_peek_name FROM storage.objects o
                WHERE o.bucket_id = bucketname AND lower(o.name) COLLATE "C" < v_next_seek
                ORDER BY lower(o.name) COLLATE "C" DESC LIMIT 1;
            END IF;
        END IF;

        EXIT WHEN v_peek_name IS NULL;

        -- STEP 2: Check if this is a FOLDER or FILE
        v_common_prefix := storage.get_common_prefix(lower(v_peek_name), v_prefix_lower, v_delimiter);

        IF v_common_prefix IS NOT NULL THEN
            -- FOLDER: Handle offset, emit if needed, skip to next folder
            IF v_skipped < offsets THEN
                v_skipped := v_skipped + 1;
            ELSE
                name := split_part(rtrim(storage.get_common_prefix(v_peek_name, v_prefix, v_delimiter), v_delimiter), v_delimiter, levels);
                id := NULL;
                updated_at := NULL;
                created_at := NULL;
                last_accessed_at := NULL;
                metadata := NULL;
                RETURN NEXT;
                v_count := v_count + 1;
            END IF;

            -- Advance seek past the folder range
            IF v_is_asc THEN
                v_next_seek := lower(left(v_common_prefix, -1)) || chr(ascii(v_delimiter) + 1);
            ELSE
                v_next_seek := lower(v_common_prefix);
            END IF;
        ELSE
            -- FILE: Batch fetch using DYNAMIC SQL (overhead amortized over many rows)
            -- For ASC: upper_bound is the exclusive upper limit (< condition)
            -- For DESC: prefix_lower is the inclusive lower limit (>= condition)
            FOR v_current IN EXECUTE v_batch_query
                USING bucketname, v_next_seek,
                    CASE WHEN v_is_asc THEN COALESCE(v_upper_bound, v_prefix_lower) ELSE v_prefix_lower END, v_file_batch_size
            LOOP
                v_common_prefix := storage.get_common_prefix(lower(v_current.name), v_prefix_lower, v_delimiter);

                IF v_common_prefix IS NOT NULL THEN
                    -- Hit a folder: exit batch, let peek handle it
                    v_next_seek := lower(v_current.name);
                    EXIT;
                END IF;

                -- Handle offset skipping
                IF v_skipped < offsets THEN
                    v_skipped := v_skipped + 1;
                ELSE
                    -- Emit file
                    name := split_part(v_current.name, v_delimiter, levels);
                    id := v_current.id;
                    updated_at := v_current.updated_at;
                    created_at := v_current.created_at;
                    last_accessed_at := v_current.last_accessed_at;
                    metadata := v_current.metadata;
                    RETURN NEXT;
                    v_count := v_count + 1;
                END IF;

                -- Advance seek past this file
                IF v_is_asc THEN
                    v_next_seek := lower(v_current.name) || v_delimiter;
                ELSE
                    v_next_seek := lower(v_current.name);
                END IF;

                EXIT WHEN v_count >= v_limit;
            END LOOP;
        END IF;
    END LOOP;
END;
$_$;


ALTER FUNCTION storage.search(prefix text, bucketname text, limits integer, levels integer, offsets integer, search text, sortcolumn text, sortorder text) OWNER TO supabase_storage_admin;

--
-- Name: search_by_timestamp(text, text, integer, integer, text, text, text, text); Type: FUNCTION; Schema: storage; Owner: supabase_storage_admin
--

CREATE FUNCTION storage.search_by_timestamp(p_prefix text, p_bucket_id text, p_limit integer, p_level integer, p_start_after text, p_sort_order text, p_sort_column text, p_sort_column_after text) RETURNS TABLE(key text, name text, id uuid, updated_at timestamp with time zone, created_at timestamp with time zone, last_accessed_at timestamp with time zone, metadata jsonb)
    LANGUAGE plpgsql STABLE
    AS $_$
DECLARE
    v_cursor_op text;
    v_query text;
    v_prefix text;
BEGIN
    v_prefix := coalesce(p_prefix, '');

    IF p_sort_order = 'asc' THEN
        v_cursor_op := '>';
    ELSE
        v_cursor_op := '<';
    END IF;

    v_query := format($sql$
        WITH raw_objects AS (
            SELECT
                o.name AS obj_name,
                o.id AS obj_id,
                o.updated_at AS obj_updated_at,
                o.created_at AS obj_created_at,
                o.last_accessed_at AS obj_last_accessed_at,
                o.metadata AS obj_metadata,
                storage.get_common_prefix(o.name, $1, '/') AS common_prefix
            FROM storage.objects o
            WHERE o.bucket_id = $2
              AND o.name COLLATE "C" LIKE $1 || '%%'
        ),
        -- Aggregate common prefixes (folders)
        -- Both created_at and updated_at use MIN(obj_created_at) to match the old prefixes table behavior
        aggregated_prefixes AS (
            SELECT
                rtrim(common_prefix, '/') AS name,
                NULL::uuid AS id,
                MIN(obj_created_at) AS updated_at,
                MIN(obj_created_at) AS created_at,
                NULL::timestamptz AS last_accessed_at,
                NULL::jsonb AS metadata,
                TRUE AS is_prefix
            FROM raw_objects
            WHERE common_prefix IS NOT NULL
            GROUP BY common_prefix
        ),
        leaf_objects AS (
            SELECT
                obj_name AS name,
                obj_id AS id,
                obj_updated_at AS updated_at,
                obj_created_at AS created_at,
                obj_last_accessed_at AS last_accessed_at,
                obj_metadata AS metadata,
                FALSE AS is_prefix
            FROM raw_objects
            WHERE common_prefix IS NULL
        ),
        combined AS (
            SELECT * FROM aggregated_prefixes
            UNION ALL
            SELECT * FROM leaf_objects
        ),
        filtered AS (
            SELECT *
            FROM combined
            WHERE (
                $5 = ''
                OR ROW(
                    date_trunc('milliseconds', %I),
                    name COLLATE "C"
                ) %s ROW(
                    COALESCE(NULLIF($6, '')::timestamptz, 'epoch'::timestamptz),
                    $5
                )
            )
        )
        SELECT
            split_part(name, '/', $3) AS key,
            name,
            id,
            updated_at,
            created_at,
            last_accessed_at,
            metadata
        FROM filtered
        ORDER BY
            COALESCE(date_trunc('milliseconds', %I), 'epoch'::timestamptz) %s,
            name COLLATE "C" %s
        LIMIT $4
    $sql$,
        p_sort_column,
        v_cursor_op,
        p_sort_column,
        p_sort_order,
        p_sort_order
    );

    RETURN QUERY EXECUTE v_query
    USING v_prefix, p_bucket_id, p_level, p_limit, p_start_after, p_sort_column_after;
END;
$_$;


ALTER FUNCTION storage.search_by_timestamp(p_prefix text, p_bucket_id text, p_limit integer, p_level integer, p_start_after text, p_sort_order text, p_sort_column text, p_sort_column_after text) OWNER TO supabase_storage_admin;

--
-- Name: search_v2(text, text, integer, integer, text, text, text, text); Type: FUNCTION; Schema: storage; Owner: supabase_storage_admin
--

CREATE FUNCTION storage.search_v2(prefix text, bucket_name text, limits integer DEFAULT 100, levels integer DEFAULT 1, start_after text DEFAULT ''::text, sort_order text DEFAULT 'asc'::text, sort_column text DEFAULT 'name'::text, sort_column_after text DEFAULT ''::text) RETURNS TABLE(key text, name text, id uuid, updated_at timestamp with time zone, created_at timestamp with time zone, last_accessed_at timestamp with time zone, metadata jsonb)
    LANGUAGE plpgsql STABLE
    AS $$
DECLARE
    v_sort_col text;
    v_sort_ord text;
    v_limit int;
BEGIN
    -- Cap limit to maximum of 1500 records
    v_limit := LEAST(coalesce(limits, 100), 1500);

    -- Validate and normalize sort_order
    v_sort_ord := lower(coalesce(sort_order, 'asc'));
    IF v_sort_ord NOT IN ('asc', 'desc') THEN
        v_sort_ord := 'asc';
    END IF;

    -- Validate and normalize sort_column
    v_sort_col := lower(coalesce(sort_column, 'name'));
    IF v_sort_col NOT IN ('name', 'updated_at', 'created_at') THEN
        v_sort_col := 'name';
    END IF;

    -- Route to appropriate implementation
    IF v_sort_col = 'name' THEN
        -- Use list_objects_with_delimiter for name sorting (most efficient: O(k * log n))
        RETURN QUERY
        SELECT
            split_part(l.name, '/', levels) AS key,
            l.name AS name,
            l.id,
            l.updated_at,
            l.created_at,
            l.last_accessed_at,
            l.metadata
        FROM storage.list_objects_with_delimiter(
            bucket_name,
            coalesce(prefix, ''),
            '/',
            v_limit,
            start_after,
            '',
            v_sort_ord
        ) l;
    ELSE
        -- Use aggregation approach for timestamp sorting
        -- Not efficient for large datasets but supports correct pagination
        RETURN QUERY SELECT * FROM storage.search_by_timestamp(
            prefix, bucket_name, v_limit, levels, start_after,
            v_sort_ord, v_sort_col, sort_column_after
        );
    END IF;
END;
$$;


ALTER FUNCTION storage.search_v2(prefix text, bucket_name text, limits integer, levels integer, start_after text, sort_order text, sort_column text, sort_column_after text) OWNER TO supabase_storage_admin;

--
-- Name: update_updated_at_column(); Type: FUNCTION; Schema: storage; Owner: supabase_storage_admin
--

CREATE FUNCTION storage.update_updated_at_column() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
BEGIN
    NEW.updated_at = now();
    RETURN NEW; 
END;
$$;


ALTER FUNCTION storage.update_updated_at_column() OWNER TO supabase_storage_admin;

--
-- Name: http_request(); Type: FUNCTION; Schema: supabase_functions; Owner: supabase_functions_admin
--

CREATE FUNCTION supabase_functions.http_request() RETURNS trigger
    LANGUAGE plpgsql SECURITY DEFINER
    SET search_path TO 'supabase_functions'
    AS $$
  DECLARE
    request_id bigint;
    payload jsonb;
    url text := TG_ARGV[0]::text;
    method text := TG_ARGV[1]::text;
    headers jsonb DEFAULT '{}'::jsonb;
    params jsonb DEFAULT '{}'::jsonb;
    timeout_ms integer DEFAULT 1000;
  BEGIN
    IF url IS NULL OR url = 'null' THEN
      RAISE EXCEPTION 'url argument is missing';
    END IF;

    IF method IS NULL OR method = 'null' THEN
      RAISE EXCEPTION 'method argument is missing';
    END IF;

    IF TG_ARGV[2] IS NULL OR TG_ARGV[2] = 'null' THEN
      headers = '{"Content-Type": "application/json"}'::jsonb;
    ELSE
      headers = TG_ARGV[2]::jsonb;
    END IF;

    IF TG_ARGV[3] IS NULL OR TG_ARGV[3] = 'null' THEN
      params = '{}'::jsonb;
    ELSE
      params = TG_ARGV[3]::jsonb;
    END IF;

    IF TG_ARGV[4] IS NULL OR TG_ARGV[4] = 'null' THEN
      timeout_ms = 1000;
    ELSE
      timeout_ms = TG_ARGV[4]::integer;
    END IF;

    CASE
      WHEN method = 'GET' THEN
        SELECT http_get INTO request_id FROM net.http_get(
          url,
          params,
          headers,
          timeout_ms
        );
      WHEN method = 'POST' THEN
        payload = jsonb_build_object(
          'old_record', OLD,
          'record', NEW,
          'type', TG_OP,
          'table', TG_TABLE_NAME,
          'schema', TG_TABLE_SCHEMA
        );

        SELECT http_post INTO request_id FROM net.http_post(
          url,
          payload,
          params,
          headers,
          timeout_ms
        );
      ELSE
        RAISE EXCEPTION 'method argument % is invalid', method;
    END CASE;

    INSERT INTO supabase_functions.hooks
      (hook_table_id, hook_name, request_id)
    VALUES
      (TG_RELID, TG_NAME, request_id);

    RETURN NEW;
  END
$$;


ALTER FUNCTION supabase_functions.http_request() OWNER TO supabase_functions_admin;

SET default_tablespace = '';

SET default_table_access_method = heap;

--
-- Name: extensions; Type: TABLE; Schema: _realtime; Owner: supabase_admin
--

CREATE TABLE _realtime.extensions (
    id uuid NOT NULL,
    type text,
    settings jsonb,
    tenant_external_id text,
    inserted_at timestamp(0) without time zone NOT NULL,
    updated_at timestamp(0) without time zone NOT NULL
);


ALTER TABLE _realtime.extensions OWNER TO supabase_admin;

--
-- Name: feature_flags; Type: TABLE; Schema: _realtime; Owner: supabase_admin
--

CREATE TABLE _realtime.feature_flags (
    id uuid NOT NULL,
    name character varying(255) NOT NULL,
    enabled boolean DEFAULT false NOT NULL,
    inserted_at timestamp(0) without time zone NOT NULL,
    updated_at timestamp(0) without time zone NOT NULL
);


ALTER TABLE _realtime.feature_flags OWNER TO supabase_admin;

--
-- Name: schema_migrations; Type: TABLE; Schema: _realtime; Owner: supabase_admin
--

CREATE TABLE _realtime.schema_migrations (
    version bigint NOT NULL,
    inserted_at timestamp(0) without time zone
);


ALTER TABLE _realtime.schema_migrations OWNER TO supabase_admin;

--
-- Name: tenants; Type: TABLE; Schema: _realtime; Owner: supabase_admin
--

CREATE TABLE _realtime.tenants (
    id uuid NOT NULL,
    name text,
    external_id text,
    jwt_secret text,
    max_concurrent_users integer DEFAULT 200 NOT NULL,
    inserted_at timestamp(0) without time zone NOT NULL,
    updated_at timestamp(0) without time zone NOT NULL,
    max_events_per_second integer DEFAULT 100 NOT NULL,
    postgres_cdc_default text DEFAULT 'postgres_cdc_rls'::text,
    max_bytes_per_second integer DEFAULT 100000 NOT NULL,
    max_channels_per_client integer DEFAULT 100 NOT NULL,
    max_joins_per_second integer DEFAULT 500 NOT NULL,
    suspend boolean DEFAULT false,
    jwt_jwks jsonb,
    notify_private_alpha boolean DEFAULT false,
    private_only boolean DEFAULT false NOT NULL,
    migrations_ran integer DEFAULT 0,
    broadcast_adapter character varying(255) DEFAULT 'gen_rpc'::character varying,
    max_presence_events_per_second integer DEFAULT 1000,
    max_payload_size_in_kb integer DEFAULT 3000,
    max_client_presence_events_per_window integer,
    client_presence_window_ms integer,
    presence_enabled boolean DEFAULT false NOT NULL,
    feature_flags jsonb DEFAULT '{}'::jsonb NOT NULL,
    CONSTRAINT jwt_secret_or_jwt_jwks_required CHECK (((jwt_secret IS NOT NULL) OR (jwt_jwks IS NOT NULL)))
);


ALTER TABLE _realtime.tenants OWNER TO supabase_admin;

--
-- Name: audit_log_entries; Type: TABLE; Schema: auth; Owner: supabase_auth_admin
--

CREATE TABLE auth.audit_log_entries (
    instance_id uuid,
    id uuid NOT NULL,
    payload json,
    created_at timestamp with time zone,
    ip_address character varying(64) DEFAULT ''::character varying NOT NULL
);


ALTER TABLE auth.audit_log_entries OWNER TO supabase_auth_admin;

--
-- Name: TABLE audit_log_entries; Type: COMMENT; Schema: auth; Owner: supabase_auth_admin
--

COMMENT ON TABLE auth.audit_log_entries IS 'Auth: Audit trail for user actions.';


--
-- Name: custom_oauth_providers; Type: TABLE; Schema: auth; Owner: supabase_auth_admin
--

CREATE TABLE auth.custom_oauth_providers (
    id uuid DEFAULT gen_random_uuid() NOT NULL,
    provider_type text NOT NULL,
    identifier text NOT NULL,
    name text NOT NULL,
    client_id text NOT NULL,
    client_secret text NOT NULL,
    acceptable_client_ids text[] DEFAULT '{}'::text[] NOT NULL,
    scopes text[] DEFAULT '{}'::text[] NOT NULL,
    pkce_enabled boolean DEFAULT true NOT NULL,
    attribute_mapping jsonb DEFAULT '{}'::jsonb NOT NULL,
    authorization_params jsonb DEFAULT '{}'::jsonb NOT NULL,
    enabled boolean DEFAULT true NOT NULL,
    email_optional boolean DEFAULT false NOT NULL,
    issuer text,
    discovery_url text,
    skip_nonce_check boolean DEFAULT false NOT NULL,
    cached_discovery jsonb,
    discovery_cached_at timestamp with time zone,
    authorization_url text,
    token_url text,
    userinfo_url text,
    jwks_uri text,
    created_at timestamp with time zone DEFAULT now() NOT NULL,
    updated_at timestamp with time zone DEFAULT now() NOT NULL,
    CONSTRAINT custom_oauth_providers_authorization_url_https CHECK (((authorization_url IS NULL) OR (authorization_url ~~ 'https://%'::text))),
    CONSTRAINT custom_oauth_providers_authorization_url_length CHECK (((authorization_url IS NULL) OR (char_length(authorization_url) <= 2048))),
    CONSTRAINT custom_oauth_providers_client_id_length CHECK (((char_length(client_id) >= 1) AND (char_length(client_id) <= 512))),
    CONSTRAINT custom_oauth_providers_discovery_url_length CHECK (((discovery_url IS NULL) OR (char_length(discovery_url) <= 2048))),
    CONSTRAINT custom_oauth_providers_identifier_format CHECK ((identifier ~ '^[a-z0-9][a-z0-9:-]{0,48}[a-z0-9]$'::text)),
    CONSTRAINT custom_oauth_providers_issuer_length CHECK (((issuer IS NULL) OR ((char_length(issuer) >= 1) AND (char_length(issuer) <= 2048)))),
    CONSTRAINT custom_oauth_providers_jwks_uri_https CHECK (((jwks_uri IS NULL) OR (jwks_uri ~~ 'https://%'::text))),
    CONSTRAINT custom_oauth_providers_jwks_uri_length CHECK (((jwks_uri IS NULL) OR (char_length(jwks_uri) <= 2048))),
    CONSTRAINT custom_oauth_providers_name_length CHECK (((char_length(name) >= 1) AND (char_length(name) <= 100))),
    CONSTRAINT custom_oauth_providers_oauth2_requires_endpoints CHECK (((provider_type <> 'oauth2'::text) OR ((authorization_url IS NOT NULL) AND (token_url IS NOT NULL) AND (userinfo_url IS NOT NULL)))),
    CONSTRAINT custom_oauth_providers_oidc_discovery_url_https CHECK (((provider_type <> 'oidc'::text) OR (discovery_url IS NULL) OR (discovery_url ~~ 'https://%'::text))),
    CONSTRAINT custom_oauth_providers_oidc_issuer_https CHECK (((provider_type <> 'oidc'::text) OR (issuer IS NULL) OR (issuer ~~ 'https://%'::text))),
    CONSTRAINT custom_oauth_providers_oidc_requires_issuer CHECK (((provider_type <> 'oidc'::text) OR (issuer IS NOT NULL))),
    CONSTRAINT custom_oauth_providers_provider_type_check CHECK ((provider_type = ANY (ARRAY['oauth2'::text, 'oidc'::text]))),
    CONSTRAINT custom_oauth_providers_token_url_https CHECK (((token_url IS NULL) OR (token_url ~~ 'https://%'::text))),
    CONSTRAINT custom_oauth_providers_token_url_length CHECK (((token_url IS NULL) OR (char_length(token_url) <= 2048))),
    CONSTRAINT custom_oauth_providers_userinfo_url_https CHECK (((userinfo_url IS NULL) OR (userinfo_url ~~ 'https://%'::text))),
    CONSTRAINT custom_oauth_providers_userinfo_url_length CHECK (((userinfo_url IS NULL) OR (char_length(userinfo_url) <= 2048)))
);


ALTER TABLE auth.custom_oauth_providers OWNER TO supabase_auth_admin;

--
-- Name: flow_state; Type: TABLE; Schema: auth; Owner: supabase_auth_admin
--

CREATE TABLE auth.flow_state (
    id uuid NOT NULL,
    user_id uuid,
    auth_code text,
    code_challenge_method auth.code_challenge_method,
    code_challenge text,
    provider_type text NOT NULL,
    provider_access_token text,
    provider_refresh_token text,
    created_at timestamp with time zone,
    updated_at timestamp with time zone,
    authentication_method text NOT NULL,
    auth_code_issued_at timestamp with time zone,
    invite_token text,
    referrer text,
    oauth_client_state_id uuid,
    linking_target_id uuid,
    email_optional boolean DEFAULT false NOT NULL
);


ALTER TABLE auth.flow_state OWNER TO supabase_auth_admin;

--
-- Name: TABLE flow_state; Type: COMMENT; Schema: auth; Owner: supabase_auth_admin
--

COMMENT ON TABLE auth.flow_state IS 'Stores metadata for all OAuth/SSO login flows';


--
-- Name: identities; Type: TABLE; Schema: auth; Owner: supabase_auth_admin
--

CREATE TABLE auth.identities (
    provider_id text NOT NULL,
    user_id uuid NOT NULL,
    identity_data jsonb NOT NULL,
    provider text NOT NULL,
    last_sign_in_at timestamp with time zone,
    created_at timestamp with time zone,
    updated_at timestamp with time zone,
    email text GENERATED ALWAYS AS (lower((identity_data ->> 'email'::text))) STORED,
    id uuid DEFAULT gen_random_uuid() NOT NULL
);


ALTER TABLE auth.identities OWNER TO supabase_auth_admin;

--
-- Name: TABLE identities; Type: COMMENT; Schema: auth; Owner: supabase_auth_admin
--

COMMENT ON TABLE auth.identities IS 'Auth: Stores identities associated to a user.';


--
-- Name: COLUMN identities.email; Type: COMMENT; Schema: auth; Owner: supabase_auth_admin
--

COMMENT ON COLUMN auth.identities.email IS 'Auth: Email is a generated column that references the optional email property in the identity_data';


--
-- Name: instances; Type: TABLE; Schema: auth; Owner: supabase_auth_admin
--

CREATE TABLE auth.instances (
    id uuid NOT NULL,
    uuid uuid,
    raw_base_config text,
    created_at timestamp with time zone,
    updated_at timestamp with time zone
);


ALTER TABLE auth.instances OWNER TO supabase_auth_admin;

--
-- Name: TABLE instances; Type: COMMENT; Schema: auth; Owner: supabase_auth_admin
--

COMMENT ON TABLE auth.instances IS 'Auth: Manages users across multiple sites.';


--
-- Name: mfa_amr_claims; Type: TABLE; Schema: auth; Owner: supabase_auth_admin
--

CREATE TABLE auth.mfa_amr_claims (
    session_id uuid NOT NULL,
    created_at timestamp with time zone NOT NULL,
    updated_at timestamp with time zone NOT NULL,
    authentication_method text NOT NULL,
    id uuid NOT NULL
);


ALTER TABLE auth.mfa_amr_claims OWNER TO supabase_auth_admin;

--
-- Name: TABLE mfa_amr_claims; Type: COMMENT; Schema: auth; Owner: supabase_auth_admin
--

COMMENT ON TABLE auth.mfa_amr_claims IS 'auth: stores authenticator method reference claims for multi factor authentication';


--
-- Name: mfa_challenges; Type: TABLE; Schema: auth; Owner: supabase_auth_admin
--

CREATE TABLE auth.mfa_challenges (
    id uuid NOT NULL,
    factor_id uuid NOT NULL,
    created_at timestamp with time zone NOT NULL,
    verified_at timestamp with time zone,
    ip_address inet NOT NULL,
    otp_code text,
    web_authn_session_data jsonb
);


ALTER TABLE auth.mfa_challenges OWNER TO supabase_auth_admin;

--
-- Name: TABLE mfa_challenges; Type: COMMENT; Schema: auth; Owner: supabase_auth_admin
--

COMMENT ON TABLE auth.mfa_challenges IS 'auth: stores metadata about challenge requests made';


--
-- Name: mfa_factors; Type: TABLE; Schema: auth; Owner: supabase_auth_admin
--

CREATE TABLE auth.mfa_factors (
    id uuid NOT NULL,
    user_id uuid NOT NULL,
    friendly_name text,
    factor_type auth.factor_type NOT NULL,
    status auth.factor_status NOT NULL,
    created_at timestamp with time zone NOT NULL,
    updated_at timestamp with time zone NOT NULL,
    secret text,
    phone text,
    last_challenged_at timestamp with time zone,
    web_authn_credential jsonb,
    web_authn_aaguid uuid,
    last_webauthn_challenge_data jsonb
);


ALTER TABLE auth.mfa_factors OWNER TO supabase_auth_admin;

--
-- Name: TABLE mfa_factors; Type: COMMENT; Schema: auth; Owner: supabase_auth_admin
--

COMMENT ON TABLE auth.mfa_factors IS 'auth: stores metadata about factors';


--
-- Name: COLUMN mfa_factors.last_webauthn_challenge_data; Type: COMMENT; Schema: auth; Owner: supabase_auth_admin
--

COMMENT ON COLUMN auth.mfa_factors.last_webauthn_challenge_data IS 'Stores the latest WebAuthn challenge data including attestation/assertion for customer verification';


--
-- Name: oauth_authorizations; Type: TABLE; Schema: auth; Owner: supabase_auth_admin
--

CREATE TABLE auth.oauth_authorizations (
    id uuid NOT NULL,
    authorization_id text NOT NULL,
    client_id uuid NOT NULL,
    user_id uuid,
    redirect_uri text NOT NULL,
    scope text NOT NULL,
    state text,
    resource text,
    code_challenge text,
    code_challenge_method auth.code_challenge_method,
    response_type auth.oauth_response_type DEFAULT 'code'::auth.oauth_response_type NOT NULL,
    status auth.oauth_authorization_status DEFAULT 'pending'::auth.oauth_authorization_status NOT NULL,
    authorization_code text,
    created_at timestamp with time zone DEFAULT now() NOT NULL,
    expires_at timestamp with time zone DEFAULT (now() + '00:03:00'::interval) NOT NULL,
    approved_at timestamp with time zone,
    nonce text,
    CONSTRAINT oauth_authorizations_authorization_code_length CHECK ((char_length(authorization_code) <= 255)),
    CONSTRAINT oauth_authorizations_code_challenge_length CHECK ((char_length(code_challenge) <= 128)),
    CONSTRAINT oauth_authorizations_expires_at_future CHECK ((expires_at > created_at)),
    CONSTRAINT oauth_authorizations_nonce_length CHECK ((char_length(nonce) <= 255)),
    CONSTRAINT oauth_authorizations_redirect_uri_length CHECK ((char_length(redirect_uri) <= 2048)),
    CONSTRAINT oauth_authorizations_resource_length CHECK ((char_length(resource) <= 2048)),
    CONSTRAINT oauth_authorizations_scope_length CHECK ((char_length(scope) <= 4096)),
    CONSTRAINT oauth_authorizations_state_length CHECK ((char_length(state) <= 4096))
);


ALTER TABLE auth.oauth_authorizations OWNER TO supabase_auth_admin;

--
-- Name: oauth_client_states; Type: TABLE; Schema: auth; Owner: supabase_auth_admin
--

CREATE TABLE auth.oauth_client_states (
    id uuid NOT NULL,
    provider_type text NOT NULL,
    code_verifier text,
    created_at timestamp with time zone NOT NULL
);


ALTER TABLE auth.oauth_client_states OWNER TO supabase_auth_admin;

--
-- Name: TABLE oauth_client_states; Type: COMMENT; Schema: auth; Owner: supabase_auth_admin
--

COMMENT ON TABLE auth.oauth_client_states IS 'Stores OAuth states for third-party provider authentication flows where Supabase acts as the OAuth client.';


--
-- Name: oauth_clients; Type: TABLE; Schema: auth; Owner: supabase_auth_admin
--

CREATE TABLE auth.oauth_clients (
    id uuid NOT NULL,
    client_secret_hash text,
    registration_type auth.oauth_registration_type NOT NULL,
    redirect_uris text NOT NULL,
    grant_types text NOT NULL,
    client_name text,
    client_uri text,
    logo_uri text,
    created_at timestamp with time zone DEFAULT now() NOT NULL,
    updated_at timestamp with time zone DEFAULT now() NOT NULL,
    deleted_at timestamp with time zone,
    client_type auth.oauth_client_type DEFAULT 'confidential'::auth.oauth_client_type NOT NULL,
    token_endpoint_auth_method text NOT NULL,
    CONSTRAINT oauth_clients_client_name_length CHECK ((char_length(client_name) <= 1024)),
    CONSTRAINT oauth_clients_client_uri_length CHECK ((char_length(client_uri) <= 2048)),
    CONSTRAINT oauth_clients_logo_uri_length CHECK ((char_length(logo_uri) <= 2048)),
    CONSTRAINT oauth_clients_token_endpoint_auth_method_check CHECK ((token_endpoint_auth_method = ANY (ARRAY['client_secret_basic'::text, 'client_secret_post'::text, 'none'::text])))
);


ALTER TABLE auth.oauth_clients OWNER TO supabase_auth_admin;

--
-- Name: oauth_consents; Type: TABLE; Schema: auth; Owner: supabase_auth_admin
--

CREATE TABLE auth.oauth_consents (
    id uuid NOT NULL,
    user_id uuid NOT NULL,
    client_id uuid NOT NULL,
    scopes text NOT NULL,
    granted_at timestamp with time zone DEFAULT now() NOT NULL,
    revoked_at timestamp with time zone,
    CONSTRAINT oauth_consents_revoked_after_granted CHECK (((revoked_at IS NULL) OR (revoked_at >= granted_at))),
    CONSTRAINT oauth_consents_scopes_length CHECK ((char_length(scopes) <= 2048)),
    CONSTRAINT oauth_consents_scopes_not_empty CHECK ((char_length(TRIM(BOTH FROM scopes)) > 0))
);


ALTER TABLE auth.oauth_consents OWNER TO supabase_auth_admin;

--
-- Name: one_time_tokens; Type: TABLE; Schema: auth; Owner: supabase_auth_admin
--

CREATE TABLE auth.one_time_tokens (
    id uuid NOT NULL,
    user_id uuid NOT NULL,
    token_type auth.one_time_token_type NOT NULL,
    token_hash text NOT NULL,
    relates_to text NOT NULL,
    created_at timestamp without time zone DEFAULT now() NOT NULL,
    updated_at timestamp without time zone DEFAULT now() NOT NULL,
    CONSTRAINT one_time_tokens_token_hash_check CHECK ((char_length(token_hash) > 0))
);


ALTER TABLE auth.one_time_tokens OWNER TO supabase_auth_admin;

--
-- Name: refresh_tokens; Type: TABLE; Schema: auth; Owner: supabase_auth_admin
--

CREATE TABLE auth.refresh_tokens (
    instance_id uuid,
    id bigint NOT NULL,
    token character varying(255),
    user_id character varying(255),
    revoked boolean,
    created_at timestamp with time zone,
    updated_at timestamp with time zone,
    parent character varying(255),
    session_id uuid
);


ALTER TABLE auth.refresh_tokens OWNER TO supabase_auth_admin;

--
-- Name: TABLE refresh_tokens; Type: COMMENT; Schema: auth; Owner: supabase_auth_admin
--

COMMENT ON TABLE auth.refresh_tokens IS 'Auth: Store of tokens used to refresh JWT tokens once they expire.';


--
-- Name: refresh_tokens_id_seq; Type: SEQUENCE; Schema: auth; Owner: supabase_auth_admin
--

CREATE SEQUENCE auth.refresh_tokens_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER SEQUENCE auth.refresh_tokens_id_seq OWNER TO supabase_auth_admin;

--
-- Name: refresh_tokens_id_seq; Type: SEQUENCE OWNED BY; Schema: auth; Owner: supabase_auth_admin
--

ALTER SEQUENCE auth.refresh_tokens_id_seq OWNED BY auth.refresh_tokens.id;


--
-- Name: saml_providers; Type: TABLE; Schema: auth; Owner: supabase_auth_admin
--

CREATE TABLE auth.saml_providers (
    id uuid NOT NULL,
    sso_provider_id uuid NOT NULL,
    entity_id text NOT NULL,
    metadata_xml text NOT NULL,
    metadata_url text,
    attribute_mapping jsonb,
    created_at timestamp with time zone,
    updated_at timestamp with time zone,
    name_id_format text,
    CONSTRAINT "entity_id not empty" CHECK ((char_length(entity_id) > 0)),
    CONSTRAINT "metadata_url not empty" CHECK (((metadata_url = NULL::text) OR (char_length(metadata_url) > 0))),
    CONSTRAINT "metadata_xml not empty" CHECK ((char_length(metadata_xml) > 0))
);


ALTER TABLE auth.saml_providers OWNER TO supabase_auth_admin;

--
-- Name: TABLE saml_providers; Type: COMMENT; Schema: auth; Owner: supabase_auth_admin
--

COMMENT ON TABLE auth.saml_providers IS 'Auth: Manages SAML Identity Provider connections.';


--
-- Name: saml_relay_states; Type: TABLE; Schema: auth; Owner: supabase_auth_admin
--

CREATE TABLE auth.saml_relay_states (
    id uuid NOT NULL,
    sso_provider_id uuid NOT NULL,
    request_id text NOT NULL,
    for_email text,
    redirect_to text,
    created_at timestamp with time zone,
    updated_at timestamp with time zone,
    flow_state_id uuid,
    CONSTRAINT "request_id not empty" CHECK ((char_length(request_id) > 0))
);


ALTER TABLE auth.saml_relay_states OWNER TO supabase_auth_admin;

--
-- Name: TABLE saml_relay_states; Type: COMMENT; Schema: auth; Owner: supabase_auth_admin
--

COMMENT ON TABLE auth.saml_relay_states IS 'Auth: Contains SAML Relay State information for each Service Provider initiated login.';


--
-- Name: schema_migrations; Type: TABLE; Schema: auth; Owner: supabase_auth_admin
--

CREATE TABLE auth.schema_migrations (
    version character varying(255) NOT NULL
);


ALTER TABLE auth.schema_migrations OWNER TO supabase_auth_admin;

--
-- Name: TABLE schema_migrations; Type: COMMENT; Schema: auth; Owner: supabase_auth_admin
--

COMMENT ON TABLE auth.schema_migrations IS 'Auth: Manages updates to the auth system.';


--
-- Name: sessions; Type: TABLE; Schema: auth; Owner: supabase_auth_admin
--

CREATE TABLE auth.sessions (
    id uuid NOT NULL,
    user_id uuid NOT NULL,
    created_at timestamp with time zone,
    updated_at timestamp with time zone,
    factor_id uuid,
    aal auth.aal_level,
    not_after timestamp with time zone,
    refreshed_at timestamp without time zone,
    user_agent text,
    ip inet,
    tag text,
    oauth_client_id uuid,
    refresh_token_hmac_key text,
    refresh_token_counter bigint,
    scopes text,
    CONSTRAINT sessions_scopes_length CHECK ((char_length(scopes) <= 4096))
);


ALTER TABLE auth.sessions OWNER TO supabase_auth_admin;

--
-- Name: TABLE sessions; Type: COMMENT; Schema: auth; Owner: supabase_auth_admin
--

COMMENT ON TABLE auth.sessions IS 'Auth: Stores session data associated to a user.';


--
-- Name: COLUMN sessions.not_after; Type: COMMENT; Schema: auth; Owner: supabase_auth_admin
--

COMMENT ON COLUMN auth.sessions.not_after IS 'Auth: Not after is a nullable column that contains a timestamp after which the session should be regarded as expired.';


--
-- Name: COLUMN sessions.refresh_token_hmac_key; Type: COMMENT; Schema: auth; Owner: supabase_auth_admin
--

COMMENT ON COLUMN auth.sessions.refresh_token_hmac_key IS 'Holds a HMAC-SHA256 key used to sign refresh tokens for this session.';


--
-- Name: COLUMN sessions.refresh_token_counter; Type: COMMENT; Schema: auth; Owner: supabase_auth_admin
--

COMMENT ON COLUMN auth.sessions.refresh_token_counter IS 'Holds the ID (counter) of the last issued refresh token.';


--
-- Name: sso_domains; Type: TABLE; Schema: auth; Owner: supabase_auth_admin
--

CREATE TABLE auth.sso_domains (
    id uuid NOT NULL,
    sso_provider_id uuid NOT NULL,
    domain text NOT NULL,
    created_at timestamp with time zone,
    updated_at timestamp with time zone,
    CONSTRAINT "domain not empty" CHECK ((char_length(domain) > 0))
);


ALTER TABLE auth.sso_domains OWNER TO supabase_auth_admin;

--
-- Name: TABLE sso_domains; Type: COMMENT; Schema: auth; Owner: supabase_auth_admin
--

COMMENT ON TABLE auth.sso_domains IS 'Auth: Manages SSO email address domain mapping to an SSO Identity Provider.';


--
-- Name: sso_providers; Type: TABLE; Schema: auth; Owner: supabase_auth_admin
--

CREATE TABLE auth.sso_providers (
    id uuid NOT NULL,
    resource_id text,
    created_at timestamp with time zone,
    updated_at timestamp with time zone,
    disabled boolean,
    CONSTRAINT "resource_id not empty" CHECK (((resource_id = NULL::text) OR (char_length(resource_id) > 0)))
);


ALTER TABLE auth.sso_providers OWNER TO supabase_auth_admin;

--
-- Name: TABLE sso_providers; Type: COMMENT; Schema: auth; Owner: supabase_auth_admin
--

COMMENT ON TABLE auth.sso_providers IS 'Auth: Manages SSO identity provider information; see saml_providers for SAML.';


--
-- Name: COLUMN sso_providers.resource_id; Type: COMMENT; Schema: auth; Owner: supabase_auth_admin
--

COMMENT ON COLUMN auth.sso_providers.resource_id IS 'Auth: Uniquely identifies a SSO provider according to a user-chosen resource ID (case insensitive), useful in infrastructure as code.';


--
-- Name: users; Type: TABLE; Schema: auth; Owner: supabase_auth_admin
--

CREATE TABLE auth.users (
    instance_id uuid,
    id uuid NOT NULL,
    aud character varying(255),
    role character varying(255),
    email character varying(255),
    encrypted_password character varying(255),
    email_confirmed_at timestamp with time zone,
    invited_at timestamp with time zone,
    confirmation_token character varying(255),
    confirmation_sent_at timestamp with time zone,
    recovery_token character varying(255),
    recovery_sent_at timestamp with time zone,
    email_change_token_new character varying(255),
    email_change character varying(255),
    email_change_sent_at timestamp with time zone,
    last_sign_in_at timestamp with time zone,
    raw_app_meta_data jsonb,
    raw_user_meta_data jsonb,
    is_super_admin boolean,
    created_at timestamp with time zone,
    updated_at timestamp with time zone,
    phone text DEFAULT NULL::character varying,
    phone_confirmed_at timestamp with time zone,
    phone_change text DEFAULT ''::character varying,
    phone_change_token character varying(255) DEFAULT ''::character varying,
    phone_change_sent_at timestamp with time zone,
    confirmed_at timestamp with time zone GENERATED ALWAYS AS (LEAST(email_confirmed_at, phone_confirmed_at)) STORED,
    email_change_token_current character varying(255) DEFAULT ''::character varying,
    email_change_confirm_status smallint DEFAULT 0,
    banned_until timestamp with time zone,
    reauthentication_token character varying(255) DEFAULT ''::character varying,
    reauthentication_sent_at timestamp with time zone,
    is_sso_user boolean DEFAULT false NOT NULL,
    deleted_at timestamp with time zone,
    is_anonymous boolean DEFAULT false NOT NULL,
    CONSTRAINT users_email_change_confirm_status_check CHECK (((email_change_confirm_status >= 0) AND (email_change_confirm_status <= 2)))
);


ALTER TABLE auth.users OWNER TO supabase_auth_admin;

--
-- Name: TABLE users; Type: COMMENT; Schema: auth; Owner: supabase_auth_admin
--

COMMENT ON TABLE auth.users IS 'Auth: Stores user login data within a secure schema.';


--
-- Name: COLUMN users.is_sso_user; Type: COMMENT; Schema: auth; Owner: supabase_auth_admin
--

COMMENT ON COLUMN auth.users.is_sso_user IS 'Auth: Set this column to true when the account comes from SSO. These accounts can have duplicate emails.';


--
-- Name: webauthn_challenges; Type: TABLE; Schema: auth; Owner: supabase_auth_admin
--

CREATE TABLE auth.webauthn_challenges (
    id uuid DEFAULT gen_random_uuid() NOT NULL,
    user_id uuid,
    challenge_type text NOT NULL,
    session_data jsonb NOT NULL,
    created_at timestamp with time zone DEFAULT now() NOT NULL,
    expires_at timestamp with time zone NOT NULL,
    CONSTRAINT webauthn_challenges_challenge_type_check CHECK ((challenge_type = ANY (ARRAY['signup'::text, 'registration'::text, 'authentication'::text])))
);


ALTER TABLE auth.webauthn_challenges OWNER TO supabase_auth_admin;

--
-- Name: webauthn_credentials; Type: TABLE; Schema: auth; Owner: supabase_auth_admin
--

CREATE TABLE auth.webauthn_credentials (
    id uuid DEFAULT gen_random_uuid() NOT NULL,
    user_id uuid NOT NULL,
    credential_id bytea NOT NULL,
    public_key bytea NOT NULL,
    attestation_type text DEFAULT ''::text NOT NULL,
    aaguid uuid,
    sign_count bigint DEFAULT 0 NOT NULL,
    transports jsonb DEFAULT '[]'::jsonb NOT NULL,
    backup_eligible boolean DEFAULT false NOT NULL,
    backed_up boolean DEFAULT false NOT NULL,
    friendly_name text DEFAULT ''::text NOT NULL,
    created_at timestamp with time zone DEFAULT now() NOT NULL,
    updated_at timestamp with time zone DEFAULT now() NOT NULL,
    last_used_at timestamp with time zone
);


ALTER TABLE auth.webauthn_credentials OWNER TO supabase_auth_admin;

--
-- Name: ai_analysis_logs; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.ai_analysis_logs (
    id uuid DEFAULT gen_random_uuid() NOT NULL,
    camera_id uuid NOT NULL,
    alert_template_id uuid,
    prompt text NOT NULL,
    response_text text,
    model text,
    image_url text,
    metadata jsonb DEFAULT '{}'::jsonb,
    created_at timestamp with time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.ai_analysis_logs OWNER TO postgres;

--
-- Name: ai_models; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.ai_models (
    id uuid DEFAULT gen_random_uuid() NOT NULL,
    name text NOT NULL,
    description text,
    category text NOT NULL,
    version text NOT NULL,
    enabled boolean DEFAULT true NOT NULL,
    configuration jsonb,
    created_at timestamp with time zone DEFAULT now()
);


ALTER TABLE public.ai_models OWNER TO postgres;

--
-- Name: alert_template_events; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.alert_template_events (
    id uuid DEFAULT gen_random_uuid() NOT NULL,
    alert_template_id uuid NOT NULL,
    event_type_id uuid NOT NULL,
    created_at timestamp with time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.alert_template_events OWNER TO postgres;

--
-- Name: alert_template_industries; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.alert_template_industries (
    id uuid DEFAULT gen_random_uuid() NOT NULL,
    alert_template_id uuid NOT NULL,
    industry_id uuid NOT NULL,
    created_at timestamp with time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.alert_template_industries OWNER TO postgres;

--
-- Name: alert_templates; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.alert_templates (
    id uuid DEFAULT gen_random_uuid() NOT NULL,
    name text NOT NULL,
    name_ar text NOT NULL,
    description text,
    description_ar text,
    detection_method public.detection_method NOT NULL,
    model_file_url text,
    model_type text,
    huggingface_api_key text,
    model_api_endpoint text,
    enabled boolean DEFAULT true NOT NULL,
    created_at timestamp with time zone DEFAULT now() NOT NULL,
    updated_at timestamp with time zone DEFAULT now() NOT NULL,
    created_by uuid,
    api_provider text
);


ALTER TABLE public.alert_templates OWNER TO postgres;

--
-- Name: aman_instances; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.aman_instances (
    id uuid DEFAULT gen_random_uuid() NOT NULL,
    organization_id uuid NOT NULL,
    branch_id uuid,
    name text NOT NULL,
    base_url text NOT NULL,
    access_token text NOT NULL,
    active boolean DEFAULT true NOT NULL,
    created_by uuid,
    created_at timestamp with time zone DEFAULT now() NOT NULL,
    updated_at timestamp with time zone DEFAULT now() NOT NULL,
    username text,
    password text,
    dashboard_path text DEFAULT '/lovelace/default_view?kiosk'::text,
    aman_api_url text
);

ALTER TABLE ONLY public.aman_instances REPLICA IDENTITY FULL;


ALTER TABLE public.aman_instances OWNER TO postgres;

--
-- Name: auto_sync_settings; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.auto_sync_settings (
    id uuid DEFAULT gen_random_uuid() NOT NULL,
    enabled boolean DEFAULT true NOT NULL,
    interval_minutes integer DEFAULT 30 NOT NULL,
    last_sync timestamp with time zone,
    next_sync timestamp with time zone,
    created_at timestamp with time zone DEFAULT now(),
    updated_at timestamp with time zone DEFAULT now()
);


ALTER TABLE public.auto_sync_settings OWNER TO postgres;

--
-- Name: branch_roles; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.branch_roles (
    id uuid DEFAULT gen_random_uuid() NOT NULL,
    user_id uuid NOT NULL,
    branch_id uuid NOT NULL,
    role text NOT NULL,
    created_at timestamp with time zone DEFAULT now() NOT NULL,
    CONSTRAINT branch_roles_role_check CHECK ((role = 'branch_manager'::text))
);


ALTER TABLE public.branch_roles OWNER TO postgres;

--
-- Name: branches; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.branches (
    id uuid DEFAULT gen_random_uuid() NOT NULL,
    organization_id uuid,
    name text NOT NULL,
    address text,
    latitude numeric(10,8),
    longitude numeric(11,8),
    active boolean DEFAULT true NOT NULL,
    created_at timestamp with time zone DEFAULT now(),
    device_token text DEFAULT (md5((gen_random_uuid())::text) || md5((gen_random_uuid())::text)),
    config_version integer DEFAULT 1 NOT NULL,
    last_seen timestamp with time zone,
    agent_info jsonb DEFAULT '{}'::jsonb,
    alert_numbers text DEFAULT ''::text,
    engine_image text,
    device_status text DEFAULT 'pending'::text NOT NULL,
    device_fingerprint text,
    hardware_info jsonb DEFAULT '{}'::jsonb,
    is_vm boolean DEFAULT false,
    allow_vm boolean DEFAULT false,
    device_first_seen timestamp with time zone
);


ALTER TABLE public.branches OWNER TO postgres;

--
-- Name: camera_alert_assignments; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.camera_alert_assignments (
    id uuid DEFAULT gen_random_uuid() NOT NULL,
    camera_id uuid NOT NULL,
    alert_template_id uuid NOT NULL,
    enabled boolean DEFAULT true NOT NULL,
    confidence_threshold numeric DEFAULT 0.7,
    created_at timestamp with time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.camera_alert_assignments OWNER TO postgres;

--
-- Name: camera_event_assignments; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.camera_event_assignments (
    id uuid DEFAULT gen_random_uuid() NOT NULL,
    camera_id uuid NOT NULL,
    event_type_id uuid NOT NULL,
    enabled boolean DEFAULT true NOT NULL,
    confidence_threshold numeric DEFAULT 0.7,
    created_at timestamp with time zone DEFAULT now() NOT NULL,
    config jsonb DEFAULT '{}'::jsonb
);


ALTER TABLE public.camera_event_assignments OWNER TO postgres;

--
-- Name: camera_sources; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.camera_sources (
    id uuid DEFAULT gen_random_uuid() NOT NULL,
    name text NOT NULL,
    name_ar text NOT NULL,
    protocol text NOT NULL,
    requires_auth boolean DEFAULT false NOT NULL,
    default_port integer,
    url_pattern text,
    description text,
    description_ar text,
    icon text DEFAULT 'camera'::text,
    active boolean DEFAULT true NOT NULL,
    created_at timestamp with time zone DEFAULT now() NOT NULL,
    updated_at timestamp with time zone DEFAULT now() NOT NULL,
    created_by uuid
);


ALTER TABLE public.camera_sources OWNER TO postgres;

--
-- Name: cameras; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.cameras (
    id uuid DEFAULT gen_random_uuid() NOT NULL,
    branch_id uuid,
    name text NOT NULL,
    rtsp_url text,
    frigate_identifier text,
    status text DEFAULT 'offline'::text,
    last_connection timestamp with time zone,
    config jsonb,
    created_at timestamp with time zone DEFAULT now(),
    model text DEFAULT 'AI-CAM-4K'::text,
    features jsonb DEFAULT '{"ai_analysis": true, "night_vision": true, "audio_recording": false, "motion_detection": true}'::jsonb,
    max_resolution text DEFAULT '4K'::text,
    security_zone_id uuid,
    description text,
    detection_rules jsonb DEFAULT '[]'::jsonb,
    updated_at timestamp with time zone DEFAULT now(),
    enabled boolean DEFAULT true NOT NULL,
    frigate_instance_id uuid
);


ALTER TABLE public.cameras OWNER TO postgres;

--
-- Name: COLUMN cameras.status; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.cameras.status IS 'Camera connection status based on actual data/stream (متصلة/غير متصلة)';


--
-- Name: COLUMN cameras.enabled; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.cameras.enabled IS 'Camera activation status (مفعل/غير مفعل)';


--
-- Name: chat_messages; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.chat_messages (
    id uuid DEFAULT gen_random_uuid() NOT NULL,
    thread_id uuid NOT NULL,
    organization_id uuid NOT NULL,
    sender_id uuid NOT NULL,
    content text NOT NULL,
    metadata jsonb DEFAULT '{}'::jsonb NOT NULL,
    created_at timestamp with time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.chat_messages OWNER TO postgres;

--
-- Name: chat_thread_participants; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.chat_thread_participants (
    id uuid DEFAULT gen_random_uuid() NOT NULL,
    thread_id uuid NOT NULL,
    user_id uuid NOT NULL,
    added_at timestamp with time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.chat_thread_participants OWNER TO postgres;

--
-- Name: chat_threads; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.chat_threads (
    id uuid DEFAULT gen_random_uuid() NOT NULL,
    organization_id uuid NOT NULL,
    created_by uuid,
    name text,
    is_private boolean DEFAULT false NOT NULL,
    created_at timestamp with time zone DEFAULT now() NOT NULL,
    updated_at timestamp with time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.chat_threads OWNER TO postgres;

--
-- Name: chatbot_knowledge_base; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.chatbot_knowledge_base (
    id uuid DEFAULT gen_random_uuid() NOT NULL,
    language text NOT NULL,
    content_type text NOT NULL,
    title text,
    data jsonb DEFAULT '{}'::jsonb NOT NULL,
    is_active boolean DEFAULT true NOT NULL,
    display_order integer DEFAULT 0,
    created_at timestamp with time zone DEFAULT now() NOT NULL,
    updated_at timestamp with time zone DEFAULT now() NOT NULL,
    created_by uuid,
    updated_by uuid,
    CONSTRAINT chatbot_knowledge_base_content_type_check CHECK ((content_type = ANY (ARRAY['company'::text, 'services'::text, 'sectors'::text, 'integrations'::text, 'features'::text, 'stats'::text, 'contact'::text]))),
    CONSTRAINT chatbot_knowledge_base_language_check CHECK ((language = ANY (ARRAY['ar'::text, 'en'::text])))
);


ALTER TABLE public.chatbot_knowledge_base OWNER TO postgres;

--
-- Name: detection_rules; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.detection_rules (
    id uuid DEFAULT gen_random_uuid() NOT NULL,
    organization_id uuid,
    name text NOT NULL,
    description text,
    object_types text[],
    min_confidence numeric(5,2) DEFAULT 0.6 NOT NULL,
    cooldown_seconds integer DEFAULT 60,
    notification_channels text[],
    created_at timestamp with time zone DEFAULT now(),
    updated_at timestamp with time zone DEFAULT now()
);


ALTER TABLE public.detection_rules OWNER TO postgres;

--
-- Name: event_types; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.event_types (
    id uuid DEFAULT gen_random_uuid() NOT NULL,
    name_en text NOT NULL,
    name_ar text NOT NULL,
    description_en text,
    description_ar text,
    icon text DEFAULT 'alert-circle'::text,
    color text DEFAULT '#3b82f6'::text,
    enabled boolean DEFAULT true NOT NULL,
    created_at timestamp with time zone DEFAULT now() NOT NULL,
    updated_at timestamp with time zone DEFAULT now() NOT NULL,
    created_by uuid,
    feature_key text,
    kind text DEFAULT 'rule'::text,
    default_config jsonb DEFAULT '{}'::jsonb,
    available boolean DEFAULT true,
    sector text DEFAULT 'general'::text
);


ALTER TABLE public.event_types OWNER TO postgres;

--
-- Name: events; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.events (
    id uuid DEFAULT gen_random_uuid() NOT NULL,
    camera_id uuid,
    event_type text NOT NULL,
    severity text DEFAULT 'info'::text NOT NULL,
    metadata jsonb,
    snapshot_url text,
    detected_at timestamp with time zone DEFAULT now(),
    reviewed boolean DEFAULT false NOT NULL,
    attributes jsonb DEFAULT '{}'::jsonb,
    face_id text,
    license_plate text,
    zones text[],
    sub_label text,
    top_score double precision,
    start_time timestamp with time zone,
    end_time timestamp with time zone,
    has_clip boolean DEFAULT false,
    has_snapshot boolean DEFAULT false,
    frigate_id text
);


ALTER TABLE public.events OWNER TO postgres;

--
-- Name: form_assignments; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.form_assignments (
    id uuid DEFAULT gen_random_uuid() NOT NULL,
    workflow_form_id uuid NOT NULL,
    organization_id uuid NOT NULL,
    representative_id uuid NOT NULL,
    assigned_by uuid,
    due_date timestamp with time zone,
    reminder_frequency text DEFAULT 'daily'::text,
    is_active boolean DEFAULT true NOT NULL,
    created_at timestamp with time zone DEFAULT now() NOT NULL,
    updated_at timestamp with time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.form_assignments OWNER TO postgres;

--
-- Name: form_distribution_settings; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.form_distribution_settings (
    id uuid DEFAULT gen_random_uuid() NOT NULL,
    workflow_form_id uuid,
    distribution_type text NOT NULL,
    target_groups jsonb DEFAULT '[]'::jsonb,
    target_users jsonb DEFAULT '[]'::jsonb,
    schedule_type text DEFAULT 'immediate'::text,
    schedule_data jsonb DEFAULT '{}'::jsonb,
    notification_settings jsonb DEFAULT '{"push": true, "email": true}'::jsonb,
    created_by uuid,
    created_at timestamp with time zone DEFAULT now(),
    updated_at timestamp with time zone DEFAULT now()
);


ALTER TABLE public.form_distribution_settings OWNER TO postgres;

--
-- Name: form_submissions; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.form_submissions (
    id uuid DEFAULT gen_random_uuid() NOT NULL,
    form_assignment_id uuid NOT NULL,
    submitted_data jsonb DEFAULT '{}'::jsonb NOT NULL,
    submitted_at timestamp with time zone DEFAULT now() NOT NULL,
    submitted_by uuid,
    status text DEFAULT 'in_progress'::text NOT NULL
);


ALTER TABLE public.form_submissions OWNER TO postgres;

--
-- Name: frigate_alert_rules; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.frigate_alert_rules (
    id uuid DEFAULT gen_random_uuid() NOT NULL,
    camera_id uuid,
    rule_name text NOT NULL,
    object_types text[] DEFAULT '{}'::text[],
    zones text[] DEFAULT '{}'::text[],
    min_confidence double precision DEFAULT 0.7,
    cooldown_seconds integer DEFAULT 60,
    notification_methods jsonb DEFAULT '{"push": true, "email": false}'::jsonb,
    enabled boolean DEFAULT true NOT NULL,
    created_at timestamp with time zone DEFAULT now() NOT NULL,
    updated_at timestamp with time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.frigate_alert_rules OWNER TO postgres;

--
-- Name: frigate_deployed_models; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.frigate_deployed_models (
    id uuid DEFAULT gen_random_uuid() NOT NULL,
    frigate_instance_id uuid NOT NULL,
    model_id text NOT NULL,
    model_name text NOT NULL,
    category text NOT NULL,
    labels jsonb DEFAULT '[]'::jsonb NOT NULL,
    onnx_path text,
    pt_path text,
    config_snippet text,
    runtime text DEFAULT 'cpu'::text,
    status text DEFAULT 'pending'::text,
    download_url text,
    license text,
    accuracy jsonb,
    error_message text,
    deployed_at timestamp with time zone,
    applied_to_cameras text[] DEFAULT ARRAY[]::text[],
    created_at timestamp with time zone DEFAULT now(),
    updated_at timestamp with time zone DEFAULT now()
);


ALTER TABLE public.frigate_deployed_models OWNER TO postgres;

--
-- Name: frigate_exports; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.frigate_exports (
    id uuid DEFAULT gen_random_uuid() NOT NULL,
    export_id text NOT NULL,
    frigate_instance_id uuid NOT NULL,
    camera text NOT NULL,
    start_time timestamp with time zone NOT NULL,
    end_time timestamp with time zone NOT NULL,
    path text,
    status text,
    url text,
    metadata jsonb,
    created_at timestamp with time zone DEFAULT now() NOT NULL,
    updated_at timestamp with time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.frigate_exports OWNER TO postgres;

--
-- Name: frigate_faces; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.frigate_faces (
    id text NOT NULL,
    camera_id uuid,
    embedding jsonb,
    label text,
    confidence double precision DEFAULT 0.0 NOT NULL,
    thumbnail_url text,
    created_at timestamp with time zone DEFAULT now() NOT NULL,
    updated_at timestamp with time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.frigate_faces OWNER TO postgres;

--
-- Name: frigate_instances; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.frigate_instances (
    id uuid DEFAULT gen_random_uuid() NOT NULL,
    branch_id uuid NOT NULL,
    name text NOT NULL,
    description text,
    host_url text NOT NULL,
    api_key text,
    config_yaml text,
    enabled boolean DEFAULT true NOT NULL,
    last_sync_at timestamp with time zone,
    created_at timestamp with time zone DEFAULT now() NOT NULL,
    updated_at timestamp with time zone DEFAULT now() NOT NULL,
    sync_interval_seconds integer DEFAULT 300
);


ALTER TABLE public.frigate_instances OWNER TO postgres;

--
-- Name: COLUMN frigate_instances.sync_interval_seconds; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.frigate_instances.sync_interval_seconds IS 'Synchronization interval in seconds for Frigate data sync';


--
-- Name: frigate_license_plates; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.frigate_license_plates (
    id text NOT NULL,
    plate_number text NOT NULL,
    camera_id uuid,
    confidence double precision DEFAULT 0.0 NOT NULL,
    region text,
    vehicle_make text,
    vehicle_model text,
    vehicle_color text,
    thumbnail_url text,
    created_at timestamp with time zone DEFAULT now() NOT NULL,
    updated_at timestamp with time zone DEFAULT now() NOT NULL,
    frigate_instance_id uuid,
    is_watchlisted boolean DEFAULT false,
    watchlist_notes text,
    recognized_count integer DEFAULT 0,
    last_seen_at timestamp with time zone
);


ALTER TABLE public.frigate_license_plates OWNER TO postgres;

--
-- Name: frigate_model_deployments; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.frigate_model_deployments (
    id uuid DEFAULT gen_random_uuid() NOT NULL,
    model_id text NOT NULL,
    frigate_instance_id uuid NOT NULL,
    deployment_status text DEFAULT 'pending'::text,
    applied_to_cameras text[] DEFAULT ARRAY[]::text[],
    applied_zones jsonb DEFAULT '[]'::jsonb,
    runtime text DEFAULT 'cpu'::text,
    threshold real DEFAULT 0.5,
    remote_path text,
    config_snippet text,
    last_sync_at timestamp with time zone,
    last_verified_at timestamp with time zone,
    last_event_count integer DEFAULT 0,
    error_message text,
    deployed_by uuid,
    deployed_at timestamp with time zone,
    created_at timestamp with time zone DEFAULT now(),
    updated_at timestamp with time zone DEFAULT now()
);


ALTER TABLE public.frigate_model_deployments OWNER TO postgres;

--
-- Name: frigate_model_registry; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.frigate_model_registry (
    id uuid DEFAULT gen_random_uuid() NOT NULL,
    model_id text NOT NULL,
    name_ar text NOT NULL,
    name_en text NOT NULL,
    category text NOT NULL,
    sector_ar text,
    description_ar text,
    publisher text NOT NULL,
    source_url text NOT NULL,
    framework text NOT NULL,
    labels jsonb DEFAULT '[]'::jsonb NOT NULL,
    label_to_frigate jsonb DEFAULT '{}'::jsonb NOT NULL,
    license text NOT NULL,
    commercial_ok boolean DEFAULT true,
    preferred_runtime text[] DEFAULT ARRAY['cpu'::text],
    accuracy jsonb,
    last_updated date,
    stars integer,
    recommendation text DEFAULT 'alternate'::text,
    compliance_note_ar text,
    storage_path text,
    storage_size_bytes bigint,
    storage_etag text,
    storage_updated_at timestamp with time zone,
    formats jsonb DEFAULT '[]'::jsonb,
    frigate_config_yaml text,
    status text DEFAULT 'available'::text,
    download_count integer DEFAULT 0,
    created_at timestamp with time zone DEFAULT now(),
    updated_at timestamp with time zone DEFAULT now()
);


ALTER TABLE public.frigate_model_registry OWNER TO postgres;

--
-- Name: frigate_model_sync_log; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.frigate_model_sync_log (
    id uuid DEFAULT gen_random_uuid() NOT NULL,
    sync_type text NOT NULL,
    model_id text,
    frigate_instance_id uuid,
    status text NOT NULL,
    bytes_transferred bigint,
    duration_ms integer,
    error_message text,
    metadata jsonb DEFAULT '{}'::jsonb,
    started_at timestamp with time zone DEFAULT now(),
    completed_at timestamp with time zone
);


ALTER TABLE public.frigate_model_sync_log OWNER TO postgres;

--
-- Name: frigate_previews; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.frigate_previews (
    id uuid DEFAULT gen_random_uuid() NOT NULL,
    preview_id text NOT NULL,
    frigate_instance_id uuid NOT NULL,
    camera text NOT NULL,
    start_time timestamp with time zone NOT NULL,
    end_time timestamp with time zone NOT NULL,
    path text,
    url text,
    metadata jsonb,
    created_at timestamp with time zone DEFAULT now() NOT NULL,
    updated_at timestamp with time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.frigate_previews OWNER TO postgres;

--
-- Name: frigate_recordings; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.frigate_recordings (
    id uuid DEFAULT gen_random_uuid() NOT NULL,
    recording_id text NOT NULL,
    frigate_instance_id uuid NOT NULL,
    camera text NOT NULL,
    start_time timestamp with time zone NOT NULL,
    end_time timestamp with time zone NOT NULL,
    duration integer,
    size bigint,
    path text,
    url text,
    metadata jsonb,
    created_at timestamp with time zone DEFAULT now() NOT NULL,
    updated_at timestamp with time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.frigate_recordings OWNER TO postgres;

--
-- Name: frigate_reviews; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.frigate_reviews (
    id uuid DEFAULT gen_random_uuid() NOT NULL,
    review_id text NOT NULL,
    frigate_instance_id uuid NOT NULL,
    camera text NOT NULL,
    start_time timestamp with time zone NOT NULL,
    end_time timestamp with time zone NOT NULL,
    severity text,
    has_been_reviewed boolean DEFAULT false,
    data jsonb,
    metadata jsonb,
    created_at timestamp with time zone DEFAULT now() NOT NULL,
    updated_at timestamp with time zone DEFAULT now() NOT NULL,
    frigate_review_id text,
    reviewed boolean DEFAULT false,
    reviewed_by uuid,
    reviewed_at timestamp with time zone,
    thumb_path text
);


ALTER TABLE public.frigate_reviews OWNER TO postgres;

--
-- Name: frigate_stats_history; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.frigate_stats_history (
    id uuid DEFAULT gen_random_uuid() NOT NULL,
    frigate_instance_id uuid,
    recorded_at timestamp with time zone DEFAULT now(),
    cpu_usages jsonb,
    gpu_usages jsonb,
    memory_usage jsonb,
    detector_speeds jsonb,
    camera_fps jsonb,
    service_info jsonb
);


ALTER TABLE public.frigate_stats_history OWNER TO postgres;

--
-- Name: frigate_sync_logs; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.frigate_sync_logs (
    id uuid DEFAULT gen_random_uuid() NOT NULL,
    frigate_instance_id uuid,
    sync_type text NOT NULL,
    status text DEFAULT 'started'::text NOT NULL,
    events_processed integer DEFAULT 0,
    events_inserted integer DEFAULT 0,
    events_skipped integer DEFAULT 0,
    duration_ms integer,
    error_message text,
    started_at timestamp with time zone DEFAULT now(),
    completed_at timestamp with time zone
);


ALTER TABLE public.frigate_sync_logs OWNER TO postgres;

--
-- Name: frigate_timeline; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.frigate_timeline (
    id uuid DEFAULT gen_random_uuid() NOT NULL,
    camera_id uuid,
    start_time timestamp with time zone NOT NULL,
    end_time timestamp with time zone NOT NULL,
    segment_type text DEFAULT 'recording'::text NOT NULL,
    file_path text,
    duration_seconds integer,
    created_at timestamp with time zone DEFAULT now() NOT NULL,
    frigate_instance_id uuid,
    class_type text,
    data jsonb,
    metadata jsonb,
    entry_id text
);


ALTER TABLE public.frigate_timeline OWNER TO postgres;

--
-- Name: frigate_triggers; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.frigate_triggers (
    id uuid DEFAULT gen_random_uuid() NOT NULL,
    frigate_instance_id uuid,
    camera text NOT NULL,
    name text NOT NULL,
    description text,
    trigger_type text DEFAULT 'text'::text,
    similarity_threshold real DEFAULT 0.7,
    enabled boolean DEFAULT true,
    last_triggered_at timestamp with time zone,
    actions jsonb DEFAULT '[]'::jsonb,
    created_at timestamp with time zone DEFAULT now()
);


ALTER TABLE public.frigate_triggers OWNER TO postgres;

--
-- Name: frigate_zones; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.frigate_zones (
    id uuid DEFAULT gen_random_uuid() NOT NULL,
    camera_id uuid,
    name text NOT NULL,
    coordinates jsonb NOT NULL,
    zone_type text DEFAULT 'detection'::text NOT NULL,
    enabled boolean DEFAULT true NOT NULL,
    color text DEFAULT '#3b82f6'::text,
    created_at timestamp with time zone DEFAULT now() NOT NULL,
    updated_at timestamp with time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.frigate_zones OWNER TO postgres;

--
-- Name: health_alerts; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.health_alerts (
    id uuid DEFAULT gen_random_uuid() NOT NULL,
    student_id uuid,
    alert_type text NOT NULL,
    value numeric,
    severity text DEFAULT 'high'::text,
    note text DEFAULT ''::text,
    detected_at timestamp with time zone DEFAULT now(),
    notified boolean DEFAULT false,
    resolved boolean DEFAULT false
);


ALTER TABLE public.health_alerts OWNER TO postgres;

--
-- Name: industries; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.industries (
    id uuid DEFAULT gen_random_uuid() NOT NULL,
    name text NOT NULL,
    name_ar text NOT NULL,
    description text,
    description_ar text,
    icon text DEFAULT 'building'::text,
    active boolean DEFAULT true NOT NULL,
    created_at timestamp with time zone DEFAULT now() NOT NULL,
    updated_at timestamp with time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.industries OWNER TO postgres;

--
-- Name: legal_documents; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.legal_documents (
    id uuid DEFAULT gen_random_uuid() NOT NULL,
    document_type text NOT NULL,
    title text NOT NULL,
    content text NOT NULL,
    version integer DEFAULT 1 NOT NULL,
    effective_date timestamp with time zone DEFAULT now() NOT NULL,
    created_at timestamp with time zone DEFAULT now() NOT NULL,
    updated_at timestamp with time zone DEFAULT now() NOT NULL,
    created_by uuid,
    updated_by uuid,
    CONSTRAINT legal_documents_document_type_check CHECK ((document_type = ANY (ARRAY['terms_of_service'::text, 'privacy_policy'::text])))
);


ALTER TABLE public.legal_documents OWNER TO postgres;

--
-- Name: network_scan_results; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.network_scan_results (
    id uuid DEFAULT gen_random_uuid() NOT NULL,
    ip_address inet NOT NULL,
    port integer NOT NULL,
    manufacturer text,
    model text,
    device_type text,
    protocol text,
    mac_address text,
    hostname text,
    discovered_at timestamp with time zone DEFAULT now() NOT NULL,
    scan_session_id uuid NOT NULL,
    user_id uuid
);


ALTER TABLE public.network_scan_results OWNER TO postgres;

--
-- Name: notification_labels; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.notification_labels (
    id uuid DEFAULT gen_random_uuid() NOT NULL,
    type text NOT NULL,
    name_ar text NOT NULL,
    name_en text,
    is_active boolean DEFAULT true NOT NULL,
    created_at timestamp with time zone DEFAULT now() NOT NULL,
    updated_at timestamp with time zone DEFAULT now() NOT NULL,
    created_by uuid
);


ALTER TABLE public.notification_labels OWNER TO postgres;

--
-- Name: notification_methods; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.notification_methods (
    id uuid DEFAULT gen_random_uuid() NOT NULL,
    name_ar text NOT NULL,
    name_en text NOT NULL,
    type text NOT NULL,
    icon text DEFAULT 'bell'::text,
    enabled boolean DEFAULT true NOT NULL,
    settings jsonb DEFAULT '{}'::jsonb,
    created_at timestamp with time zone DEFAULT now() NOT NULL,
    updated_at timestamp with time zone DEFAULT now() NOT NULL,
    created_by uuid,
    CONSTRAINT notification_methods_type_check CHECK ((type = ANY (ARRAY['whatsapp'::text, 'email'::text, 'phone'::text, 'sms'::text])))
);


ALTER TABLE public.notification_methods OWNER TO postgres;

--
-- Name: organization_settings; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.organization_settings (
    id uuid DEFAULT gen_random_uuid() NOT NULL,
    organization_id uuid NOT NULL,
    setting_key text NOT NULL,
    setting_value jsonb NOT NULL,
    description text,
    created_at timestamp with time zone DEFAULT now() NOT NULL,
    updated_at timestamp with time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.organization_settings OWNER TO postgres;

--
-- Name: organizations; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.organizations (
    id uuid DEFAULT gen_random_uuid() NOT NULL,
    name text NOT NULL,
    subscription_tier public.subscription_tier DEFAULT 'basic'::public.subscription_tier NOT NULL,
    max_cameras integer DEFAULT 5 NOT NULL,
    active boolean DEFAULT true NOT NULL,
    created_at timestamp with time zone DEFAULT now(),
    updated_at timestamp with time zone DEFAULT now(),
    subscription_limits jsonb DEFAULT '{"users": 3, "cameras": 5, "branches": 1, "storage_gb": 10, "ai_detections_per_month": 1000}'::jsonb,
    max_branches integer DEFAULT 1,
    features jsonb DEFAULT '{"analytics": false, "recording": false, "ai_detection": true, "live_streaming": true}'::jsonb,
    subscription_status text DEFAULT 'pending'::text,
    industry_id uuid
);


ALTER TABLE public.organizations OWNER TO postgres;

--
-- Name: pinned_dashboards; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.pinned_dashboards (
    id uuid DEFAULT gen_random_uuid() NOT NULL,
    user_id uuid NOT NULL,
    instance_id uuid NOT NULL,
    name text,
    path text DEFAULT '/lovelace/default_view?kiosk'::text NOT NULL,
    x integer DEFAULT 0 NOT NULL,
    y integer DEFAULT 0 NOT NULL,
    width integer DEFAULT 600 NOT NULL,
    height integer DEFAULT 400 NOT NULL,
    order_index integer DEFAULT 0 NOT NULL,
    created_at timestamp with time zone DEFAULT now() NOT NULL,
    updated_at timestamp with time zone DEFAULT now() NOT NULL,
    zoom numeric DEFAULT 1.0 NOT NULL
);


ALTER TABLE public.pinned_dashboards OWNER TO postgres;

--
-- Name: pinned_labels; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.pinned_labels (
    id uuid DEFAULT gen_random_uuid() NOT NULL,
    user_id uuid NOT NULL,
    text text DEFAULT 'Label'::text NOT NULL,
    color text DEFAULT '#111827'::text NOT NULL,
    font_size integer DEFAULT 16 NOT NULL,
    x integer DEFAULT 40 NOT NULL,
    y integer DEFAULT 40 NOT NULL,
    created_at timestamp with time zone DEFAULT now() NOT NULL,
    updated_at timestamp with time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.pinned_labels OWNER TO postgres;

--
-- Name: screen_permissions; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.screen_permissions (
    id uuid DEFAULT gen_random_uuid() NOT NULL,
    screen_key text NOT NULL,
    path text NOT NULL,
    title_en text,
    title_ar text,
    description_en text,
    description_ar text,
    allowed_roles text[] DEFAULT '{}'::text[] NOT NULL,
    allow_super_admin boolean DEFAULT true NOT NULL,
    is_active boolean DEFAULT true NOT NULL,
    created_by uuid,
    created_at timestamp with time zone DEFAULT now() NOT NULL,
    updated_at timestamp with time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.screen_permissions OWNER TO postgres;

--
-- Name: security_zones; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.security_zones (
    id uuid DEFAULT gen_random_uuid() NOT NULL,
    branch_id uuid,
    name text NOT NULL,
    description text,
    coordinates jsonb,
    sensitivity_level integer DEFAULT 5,
    active_hours jsonb,
    created_at timestamp with time zone DEFAULT now(),
    updated_at timestamp with time zone DEFAULT now(),
    active boolean DEFAULT true NOT NULL
);


ALTER TABLE public.security_zones OWNER TO postgres;

--
-- Name: storage_configs; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.storage_configs (
    id uuid DEFAULT gen_random_uuid() NOT NULL,
    name text NOT NULL,
    type text NOT NULL,
    config jsonb DEFAULT '{}'::jsonb NOT NULL,
    is_active boolean DEFAULT false NOT NULL,
    created_at timestamp with time zone DEFAULT now() NOT NULL,
    updated_at timestamp with time zone DEFAULT now() NOT NULL,
    created_by uuid,
    CONSTRAINT storage_configs_type_check CHECK ((type = ANY (ARRAY['google_drive'::text, 'ftp'::text, 'aws_s3'::text, 'local'::text])))
);


ALTER TABLE public.storage_configs OWNER TO postgres;

--
-- Name: students; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.students (
    id uuid DEFAULT gen_random_uuid() NOT NULL,
    organization_id uuid,
    branch_id uuid,
    name text NOT NULL,
    condition text,
    guardian_phone text,
    clinic_phone text,
    wearable_id text,
    created_at timestamp with time zone DEFAULT now()
);


ALTER TABLE public.students OWNER TO postgres;

--
-- Name: subscribers; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.subscribers (
    id uuid DEFAULT gen_random_uuid() NOT NULL,
    user_id uuid,
    email text NOT NULL,
    stripe_customer_id text,
    subscribed boolean DEFAULT false NOT NULL,
    subscription_tier public.subscription_tier DEFAULT 'basic'::public.subscription_tier,
    subscription_end timestamp with time zone,
    usage_analytics jsonb DEFAULT '{}'::jsonb,
    billing_cycle text DEFAULT 'monthly'::text,
    created_at timestamp with time zone DEFAULT now() NOT NULL,
    updated_at timestamp with time zone DEFAULT now() NOT NULL,
    subscription_status text DEFAULT 'pending'::text,
    approved_by uuid,
    approved_at timestamp with time zone,
    last_activity timestamp with time zone DEFAULT now(),
    notes text,
    organization_id uuid
);


ALTER TABLE public.subscribers OWNER TO postgres;

--
-- Name: system_settings; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.system_settings (
    id uuid DEFAULT gen_random_uuid() NOT NULL,
    setting_key text NOT NULL,
    setting_value jsonb DEFAULT '{}'::jsonb NOT NULL,
    description text,
    created_at timestamp with time zone DEFAULT now() NOT NULL,
    updated_at timestamp with time zone DEFAULT now() NOT NULL,
    updated_by uuid
);


ALTER TABLE public.system_settings OWNER TO postgres;

--
-- Name: user_branch_access; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.user_branch_access (
    id uuid DEFAULT gen_random_uuid() NOT NULL,
    user_id uuid,
    branch_id uuid,
    granted_by uuid,
    granted_at timestamp with time zone DEFAULT now()
);


ALTER TABLE public.user_branch_access OWNER TO postgres;

--
-- Name: user_group_members; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.user_group_members (
    id uuid DEFAULT gen_random_uuid() NOT NULL,
    group_id uuid,
    user_role_id uuid,
    added_by uuid,
    added_at timestamp with time zone DEFAULT now()
);


ALTER TABLE public.user_group_members OWNER TO postgres;

--
-- Name: user_groups; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.user_groups (
    id uuid DEFAULT gen_random_uuid() NOT NULL,
    name text NOT NULL,
    description text,
    organization_id uuid,
    group_type text DEFAULT 'custom'::text NOT NULL,
    metadata jsonb DEFAULT '{}'::jsonb,
    created_by uuid,
    created_at timestamp with time zone DEFAULT now(),
    updated_at timestamp with time zone DEFAULT now()
);


ALTER TABLE public.user_groups OWNER TO postgres;

--
-- Name: user_preferences; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.user_preferences (
    id uuid DEFAULT gen_random_uuid() NOT NULL,
    user_id uuid,
    language text DEFAULT 'en'::text,
    timezone text DEFAULT 'UTC'::text,
    theme text DEFAULT 'system'::text,
    notifications jsonb DEFAULT '{"sms": false, "push": true, "email": true}'::jsonb,
    created_at timestamp with time zone DEFAULT now() NOT NULL,
    updated_at timestamp with time zone DEFAULT now() NOT NULL,
    ui_language text,
    tts_language text,
    CONSTRAINT user_preferences_language_check CHECK ((language = ANY (ARRAY['en'::text, 'ar'::text, 'uk'::text, 'vi'::text])))
);


ALTER TABLE public.user_preferences OWNER TO postgres;

--
-- Name: user_roles; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.user_roles (
    id uuid DEFAULT gen_random_uuid() NOT NULL,
    user_id uuid,
    organization_id uuid,
    role public.user_role NOT NULL,
    created_at timestamp with time zone DEFAULT now(),
    permissions jsonb DEFAULT '{"manage_users": false, "view_cameras": true, "view_analytics": true, "manage_settings": false}'::jsonb,
    granted_by uuid,
    granted_at timestamp with time zone DEFAULT now(),
    notification_type text,
    notification_value text,
    name text,
    CONSTRAINT user_roles_notification_type_check CHECK ((notification_type = ANY (ARRAY['whatsapp'::text, 'email'::text, 'phone'::text, 'sms'::text])))
);


ALTER TABLE public.user_roles OWNER TO postgres;

--
-- Name: workflow_forms; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.workflow_forms (
    id uuid DEFAULT gen_random_uuid() NOT NULL,
    name text NOT NULL,
    name_ar text NOT NULL,
    description text,
    description_ar text,
    activity_type text NOT NULL,
    form_fields jsonb DEFAULT '[]'::jsonb NOT NULL,
    is_active boolean DEFAULT true NOT NULL,
    created_by uuid,
    created_at timestamp with time zone DEFAULT now() NOT NULL,
    updated_at timestamp with time zone DEFAULT now() NOT NULL,
    logo_url text
);


ALTER TABLE public.workflow_forms OWNER TO postgres;

--
-- Name: messages; Type: TABLE; Schema: realtime; Owner: supabase_realtime_admin
--

CREATE TABLE realtime.messages (
    topic text NOT NULL,
    extension text NOT NULL,
    payload jsonb,
    event text,
    private boolean DEFAULT false,
    updated_at timestamp without time zone DEFAULT now() NOT NULL,
    inserted_at timestamp without time zone DEFAULT now() NOT NULL,
    id uuid DEFAULT gen_random_uuid() NOT NULL,
    binary_payload bytea
)
PARTITION BY RANGE (inserted_at);


ALTER TABLE realtime.messages OWNER TO supabase_realtime_admin;

--
-- Name: messages_2026_07_02; Type: TABLE; Schema: realtime; Owner: supabase_admin
--

CREATE TABLE realtime.messages_2026_07_02 (
    topic text NOT NULL,
    extension text NOT NULL,
    payload jsonb,
    event text,
    private boolean DEFAULT false,
    updated_at timestamp without time zone DEFAULT now() NOT NULL,
    inserted_at timestamp without time zone DEFAULT now() NOT NULL,
    id uuid DEFAULT gen_random_uuid() NOT NULL,
    binary_payload bytea,
    CONSTRAINT messages_payload_exclusive CHECK (((payload IS NULL) OR (binary_payload IS NULL)))
);


ALTER TABLE realtime.messages_2026_07_02 OWNER TO supabase_admin;

--
-- Name: messages_2026_07_03; Type: TABLE; Schema: realtime; Owner: supabase_admin
--

CREATE TABLE realtime.messages_2026_07_03 (
    topic text NOT NULL,
    extension text NOT NULL,
    payload jsonb,
    event text,
    private boolean DEFAULT false,
    updated_at timestamp without time zone DEFAULT now() NOT NULL,
    inserted_at timestamp without time zone DEFAULT now() NOT NULL,
    id uuid DEFAULT gen_random_uuid() NOT NULL,
    binary_payload bytea,
    CONSTRAINT messages_payload_exclusive CHECK (((payload IS NULL) OR (binary_payload IS NULL)))
);


ALTER TABLE realtime.messages_2026_07_03 OWNER TO supabase_admin;

--
-- Name: messages_2026_07_04; Type: TABLE; Schema: realtime; Owner: supabase_admin
--

CREATE TABLE realtime.messages_2026_07_04 (
    topic text NOT NULL,
    extension text NOT NULL,
    payload jsonb,
    event text,
    private boolean DEFAULT false,
    updated_at timestamp without time zone DEFAULT now() NOT NULL,
    inserted_at timestamp without time zone DEFAULT now() NOT NULL,
    id uuid DEFAULT gen_random_uuid() NOT NULL,
    binary_payload bytea,
    CONSTRAINT messages_payload_exclusive CHECK (((payload IS NULL) OR (binary_payload IS NULL)))
);


ALTER TABLE realtime.messages_2026_07_04 OWNER TO supabase_admin;

--
-- Name: messages_2026_07_05; Type: TABLE; Schema: realtime; Owner: supabase_admin
--

CREATE TABLE realtime.messages_2026_07_05 (
    topic text NOT NULL,
    extension text NOT NULL,
    payload jsonb,
    event text,
    private boolean DEFAULT false,
    updated_at timestamp without time zone DEFAULT now() NOT NULL,
    inserted_at timestamp without time zone DEFAULT now() NOT NULL,
    id uuid DEFAULT gen_random_uuid() NOT NULL,
    binary_payload bytea,
    CONSTRAINT messages_payload_exclusive CHECK (((payload IS NULL) OR (binary_payload IS NULL)))
);


ALTER TABLE realtime.messages_2026_07_05 OWNER TO supabase_admin;

--
-- Name: messages_2026_07_06; Type: TABLE; Schema: realtime; Owner: supabase_admin
--

CREATE TABLE realtime.messages_2026_07_06 (
    topic text NOT NULL,
    extension text NOT NULL,
    payload jsonb,
    event text,
    private boolean DEFAULT false,
    updated_at timestamp without time zone DEFAULT now() NOT NULL,
    inserted_at timestamp without time zone DEFAULT now() NOT NULL,
    id uuid DEFAULT gen_random_uuid() NOT NULL,
    binary_payload bytea,
    CONSTRAINT messages_payload_exclusive CHECK (((payload IS NULL) OR (binary_payload IS NULL)))
);


ALTER TABLE realtime.messages_2026_07_06 OWNER TO supabase_admin;

--
-- Name: messages_2026_07_07; Type: TABLE; Schema: realtime; Owner: supabase_admin
--

CREATE TABLE realtime.messages_2026_07_07 (
    topic text NOT NULL,
    extension text NOT NULL,
    payload jsonb,
    event text,
    private boolean DEFAULT false,
    updated_at timestamp without time zone DEFAULT now() NOT NULL,
    inserted_at timestamp without time zone DEFAULT now() NOT NULL,
    id uuid DEFAULT gen_random_uuid() NOT NULL,
    binary_payload bytea,
    CONSTRAINT messages_payload_exclusive CHECK (((payload IS NULL) OR (binary_payload IS NULL)))
);


ALTER TABLE realtime.messages_2026_07_07 OWNER TO supabase_admin;

--
-- Name: messages_2026_07_08; Type: TABLE; Schema: realtime; Owner: supabase_admin
--

CREATE TABLE realtime.messages_2026_07_08 (
    topic text NOT NULL,
    extension text NOT NULL,
    payload jsonb,
    event text,
    private boolean DEFAULT false,
    updated_at timestamp without time zone DEFAULT now() NOT NULL,
    inserted_at timestamp without time zone DEFAULT now() NOT NULL,
    id uuid DEFAULT gen_random_uuid() NOT NULL,
    binary_payload bytea,
    CONSTRAINT messages_payload_exclusive CHECK (((payload IS NULL) OR (binary_payload IS NULL)))
);


ALTER TABLE realtime.messages_2026_07_08 OWNER TO supabase_admin;

--
-- Name: schema_migrations; Type: TABLE; Schema: realtime; Owner: supabase_admin
--

CREATE TABLE realtime.schema_migrations (
    version bigint NOT NULL,
    inserted_at timestamp(0) without time zone
);


ALTER TABLE realtime.schema_migrations OWNER TO supabase_admin;

--
-- Name: subscription; Type: TABLE; Schema: realtime; Owner: supabase_admin
--

CREATE TABLE realtime.subscription (
    id bigint NOT NULL,
    subscription_id uuid NOT NULL,
    entity regclass NOT NULL,
    filters realtime.user_defined_filter[] DEFAULT '{}'::realtime.user_defined_filter[] NOT NULL,
    claims jsonb NOT NULL,
    claims_role regrole GENERATED ALWAYS AS (realtime.to_regrole((claims ->> 'role'::text))) STORED NOT NULL,
    created_at timestamp without time zone DEFAULT timezone('utc'::text, now()) NOT NULL,
    action_filter text DEFAULT '*'::text,
    selected_columns text[],
    CONSTRAINT subscription_action_filter_check CHECK ((action_filter = ANY (ARRAY['*'::text, 'INSERT'::text, 'UPDATE'::text, 'DELETE'::text])))
);


ALTER TABLE realtime.subscription OWNER TO supabase_admin;

--
-- Name: subscription_id_seq; Type: SEQUENCE; Schema: realtime; Owner: supabase_admin
--

ALTER TABLE realtime.subscription ALTER COLUMN id ADD GENERATED ALWAYS AS IDENTITY (
    SEQUENCE NAME realtime.subscription_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1
);


--
-- Name: buckets; Type: TABLE; Schema: storage; Owner: supabase_storage_admin
--

CREATE TABLE storage.buckets (
    id text NOT NULL,
    name text NOT NULL,
    owner uuid,
    created_at timestamp with time zone DEFAULT now(),
    updated_at timestamp with time zone DEFAULT now(),
    public boolean DEFAULT false,
    avif_autodetection boolean DEFAULT false,
    file_size_limit bigint,
    allowed_mime_types text[],
    owner_id text,
    type storage.buckettype DEFAULT 'STANDARD'::storage.buckettype NOT NULL
);


ALTER TABLE storage.buckets OWNER TO supabase_storage_admin;

--
-- Name: COLUMN buckets.owner; Type: COMMENT; Schema: storage; Owner: supabase_storage_admin
--

COMMENT ON COLUMN storage.buckets.owner IS 'Field is deprecated, use owner_id instead';


--
-- Name: buckets_analytics; Type: TABLE; Schema: storage; Owner: supabase_storage_admin
--

CREATE TABLE storage.buckets_analytics (
    name text NOT NULL,
    type storage.buckettype DEFAULT 'ANALYTICS'::storage.buckettype NOT NULL,
    format text DEFAULT 'ICEBERG'::text NOT NULL,
    created_at timestamp with time zone DEFAULT now() NOT NULL,
    updated_at timestamp with time zone DEFAULT now() NOT NULL,
    id uuid DEFAULT gen_random_uuid() NOT NULL,
    deleted_at timestamp with time zone
);


ALTER TABLE storage.buckets_analytics OWNER TO supabase_storage_admin;

--
-- Name: buckets_vectors; Type: TABLE; Schema: storage; Owner: supabase_storage_admin
--

CREATE TABLE storage.buckets_vectors (
    id text NOT NULL,
    type storage.buckettype DEFAULT 'VECTOR'::storage.buckettype NOT NULL,
    created_at timestamp with time zone DEFAULT now() NOT NULL,
    updated_at timestamp with time zone DEFAULT now() NOT NULL
);


ALTER TABLE storage.buckets_vectors OWNER TO supabase_storage_admin;

--
-- Name: iceberg_namespaces; Type: TABLE; Schema: storage; Owner: supabase_storage_admin
--

CREATE TABLE storage.iceberg_namespaces (
    id uuid DEFAULT gen_random_uuid() NOT NULL,
    bucket_name text NOT NULL,
    name text NOT NULL COLLATE pg_catalog."C",
    created_at timestamp with time zone DEFAULT now() NOT NULL,
    updated_at timestamp with time zone DEFAULT now() NOT NULL,
    metadata jsonb DEFAULT '{}'::jsonb NOT NULL,
    catalog_id uuid NOT NULL
);


ALTER TABLE storage.iceberg_namespaces OWNER TO supabase_storage_admin;

--
-- Name: iceberg_tables; Type: TABLE; Schema: storage; Owner: supabase_storage_admin
--

CREATE TABLE storage.iceberg_tables (
    id uuid DEFAULT gen_random_uuid() NOT NULL,
    namespace_id uuid NOT NULL,
    bucket_name text NOT NULL,
    name text NOT NULL COLLATE pg_catalog."C",
    location text NOT NULL,
    created_at timestamp with time zone DEFAULT now() NOT NULL,
    updated_at timestamp with time zone DEFAULT now() NOT NULL,
    remote_table_id text,
    shard_key text,
    shard_id text,
    catalog_id uuid NOT NULL
);


ALTER TABLE storage.iceberg_tables OWNER TO supabase_storage_admin;

--
-- Name: migrations; Type: TABLE; Schema: storage; Owner: supabase_storage_admin
--

CREATE TABLE storage.migrations (
    id integer NOT NULL,
    name character varying(100) NOT NULL,
    hash character varying(40) NOT NULL,
    executed_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP
);


ALTER TABLE storage.migrations OWNER TO supabase_storage_admin;

--
-- Name: objects; Type: TABLE; Schema: storage; Owner: supabase_storage_admin
--

CREATE TABLE storage.objects (
    id uuid DEFAULT gen_random_uuid() NOT NULL,
    bucket_id text,
    name text,
    owner uuid,
    created_at timestamp with time zone DEFAULT now(),
    updated_at timestamp with time zone DEFAULT now(),
    last_accessed_at timestamp with time zone DEFAULT now(),
    metadata jsonb,
    path_tokens text[] GENERATED ALWAYS AS (string_to_array(name, '/'::text)) STORED,
    version text,
    owner_id text,
    user_metadata jsonb
);


ALTER TABLE storage.objects OWNER TO supabase_storage_admin;

--
-- Name: COLUMN objects.owner; Type: COMMENT; Schema: storage; Owner: supabase_storage_admin
--

COMMENT ON COLUMN storage.objects.owner IS 'Field is deprecated, use owner_id instead';


--
-- Name: s3_multipart_uploads; Type: TABLE; Schema: storage; Owner: supabase_storage_admin
--

CREATE TABLE storage.s3_multipart_uploads (
    id text NOT NULL,
    in_progress_size bigint DEFAULT 0 NOT NULL,
    upload_signature text NOT NULL,
    bucket_id text NOT NULL,
    key text NOT NULL COLLATE pg_catalog."C",
    version text NOT NULL,
    owner_id text,
    created_at timestamp with time zone DEFAULT now() NOT NULL,
    user_metadata jsonb,
    metadata jsonb
);


ALTER TABLE storage.s3_multipart_uploads OWNER TO supabase_storage_admin;

--
-- Name: s3_multipart_uploads_parts; Type: TABLE; Schema: storage; Owner: supabase_storage_admin
--

CREATE TABLE storage.s3_multipart_uploads_parts (
    id uuid DEFAULT gen_random_uuid() NOT NULL,
    upload_id text NOT NULL,
    size bigint DEFAULT 0 NOT NULL,
    part_number integer NOT NULL,
    bucket_id text NOT NULL,
    key text NOT NULL COLLATE pg_catalog."C",
    etag text NOT NULL,
    owner_id text,
    version text NOT NULL,
    created_at timestamp with time zone DEFAULT now() NOT NULL
);


ALTER TABLE storage.s3_multipart_uploads_parts OWNER TO supabase_storage_admin;

--
-- Name: vector_indexes; Type: TABLE; Schema: storage; Owner: supabase_storage_admin
--

CREATE TABLE storage.vector_indexes (
    id text DEFAULT gen_random_uuid() NOT NULL,
    name text NOT NULL COLLATE pg_catalog."C",
    bucket_id text NOT NULL,
    data_type text NOT NULL,
    dimension integer NOT NULL,
    distance_metric text NOT NULL,
    metadata_configuration jsonb,
    created_at timestamp with time zone DEFAULT now() NOT NULL,
    updated_at timestamp with time zone DEFAULT now() NOT NULL
);


ALTER TABLE storage.vector_indexes OWNER TO supabase_storage_admin;

--
-- Name: hooks; Type: TABLE; Schema: supabase_functions; Owner: supabase_functions_admin
--

CREATE TABLE supabase_functions.hooks (
    id bigint NOT NULL,
    hook_table_id integer NOT NULL,
    hook_name text NOT NULL,
    created_at timestamp with time zone DEFAULT now() NOT NULL,
    request_id bigint
);


ALTER TABLE supabase_functions.hooks OWNER TO supabase_functions_admin;

--
-- Name: TABLE hooks; Type: COMMENT; Schema: supabase_functions; Owner: supabase_functions_admin
--

COMMENT ON TABLE supabase_functions.hooks IS 'Supabase Functions Hooks: Audit trail for triggered hooks.';


--
-- Name: hooks_id_seq; Type: SEQUENCE; Schema: supabase_functions; Owner: supabase_functions_admin
--

CREATE SEQUENCE supabase_functions.hooks_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER SEQUENCE supabase_functions.hooks_id_seq OWNER TO supabase_functions_admin;

--
-- Name: hooks_id_seq; Type: SEQUENCE OWNED BY; Schema: supabase_functions; Owner: supabase_functions_admin
--

ALTER SEQUENCE supabase_functions.hooks_id_seq OWNED BY supabase_functions.hooks.id;


--
-- Name: migrations; Type: TABLE; Schema: supabase_functions; Owner: supabase_functions_admin
--

CREATE TABLE supabase_functions.migrations (
    version text NOT NULL,
    inserted_at timestamp with time zone DEFAULT now() NOT NULL
);


ALTER TABLE supabase_functions.migrations OWNER TO supabase_functions_admin;

--
-- Name: schema_migrations; Type: TABLE; Schema: supabase_migrations; Owner: postgres
--

CREATE TABLE supabase_migrations.schema_migrations (
    version text NOT NULL,
    statements text[],
    name text
);


ALTER TABLE supabase_migrations.schema_migrations OWNER TO postgres;

--
-- Name: messages_2026_07_02; Type: TABLE ATTACH; Schema: realtime; Owner: supabase_admin
--

ALTER TABLE ONLY realtime.messages ATTACH PARTITION realtime.messages_2026_07_02 FOR VALUES FROM ('2026-07-02 00:00:00') TO ('2026-07-03 00:00:00');


--
-- Name: messages_2026_07_03; Type: TABLE ATTACH; Schema: realtime; Owner: supabase_admin
--

ALTER TABLE ONLY realtime.messages ATTACH PARTITION realtime.messages_2026_07_03 FOR VALUES FROM ('2026-07-03 00:00:00') TO ('2026-07-04 00:00:00');


--
-- Name: messages_2026_07_04; Type: TABLE ATTACH; Schema: realtime; Owner: supabase_admin
--

ALTER TABLE ONLY realtime.messages ATTACH PARTITION realtime.messages_2026_07_04 FOR VALUES FROM ('2026-07-04 00:00:00') TO ('2026-07-05 00:00:00');


--
-- Name: messages_2026_07_05; Type: TABLE ATTACH; Schema: realtime; Owner: supabase_admin
--

ALTER TABLE ONLY realtime.messages ATTACH PARTITION realtime.messages_2026_07_05 FOR VALUES FROM ('2026-07-05 00:00:00') TO ('2026-07-06 00:00:00');


--
-- Name: messages_2026_07_06; Type: TABLE ATTACH; Schema: realtime; Owner: supabase_admin
--

ALTER TABLE ONLY realtime.messages ATTACH PARTITION realtime.messages_2026_07_06 FOR VALUES FROM ('2026-07-06 00:00:00') TO ('2026-07-07 00:00:00');


--
-- Name: messages_2026_07_07; Type: TABLE ATTACH; Schema: realtime; Owner: supabase_admin
--

ALTER TABLE ONLY realtime.messages ATTACH PARTITION realtime.messages_2026_07_07 FOR VALUES FROM ('2026-07-07 00:00:00') TO ('2026-07-08 00:00:00');


--
-- Name: messages_2026_07_08; Type: TABLE ATTACH; Schema: realtime; Owner: supabase_admin
--

ALTER TABLE ONLY realtime.messages ATTACH PARTITION realtime.messages_2026_07_08 FOR VALUES FROM ('2026-07-08 00:00:00') TO ('2026-07-09 00:00:00');


--
-- Name: refresh_tokens id; Type: DEFAULT; Schema: auth; Owner: supabase_auth_admin
--

ALTER TABLE ONLY auth.refresh_tokens ALTER COLUMN id SET DEFAULT nextval('auth.refresh_tokens_id_seq'::regclass);


--
-- Name: hooks id; Type: DEFAULT; Schema: supabase_functions; Owner: supabase_functions_admin
--

ALTER TABLE ONLY supabase_functions.hooks ALTER COLUMN id SET DEFAULT nextval('supabase_functions.hooks_id_seq'::regclass);


--
-- Data for Name: extensions; Type: TABLE DATA; Schema: _realtime; Owner: supabase_admin
--

COPY _realtime.extensions (id, type, settings, tenant_external_id, inserted_at, updated_at) FROM stdin;
3565bc5e-85ff-4c91-ab47-b0f1134c9de4	postgres_cdc_rls	{"region": "us-east-1", "db_host": "TScLwIpzmULKpK6vh1rgsfK1IlaywIj1gcAFWvuvmldPNrrhma6I8nd28t/mto4/", "db_name": "sWBpZNdjggEPTQVlI52Zfw==", "db_port": "+enMDFi1J/3IrrquHHwUmA==", "db_user": "uxbEq/zz8DXVD53TOI1zmw==", "slot_name": "supabase_realtime_replication_slot", "db_password": "sWBpZNdjggEPTQVlI52Zfw==", "publication": "supabase_realtime", "ssl_enforced": false, "poll_interval_ms": 100, "poll_max_changes": 100, "poll_max_record_bytes": 1048576}	realtime-dev	2026-07-03 02:52:35	2026-07-03 02:52:35
\.


--
-- Data for Name: feature_flags; Type: TABLE DATA; Schema: _realtime; Owner: supabase_admin
--

COPY _realtime.feature_flags (id, name, enabled, inserted_at, updated_at) FROM stdin;
\.


--
-- Data for Name: schema_migrations; Type: TABLE DATA; Schema: _realtime; Owner: supabase_admin
--

COPY _realtime.schema_migrations (version, inserted_at) FROM stdin;
20210706140551	2026-06-12 00:19:48
20220329161857	2026-06-12 00:19:48
20220410212326	2026-06-12 00:19:48
20220506102948	2026-06-12 00:19:48
20220527210857	2026-06-12 00:19:48
20220815211129	2026-06-12 00:19:48
20220815215024	2026-06-12 00:19:48
20220818141501	2026-06-12 00:19:48
20221018173709	2026-06-12 00:19:48
20221102172703	2026-06-12 00:19:48
20221223010058	2026-06-12 00:19:49
20230110180046	2026-06-12 00:19:49
20230810220907	2026-06-12 00:19:49
20230810220924	2026-06-12 00:19:49
20231024094642	2026-06-12 00:19:49
20240306114423	2026-06-12 00:19:49
20240418082835	2026-06-12 00:19:49
20240625211759	2026-06-12 00:19:49
20240704172020	2026-06-12 00:19:49
20240902173232	2026-06-12 00:19:49
20241106103258	2026-06-12 00:19:49
20250424203323	2026-06-12 00:19:49
20250613072131	2026-06-12 00:19:49
20250711044927	2026-06-12 00:19:49
20250811121559	2026-06-12 00:19:49
20250926223044	2026-06-12 00:19:49
20251204170944	2026-06-12 00:19:49
20251218000543	2026-06-12 00:19:49
20260209232800	2026-06-12 00:19:49
20260304000000	2026-06-12 00:19:49
20260422000000	2026-06-12 00:19:49
\.


--
-- Data for Name: tenants; Type: TABLE DATA; Schema: _realtime; Owner: supabase_admin
--

COPY _realtime.tenants (id, name, external_id, jwt_secret, max_concurrent_users, inserted_at, updated_at, max_events_per_second, postgres_cdc_default, max_bytes_per_second, max_channels_per_client, max_joins_per_second, suspend, jwt_jwks, notify_private_alpha, private_only, migrations_ran, broadcast_adapter, max_presence_events_per_second, max_payload_size_in_kb, max_client_presence_events_per_window, client_presence_window_ms, presence_enabled, feature_flags) FROM stdin;
48547377-27b9-4666-a449-d11d29a7238f	realtime-dev	realtime-dev	iNjicxc4+llvc9wovDvqymwfnj9teWMlyOIbJ8Fh6j2WNU8CIJ2ZgjR6MUIKqSmeDmvpsKLsZ9jgXJmQPpwL8w==	200	2026-07-03 02:52:35	2026-07-03 02:52:35	100	postgres_cdc_rls	100000	100	100	f	{"keys": [{"x": "M5Sjqn5zwC9Kl1zVfUUGvv9boQjCGd45G8sdopBExB4", "y": "P6IXMvA2WYXSHSOMTBH2jsw_9rrzGy89FjPf6oOsIxQ", "alg": "ES256", "crv": "P-256", "ext": true, "kid": "b81269f1-21d8-4f2e-b719-c2240a840d90", "kty": "EC", "use": "sig", "key_ops": ["verify"]}, {"k": "c3VwZXItc2VjcmV0LWp3dC10b2tlbi13aXRoLWF0LWxlYXN0LTMyLWNoYXJhY3RlcnMtbG9uZw", "kty": "oct"}]}	f	f	73	gen_rpc	1000	3000	\N	\N	f	{}
\.


--
-- Data for Name: audit_log_entries; Type: TABLE DATA; Schema: auth; Owner: supabase_auth_admin
--

COPY auth.audit_log_entries (instance_id, id, payload, created_at, ip_address) FROM stdin;
00000000-0000-0000-0000-000000000000	f5e1a42e-535d-42ad-bcd1-4b67bcdfc41a	{"action":"user_signedup","actor_id":"00000000-0000-0000-0000-000000000000","actor_username":"service_role","actor_via_sso":false,"log_type":"team","traits":{"provider":"email","user_email":"ashraffarid@gmail.com","user_id":"f69c2370-64a4-467b-9be5-0262b271986a","user_phone":""}}	2026-06-12 00:22:09.687585+00	
00000000-0000-0000-0000-000000000000	b7ab855d-e6a3-4a2e-9e2a-ba0f247d30cf	{"action":"login","actor_id":"f69c2370-64a4-467b-9be5-0262b271986a","actor_username":"ashraffarid@gmail.com","actor_via_sso":false,"log_type":"account","traits":{"provider":"email"}}	2026-06-12 00:23:50.310115+00	
00000000-0000-0000-0000-000000000000	975efd8f-fae1-4da9-853f-708e69068e9d	{"action":"user_signedup","actor_id":"00000000-0000-0000-0000-000000000000","actor_username":"service_role","actor_via_sso":false,"log_type":"team","traits":{"provider":"email","user_email":"admin@admin.com","user_id":"8526382f-7ebb-4245-b8be-84c1f7a14e40","user_phone":""}}	2026-06-12 00:24:01.260914+00	
00000000-0000-0000-0000-000000000000	4d7bd547-f0e3-410d-98d2-855d14eb9413	{"action":"login","actor_id":"8526382f-7ebb-4245-b8be-84c1f7a14e40","actor_username":"admin@admin.com","actor_via_sso":false,"log_type":"account","traits":{"provider":"email"}}	2026-06-12 00:24:13.097843+00	
00000000-0000-0000-0000-000000000000	99fca6ea-01cc-4b80-9dd9-699f2c0bf8c2	{"action":"token_refreshed","actor_id":"f69c2370-64a4-467b-9be5-0262b271986a","actor_username":"ashraffarid@gmail.com","actor_via_sso":false,"log_type":"token"}	2026-06-12 01:22:26.972543+00	
00000000-0000-0000-0000-000000000000	5827e7aa-69ab-4481-adc4-1bfe30c97a0c	{"action":"token_revoked","actor_id":"f69c2370-64a4-467b-9be5-0262b271986a","actor_username":"ashraffarid@gmail.com","actor_via_sso":false,"log_type":"token"}	2026-06-12 01:22:26.973762+00	
00000000-0000-0000-0000-000000000000	4cdd32d0-95dc-4df3-b3a2-bebd6aa5a8aa	{"action":"token_refreshed","actor_id":"f69c2370-64a4-467b-9be5-0262b271986a","actor_username":"ashraffarid@gmail.com","actor_via_sso":false,"log_type":"token"}	2026-06-12 02:20:31.188079+00	
00000000-0000-0000-0000-000000000000	ff19960b-ded5-4583-8b0e-94647af83157	{"action":"token_revoked","actor_id":"f69c2370-64a4-467b-9be5-0262b271986a","actor_username":"ashraffarid@gmail.com","actor_via_sso":false,"log_type":"token"}	2026-06-12 02:20:31.189584+00	
00000000-0000-0000-0000-000000000000	c5721887-42cb-4879-9ba9-f72097d8e180	{"action":"token_refreshed","actor_id":"f69c2370-64a4-467b-9be5-0262b271986a","actor_username":"ashraffarid@gmail.com","actor_via_sso":false,"log_type":"token"}	2026-06-12 07:40:00.217294+00	
00000000-0000-0000-0000-000000000000	7b2e9625-0a98-45fc-a0f3-8b2c0a9d5ca1	{"action":"token_revoked","actor_id":"f69c2370-64a4-467b-9be5-0262b271986a","actor_username":"ashraffarid@gmail.com","actor_via_sso":false,"log_type":"token"}	2026-06-12 07:40:00.220807+00	
00000000-0000-0000-0000-000000000000	be172e0a-6120-4b47-ba4d-530a8b4c8461	{"action":"token_refreshed","actor_id":"f69c2370-64a4-467b-9be5-0262b271986a","actor_username":"ashraffarid@gmail.com","actor_via_sso":false,"log_type":"token"}	2026-06-12 08:38:31.118893+00	
00000000-0000-0000-0000-000000000000	8f186932-f06b-4c4f-a6b3-e6048bb7aa4b	{"action":"token_revoked","actor_id":"f69c2370-64a4-467b-9be5-0262b271986a","actor_username":"ashraffarid@gmail.com","actor_via_sso":false,"log_type":"token"}	2026-06-12 08:38:31.120296+00	
00000000-0000-0000-0000-000000000000	85493b82-3299-42f8-8923-e3361aa35bf1	{"action":"token_refreshed","actor_id":"f69c2370-64a4-467b-9be5-0262b271986a","actor_username":"ashraffarid@gmail.com","actor_via_sso":false,"log_type":"token"}	2026-06-12 09:36:31.113163+00	
00000000-0000-0000-0000-000000000000	4aee5924-e37b-457c-8d02-3da5787c2e3f	{"action":"token_revoked","actor_id":"f69c2370-64a4-467b-9be5-0262b271986a","actor_username":"ashraffarid@gmail.com","actor_via_sso":false,"log_type":"token"}	2026-06-12 09:36:31.113979+00	
00000000-0000-0000-0000-000000000000	f51f6a51-1f47-4c86-bf59-70b856390cc6	{"action":"token_refreshed","actor_id":"f69c2370-64a4-467b-9be5-0262b271986a","actor_username":"ashraffarid@gmail.com","actor_via_sso":false,"log_type":"token"}	2026-06-12 10:34:31.137325+00	
00000000-0000-0000-0000-000000000000	476988c4-27ed-4301-9493-7764a0774a2a	{"action":"token_revoked","actor_id":"f69c2370-64a4-467b-9be5-0262b271986a","actor_username":"ashraffarid@gmail.com","actor_via_sso":false,"log_type":"token"}	2026-06-12 10:34:31.138871+00	
00000000-0000-0000-0000-000000000000	777a4580-f611-4772-9291-13a20caa4501	{"action":"token_refreshed","actor_id":"f69c2370-64a4-467b-9be5-0262b271986a","actor_username":"ashraffarid@gmail.com","actor_via_sso":false,"log_type":"token"}	2026-06-12 13:06:40.931565+00	
00000000-0000-0000-0000-000000000000	aeaf188e-e02e-4414-9735-687d739c2d68	{"action":"token_revoked","actor_id":"f69c2370-64a4-467b-9be5-0262b271986a","actor_username":"ashraffarid@gmail.com","actor_via_sso":false,"log_type":"token"}	2026-06-12 13:06:40.935416+00	
00000000-0000-0000-0000-000000000000	c8decebe-776e-42b7-a55f-5a3dbb760652	{"action":"token_refreshed","actor_id":"f69c2370-64a4-467b-9be5-0262b271986a","actor_username":"ashraffarid@gmail.com","actor_via_sso":false,"log_type":"token"}	2026-06-12 14:05:31.140659+00	
00000000-0000-0000-0000-000000000000	3885b45f-863d-48e8-a496-c425d5c1a282	{"action":"token_revoked","actor_id":"f69c2370-64a4-467b-9be5-0262b271986a","actor_username":"ashraffarid@gmail.com","actor_via_sso":false,"log_type":"token"}	2026-06-12 14:05:31.141919+00	
00000000-0000-0000-0000-000000000000	be77cbc7-6f60-4a55-8605-f4b0fc1547b2	{"action":"token_refreshed","actor_id":"f69c2370-64a4-467b-9be5-0262b271986a","actor_username":"ashraffarid@gmail.com","actor_via_sso":false,"log_type":"token"}	2026-06-12 15:04:14.62976+00	
00000000-0000-0000-0000-000000000000	40539b17-7e5f-48c7-bb3a-36c82b1f2205	{"action":"token_revoked","actor_id":"f69c2370-64a4-467b-9be5-0262b271986a","actor_username":"ashraffarid@gmail.com","actor_via_sso":false,"log_type":"token"}	2026-06-12 15:04:14.63116+00	
00000000-0000-0000-0000-000000000000	92d8e64b-cd00-464f-b378-028d2dd9ef93	{"action":"token_refreshed","actor_id":"f69c2370-64a4-467b-9be5-0262b271986a","actor_username":"ashraffarid@gmail.com","actor_via_sso":false,"log_type":"token"}	2026-06-12 16:02:27.067685+00	
00000000-0000-0000-0000-000000000000	869f7277-77d3-4692-a604-981abb9cf036	{"action":"token_revoked","actor_id":"f69c2370-64a4-467b-9be5-0262b271986a","actor_username":"ashraffarid@gmail.com","actor_via_sso":false,"log_type":"token"}	2026-06-12 16:02:27.068934+00	
00000000-0000-0000-0000-000000000000	05002b3e-fd35-4d09-9ad8-cfd8e8456516	{"action":"token_refreshed","actor_id":"f69c2370-64a4-467b-9be5-0262b271986a","actor_username":"ashraffarid@gmail.com","actor_via_sso":false,"log_type":"token"}	2026-06-12 17:00:31.848327+00	
00000000-0000-0000-0000-000000000000	c0a13cde-a6c3-4ec6-a0ee-4f221f19cde0	{"action":"token_revoked","actor_id":"f69c2370-64a4-467b-9be5-0262b271986a","actor_username":"ashraffarid@gmail.com","actor_via_sso":false,"log_type":"token"}	2026-06-12 17:00:31.84944+00	
00000000-0000-0000-0000-000000000000	563e7b94-25eb-438e-a962-cd5299feb76b	{"action":"login","actor_id":"f69c2370-64a4-467b-9be5-0262b271986a","actor_username":"ashraffarid@gmail.com","actor_via_sso":false,"log_type":"account","traits":{"provider":"email"}}	2026-06-12 19:44:05.336282+00	
00000000-0000-0000-0000-000000000000	d804bf6c-3dc7-45db-ae19-1beb901f7ed2	{"action":"login","actor_id":"f69c2370-64a4-467b-9be5-0262b271986a","actor_username":"ashraffarid@gmail.com","actor_via_sso":false,"log_type":"account","traits":{"provider":"email"}}	2026-06-12 20:06:15.459909+00	
00000000-0000-0000-0000-000000000000	95d8a750-8b72-4a78-b367-231d59bdc3c7	{"action":"token_refreshed","actor_id":"f69c2370-64a4-467b-9be5-0262b271986a","actor_username":"ashraffarid@gmail.com","actor_via_sso":false,"log_type":"token"}	2026-06-12 21:35:33.069457+00	
00000000-0000-0000-0000-000000000000	b94ea55f-866e-42a7-ac9e-17225095aeb5	{"action":"token_revoked","actor_id":"f69c2370-64a4-467b-9be5-0262b271986a","actor_username":"ashraffarid@gmail.com","actor_via_sso":false,"log_type":"token"}	2026-06-12 21:35:33.070521+00	
00000000-0000-0000-0000-000000000000	78709773-219f-4e78-8b9a-d972bfbd9e23	{"action":"login","actor_id":"f69c2370-64a4-467b-9be5-0262b271986a","actor_username":"ashraffarid@gmail.com","actor_via_sso":false,"log_type":"account","traits":{"provider":"email"}}	2026-06-12 22:24:41.618754+00	
00000000-0000-0000-0000-000000000000	03a012e4-ce5e-4e9b-9531-3f5e8879aaa9	{"action":"token_refreshed","actor_id":"f69c2370-64a4-467b-9be5-0262b271986a","actor_username":"ashraffarid@gmail.com","actor_via_sso":false,"log_type":"token"}	2026-06-20 00:38:21.639988+00	
00000000-0000-0000-0000-000000000000	41291e9a-4ffa-41dc-b8fd-d48d0e0b0685	{"action":"token_revoked","actor_id":"f69c2370-64a4-467b-9be5-0262b271986a","actor_username":"ashraffarid@gmail.com","actor_via_sso":false,"log_type":"token"}	2026-06-20 00:38:21.642363+00	
00000000-0000-0000-0000-000000000000	0df241ff-9d15-47ad-848e-46ab87c2d528	{"action":"login","actor_id":"f69c2370-64a4-467b-9be5-0262b271986a","actor_username":"ashraffarid@gmail.com","actor_via_sso":false,"log_type":"account","traits":{"provider":"email"}}	2026-06-20 00:38:36.343956+00	
00000000-0000-0000-0000-000000000000	4728b510-b881-4940-b3e7-c747b6090a76	{"action":"login","actor_id":"f69c2370-64a4-467b-9be5-0262b271986a","actor_username":"ashraffarid@gmail.com","actor_via_sso":false,"log_type":"account","traits":{"provider":"email"}}	2026-06-20 00:39:00.92554+00	
00000000-0000-0000-0000-000000000000	f519e006-f584-440e-945f-abd53a69d303	{"action":"user_modified","actor_id":"00000000-0000-0000-0000-000000000000","actor_username":"service_role","actor_via_sso":false,"log_type":"user","traits":{"user_email":"ashraffarid@gmail.com","user_id":"f69c2370-64a4-467b-9be5-0262b271986a","user_phone":""}}	2026-07-04 12:21:13.270407+00	
00000000-0000-0000-0000-000000000000	60d5edee-750c-44c4-914e-0ccb727a13ca	{"action":"login","actor_id":"f69c2370-64a4-467b-9be5-0262b271986a","actor_username":"ashraffarid@gmail.com","actor_via_sso":false,"log_type":"account","traits":{"provider":"email"}}	2026-07-04 12:21:22.929556+00	
00000000-0000-0000-0000-000000000000	21f4758b-d81b-427c-bc33-c939fc4f9d6a	{"action":"login","actor_id":"f69c2370-64a4-467b-9be5-0262b271986a","actor_username":"ashraffarid@gmail.com","actor_via_sso":false,"log_type":"account","traits":{"provider":"email"}}	2026-07-04 12:21:42.207885+00	
00000000-0000-0000-0000-000000000000	64db59c4-2ef7-429f-a1c6-36ae855ac8cd	{"action":"login","actor_id":"f69c2370-64a4-467b-9be5-0262b271986a","actor_username":"ashraffarid@gmail.com","actor_via_sso":false,"log_type":"account","traits":{"provider":"email"}}	2026-07-04 12:21:52.473326+00	
00000000-0000-0000-0000-000000000000	dfc0c831-7917-4b37-8967-ed82d12cf4f7	{"action":"login","actor_id":"f69c2370-64a4-467b-9be5-0262b271986a","actor_username":"ashraffarid@gmail.com","actor_via_sso":false,"log_type":"account","traits":{"provider":"email"}}	2026-07-04 12:23:50.993945+00	
00000000-0000-0000-0000-000000000000	0d72966c-e0ae-41c2-8b3e-f51afc9df6b5	{"action":"user_signedup","actor_id":"00000000-0000-0000-0000-000000000000","actor_username":"service_role","actor_via_sso":false,"log_type":"team","traits":{"provider":"email","user_email":"veedon.test@local.dev","user_id":"a7b186ca-e6c3-4ece-9349-26a0dbf0defa","user_phone":""}}	2026-07-04 13:10:17.918076+00	
00000000-0000-0000-0000-000000000000	07cbb809-79da-4a85-a5c7-673780f76064	{"action":"token_refreshed","actor_id":"f69c2370-64a4-467b-9be5-0262b271986a","actor_username":"ashraffarid@gmail.com","actor_via_sso":false,"log_type":"token"}	2026-07-04 13:20:18.568754+00	
00000000-0000-0000-0000-000000000000	c8cce902-6b1f-4eec-90c9-d10da6704214	{"action":"token_revoked","actor_id":"f69c2370-64a4-467b-9be5-0262b271986a","actor_username":"ashraffarid@gmail.com","actor_via_sso":false,"log_type":"token"}	2026-07-04 13:20:18.572071+00	
00000000-0000-0000-0000-000000000000	c239a058-4135-4342-b722-0ada7c73ce0a	{"action":"token_refreshed","actor_id":"f69c2370-64a4-467b-9be5-0262b271986a","actor_username":"ashraffarid@gmail.com","actor_via_sso":false,"log_type":"token"}	2026-07-04 14:18:18.554482+00	
00000000-0000-0000-0000-000000000000	120776d4-590e-40e9-a1a2-88e282f3c6cc	{"action":"token_revoked","actor_id":"f69c2370-64a4-467b-9be5-0262b271986a","actor_username":"ashraffarid@gmail.com","actor_via_sso":false,"log_type":"token"}	2026-07-04 14:18:18.55532+00	
00000000-0000-0000-0000-000000000000	9ec66434-8747-41a4-bad7-b704251d4bcb	{"action":"token_refreshed","actor_id":"f69c2370-64a4-467b-9be5-0262b271986a","actor_username":"ashraffarid@gmail.com","actor_via_sso":false,"log_type":"token"}	2026-07-04 15:16:18.553291+00	
00000000-0000-0000-0000-000000000000	1ef001c4-401f-4fad-8384-3fbff9f4355e	{"action":"token_revoked","actor_id":"f69c2370-64a4-467b-9be5-0262b271986a","actor_username":"ashraffarid@gmail.com","actor_via_sso":false,"log_type":"token"}	2026-07-04 15:16:18.553918+00	
00000000-0000-0000-0000-000000000000	482d85e3-01ad-46ed-acb6-5f02415df707	{"action":"token_refreshed","actor_id":"f69c2370-64a4-467b-9be5-0262b271986a","actor_username":"ashraffarid@gmail.com","actor_via_sso":false,"log_type":"token"}	2026-07-04 16:14:18.559053+00	
00000000-0000-0000-0000-000000000000	c22b37c2-075c-4131-be27-ea21e5c392be	{"action":"token_revoked","actor_id":"f69c2370-64a4-467b-9be5-0262b271986a","actor_username":"ashraffarid@gmail.com","actor_via_sso":false,"log_type":"token"}	2026-07-04 16:14:18.559817+00	
00000000-0000-0000-0000-000000000000	9b0080b5-cba8-4ee8-b80e-dc9a6cbce0da	{"action":"token_refreshed","actor_id":"f69c2370-64a4-467b-9be5-0262b271986a","actor_username":"ashraffarid@gmail.com","actor_via_sso":false,"log_type":"token"}	2026-07-04 17:12:18.566843+00	
00000000-0000-0000-0000-000000000000	aa9b99ae-ffeb-4035-96d1-3c4292c45a88	{"action":"token_revoked","actor_id":"f69c2370-64a4-467b-9be5-0262b271986a","actor_username":"ashraffarid@gmail.com","actor_via_sso":false,"log_type":"token"}	2026-07-04 17:12:18.56809+00	
00000000-0000-0000-0000-000000000000	ed74fda4-8125-433a-8f40-fe8688cdbcb7	{"action":"login","actor_id":"a7b186ca-e6c3-4ece-9349-26a0dbf0defa","actor_username":"veedon.test@local.dev","actor_via_sso":false,"log_type":"account","traits":{"provider":"email"}}	2026-07-04 17:33:59.462776+00	
00000000-0000-0000-0000-000000000000	892250d2-03c4-4ebf-bc4f-daadc6771906	{"action":"logout","actor_id":"a7b186ca-e6c3-4ece-9349-26a0dbf0defa","actor_username":"veedon.test@local.dev","actor_via_sso":false,"log_type":"account"}	2026-07-04 17:33:59.583088+00	
00000000-0000-0000-0000-000000000000	fc496b3d-c8ab-4992-bb01-318c53607fc3	{"action":"login","actor_id":"a7b186ca-e6c3-4ece-9349-26a0dbf0defa","actor_username":"veedon.test@local.dev","actor_via_sso":false,"log_type":"account","traits":{"provider":"email"}}	2026-07-04 17:34:26.161698+00	
00000000-0000-0000-0000-000000000000	f1255434-b732-48b2-8a2a-4440a20a0b07	{"action":"token_refreshed","actor_id":"f69c2370-64a4-467b-9be5-0262b271986a","actor_username":"ashraffarid@gmail.com","actor_via_sso":false,"log_type":"token"}	2026-07-04 18:10:20.358597+00	
00000000-0000-0000-0000-000000000000	0d82727d-4b03-46b8-8b98-def715c3dfee	{"action":"token_revoked","actor_id":"f69c2370-64a4-467b-9be5-0262b271986a","actor_username":"ashraffarid@gmail.com","actor_via_sso":false,"log_type":"token"}	2026-07-04 18:10:20.359468+00	
00000000-0000-0000-0000-000000000000	869d16e0-c228-4333-8950-a334458c6acc	{"action":"token_refreshed","actor_id":"a7b186ca-e6c3-4ece-9349-26a0dbf0defa","actor_username":"veedon.test@local.dev","actor_via_sso":false,"log_type":"token"}	2026-07-04 18:32:50.927095+00	
00000000-0000-0000-0000-000000000000	90717f37-c90d-4335-8b9b-6816c5decd64	{"action":"token_revoked","actor_id":"a7b186ca-e6c3-4ece-9349-26a0dbf0defa","actor_username":"veedon.test@local.dev","actor_via_sso":false,"log_type":"token"}	2026-07-04 18:32:50.927664+00	
00000000-0000-0000-0000-000000000000	813bf38d-bcbe-42e9-826b-0ce0d9b970bd	{"action":"token_refreshed","actor_id":"f69c2370-64a4-467b-9be5-0262b271986a","actor_username":"ashraffarid@gmail.com","actor_via_sso":false,"log_type":"token"}	2026-07-04 19:08:20.343223+00	
00000000-0000-0000-0000-000000000000	9b17047a-7206-4346-9653-7dbd78a00760	{"action":"token_revoked","actor_id":"f69c2370-64a4-467b-9be5-0262b271986a","actor_username":"ashraffarid@gmail.com","actor_via_sso":false,"log_type":"token"}	2026-07-04 19:08:20.343999+00	
00000000-0000-0000-0000-000000000000	8c7c75ed-248f-452d-9c81-8cd00ad913a6	{"action":"token_refreshed","actor_id":"a7b186ca-e6c3-4ece-9349-26a0dbf0defa","actor_username":"veedon.test@local.dev","actor_via_sso":false,"log_type":"token"}	2026-07-04 19:30:50.91724+00	
00000000-0000-0000-0000-000000000000	f67e35f2-e8d3-4110-b54b-3581f639c7ae	{"action":"token_revoked","actor_id":"a7b186ca-e6c3-4ece-9349-26a0dbf0defa","actor_username":"veedon.test@local.dev","actor_via_sso":false,"log_type":"token"}	2026-07-04 19:30:50.91777+00	
00000000-0000-0000-0000-000000000000	70573a75-26e7-43fd-a0c7-449ca64ab191	{"action":"token_refreshed","actor_id":"f69c2370-64a4-467b-9be5-0262b271986a","actor_username":"ashraffarid@gmail.com","actor_via_sso":false,"log_type":"token"}	2026-07-04 20:06:20.350409+00	
00000000-0000-0000-0000-000000000000	1c92d1c2-853f-4545-9a6e-0df8626eb0e6	{"action":"token_revoked","actor_id":"f69c2370-64a4-467b-9be5-0262b271986a","actor_username":"ashraffarid@gmail.com","actor_via_sso":false,"log_type":"token"}	2026-07-04 20:06:20.351027+00	
00000000-0000-0000-0000-000000000000	96e0f36f-fa5a-4af1-9bcf-04d78a1bef8e	{"action":"token_refreshed","actor_id":"a7b186ca-e6c3-4ece-9349-26a0dbf0defa","actor_username":"veedon.test@local.dev","actor_via_sso":false,"log_type":"token"}	2026-07-04 20:29:20.313188+00	
00000000-0000-0000-0000-000000000000	85414ea2-7b9f-4e13-8c4f-2167444fbdca	{"action":"token_revoked","actor_id":"a7b186ca-e6c3-4ece-9349-26a0dbf0defa","actor_username":"veedon.test@local.dev","actor_via_sso":false,"log_type":"token"}	2026-07-04 20:29:20.313728+00	
00000000-0000-0000-0000-000000000000	34f3f6a3-896c-4c18-83dd-ed17bc3bc876	{"action":"token_refreshed","actor_id":"f69c2370-64a4-467b-9be5-0262b271986a","actor_username":"ashraffarid@gmail.com","actor_via_sso":false,"log_type":"token"}	2026-07-04 21:04:20.33772+00	
00000000-0000-0000-0000-000000000000	9b702acd-8da7-452b-9b2a-4f37df5a1f16	{"action":"token_revoked","actor_id":"f69c2370-64a4-467b-9be5-0262b271986a","actor_username":"ashraffarid@gmail.com","actor_via_sso":false,"log_type":"token"}	2026-07-04 21:04:20.338503+00	
00000000-0000-0000-0000-000000000000	5eb00c7c-bb5a-48b6-9fac-d50f1e9abd08	{"action":"token_refreshed","actor_id":"a7b186ca-e6c3-4ece-9349-26a0dbf0defa","actor_username":"veedon.test@local.dev","actor_via_sso":false,"log_type":"token"}	2026-07-04 21:43:10.512108+00	
00000000-0000-0000-0000-000000000000	28b3cd19-dd78-48a4-8084-cf9f1af15ebc	{"action":"token_revoked","actor_id":"a7b186ca-e6c3-4ece-9349-26a0dbf0defa","actor_username":"veedon.test@local.dev","actor_via_sso":false,"log_type":"token"}	2026-07-04 21:43:10.512741+00	
00000000-0000-0000-0000-000000000000	96e4a63e-e77b-4806-968b-b3afaf7450c4	{"action":"token_refreshed","actor_id":"f69c2370-64a4-467b-9be5-0262b271986a","actor_username":"ashraffarid@gmail.com","actor_via_sso":false,"log_type":"token"}	2026-07-04 22:02:20.352469+00	
00000000-0000-0000-0000-000000000000	40dcc7cf-7b59-47de-8605-a03bcdd8fe7a	{"action":"token_revoked","actor_id":"f69c2370-64a4-467b-9be5-0262b271986a","actor_username":"ashraffarid@gmail.com","actor_via_sso":false,"log_type":"token"}	2026-07-04 22:02:20.353191+00	
00000000-0000-0000-0000-000000000000	d33bf4a6-9b69-4eee-a08e-aaf16fac373a	{"action":"login","actor_id":"a7b186ca-e6c3-4ece-9349-26a0dbf0defa","actor_username":"veedon.test@local.dev","actor_via_sso":false,"log_type":"account","traits":{"provider":"email"}}	2026-07-04 22:39:23.052077+00	
00000000-0000-0000-0000-000000000000	92268808-5a53-4410-9a26-ea70034e6620	{"action":"token_refreshed","actor_id":"f69c2370-64a4-467b-9be5-0262b271986a","actor_username":"ashraffarid@gmail.com","actor_via_sso":false,"log_type":"token"}	2026-07-04 23:00:20.336642+00	
00000000-0000-0000-0000-000000000000	0ff955c6-8fa3-4365-903e-f5933af42a1c	{"action":"token_revoked","actor_id":"f69c2370-64a4-467b-9be5-0262b271986a","actor_username":"ashraffarid@gmail.com","actor_via_sso":false,"log_type":"token"}	2026-07-04 23:00:20.33734+00	
00000000-0000-0000-0000-000000000000	ecee8d13-d278-4155-bf03-d3dce616727e	{"action":"token_refreshed","actor_id":"f69c2370-64a4-467b-9be5-0262b271986a","actor_username":"ashraffarid@gmail.com","actor_via_sso":false,"log_type":"token"}	2026-07-04 23:59:20.339247+00	
00000000-0000-0000-0000-000000000000	5babb661-3024-402d-9109-64a4ccda8a53	{"action":"token_revoked","actor_id":"f69c2370-64a4-467b-9be5-0262b271986a","actor_username":"ashraffarid@gmail.com","actor_via_sso":false,"log_type":"token"}	2026-07-04 23:59:20.341267+00	
00000000-0000-0000-0000-000000000000	8ef8e5f8-d643-4ba8-aa1f-60e823f57d7d	{"action":"token_refreshed","actor_id":"f69c2370-64a4-467b-9be5-0262b271986a","actor_username":"ashraffarid@gmail.com","actor_via_sso":false,"log_type":"token"}	2026-07-05 01:18:52.110532+00	
00000000-0000-0000-0000-000000000000	10f45a36-2947-4a59-9ade-c3cc1656e74a	{"action":"token_revoked","actor_id":"f69c2370-64a4-467b-9be5-0262b271986a","actor_username":"ashraffarid@gmail.com","actor_via_sso":false,"log_type":"token"}	2026-07-05 01:18:52.113932+00	
00000000-0000-0000-0000-000000000000	0ad7079c-ab6e-4864-acbb-c4ccbf0e9562	{"action":"token_refreshed","actor_id":"f69c2370-64a4-467b-9be5-0262b271986a","actor_username":"ashraffarid@gmail.com","actor_via_sso":false,"log_type":"token"}	2026-07-05 02:17:20.303194+00	
00000000-0000-0000-0000-000000000000	a457d6d0-428a-4f64-85ca-1443667dcd61	{"action":"token_revoked","actor_id":"f69c2370-64a4-467b-9be5-0262b271986a","actor_username":"ashraffarid@gmail.com","actor_via_sso":false,"log_type":"token"}	2026-07-05 02:17:20.304721+00	
00000000-0000-0000-0000-000000000000	852ebf01-83e4-4f79-8f35-8f67d4b20b94	{"action":"token_refreshed","actor_id":"f69c2370-64a4-467b-9be5-0262b271986a","actor_username":"ashraffarid@gmail.com","actor_via_sso":false,"log_type":"token"}	2026-07-05 03:15:20.303414+00	
00000000-0000-0000-0000-000000000000	48fb851d-acbb-43d8-a6eb-d15ac468d19d	{"action":"token_revoked","actor_id":"f69c2370-64a4-467b-9be5-0262b271986a","actor_username":"ashraffarid@gmail.com","actor_via_sso":false,"log_type":"token"}	2026-07-05 03:15:20.3051+00	
00000000-0000-0000-0000-000000000000	5191a4c2-0952-4703-81eb-f94df65e8731	{"action":"token_refreshed","actor_id":"a7b186ca-e6c3-4ece-9349-26a0dbf0defa","actor_username":"veedon.test@local.dev","actor_via_sso":false,"log_type":"token"}	2026-07-05 03:42:30.614011+00	
00000000-0000-0000-0000-000000000000	9b6798b0-cf78-4716-b3a4-b8b50a728036	{"action":"token_revoked","actor_id":"a7b186ca-e6c3-4ece-9349-26a0dbf0defa","actor_username":"veedon.test@local.dev","actor_via_sso":false,"log_type":"token"}	2026-07-05 03:42:30.614705+00	
00000000-0000-0000-0000-000000000000	5e3b3947-5474-4b6a-aedf-9f577558db33	{"action":"token_refreshed","actor_id":"f69c2370-64a4-467b-9be5-0262b271986a","actor_username":"ashraffarid@gmail.com","actor_via_sso":false,"log_type":"token"}	2026-07-05 04:14:20.297575+00	
00000000-0000-0000-0000-000000000000	4660217a-ece1-4d57-8ad4-eac3bf9a023d	{"action":"token_revoked","actor_id":"f69c2370-64a4-467b-9be5-0262b271986a","actor_username":"ashraffarid@gmail.com","actor_via_sso":false,"log_type":"token"}	2026-07-05 04:14:20.29826+00	
00000000-0000-0000-0000-000000000000	0b747f95-fb1e-42a7-a489-afbe1840c96a	{"action":"token_refreshed","actor_id":"a7b186ca-e6c3-4ece-9349-26a0dbf0defa","actor_username":"veedon.test@local.dev","actor_via_sso":false,"log_type":"token"}	2026-07-05 04:40:50.745025+00	
00000000-0000-0000-0000-000000000000	0cabf0d4-1474-43c9-8b14-b40e0ee6aaa4	{"action":"token_revoked","actor_id":"a7b186ca-e6c3-4ece-9349-26a0dbf0defa","actor_username":"veedon.test@local.dev","actor_via_sso":false,"log_type":"token"}	2026-07-05 04:40:50.745701+00	
00000000-0000-0000-0000-000000000000	dfd2de2e-8985-4213-8bc6-d7d14daf086d	{"action":"token_refreshed","actor_id":"f69c2370-64a4-467b-9be5-0262b271986a","actor_username":"ashraffarid@gmail.com","actor_via_sso":false,"log_type":"token"}	2026-07-05 05:13:20.29312+00	
00000000-0000-0000-0000-000000000000	c1ea02c5-f300-40f1-b79f-7d82e7f70202	{"action":"token_revoked","actor_id":"f69c2370-64a4-467b-9be5-0262b271986a","actor_username":"ashraffarid@gmail.com","actor_via_sso":false,"log_type":"token"}	2026-07-05 05:13:20.294169+00	
00000000-0000-0000-0000-000000000000	54ba45f9-22bf-45b1-9fe6-60ad00d21ef3	{"action":"token_refreshed","actor_id":"a7b186ca-e6c3-4ece-9349-26a0dbf0defa","actor_username":"veedon.test@local.dev","actor_via_sso":false,"log_type":"token"}	2026-07-05 05:39:22.703133+00	
00000000-0000-0000-0000-000000000000	291ed1df-fed6-4f3c-919e-21aa98fa3f7b	{"action":"token_revoked","actor_id":"a7b186ca-e6c3-4ece-9349-26a0dbf0defa","actor_username":"veedon.test@local.dev","actor_via_sso":false,"log_type":"token"}	2026-07-05 05:39:22.726898+00	
00000000-0000-0000-0000-000000000000	5f66022a-dde1-4f42-939a-130087f4f237	{"action":"user_modified","actor_id":"00000000-0000-0000-0000-000000000000","actor_username":"service_role","actor_via_sso":false,"log_type":"user","traits":{"user_email":"ashraffarid@gmail.com","user_id":"f69c2370-64a4-467b-9be5-0262b271986a","user_phone":""}}	2026-07-05 06:00:38.301517+00	
00000000-0000-0000-0000-000000000000	39a089e2-cdc6-437d-bf4e-79b405e7f4f1	{"action":"user_modified","actor_id":"00000000-0000-0000-0000-000000000000","actor_username":"service_role","actor_via_sso":false,"log_type":"user","traits":{"user_email":"ashraffarid@gmail.com","user_id":"f69c2370-64a4-467b-9be5-0262b271986a","user_phone":""}}	2026-07-05 06:00:51.62088+00	
00000000-0000-0000-0000-000000000000	fa5863dd-d486-407b-9647-06b8ecfb322d	{"action":"login","actor_id":"f69c2370-64a4-467b-9be5-0262b271986a","actor_username":"ashraffarid@gmail.com","actor_via_sso":false,"log_type":"account","traits":{"provider":"email"}}	2026-07-05 06:01:05.94478+00	
00000000-0000-0000-0000-000000000000	c259b72d-397e-4103-b912-8d1c5451104d	{"action":"login","actor_id":"f69c2370-64a4-467b-9be5-0262b271986a","actor_username":"ashraffarid@gmail.com","actor_via_sso":false,"log_type":"account","traits":{"provider":"email"}}	2026-07-05 06:01:24.962898+00	
00000000-0000-0000-0000-000000000000	4290bcef-7982-4130-834d-00d391b5df07	{"action":"login","actor_id":"f69c2370-64a4-467b-9be5-0262b271986a","actor_username":"ashraffarid@gmail.com","actor_via_sso":false,"log_type":"account","traits":{"provider":"email"}}	2026-07-05 06:01:57.244894+00	
00000000-0000-0000-0000-000000000000	687b980d-44f8-4cce-be0a-f29fa111dec9	{"action":"login","actor_id":"f69c2370-64a4-467b-9be5-0262b271986a","actor_username":"ashraffarid@gmail.com","actor_via_sso":false,"log_type":"account","traits":{"provider":"email"}}	2026-07-05 06:10:45.721802+00	
00000000-0000-0000-0000-000000000000	b3aae1f0-9217-40cc-aa37-8e605def0c32	{"action":"token_refreshed","actor_id":"a7b186ca-e6c3-4ece-9349-26a0dbf0defa","actor_username":"veedon.test@local.dev","actor_via_sso":false,"log_type":"token"}	2026-07-05 06:37:53.264427+00	
00000000-0000-0000-0000-000000000000	f0b2e542-7986-4dbe-9a58-b5b113e6299e	{"action":"token_revoked","actor_id":"a7b186ca-e6c3-4ece-9349-26a0dbf0defa","actor_username":"veedon.test@local.dev","actor_via_sso":false,"log_type":"token"}	2026-07-05 06:37:53.264934+00	
00000000-0000-0000-0000-000000000000	5e724357-3a71-4e39-af32-cfb87cc1d31a	{"action":"login","actor_id":"a7b186ca-e6c3-4ece-9349-26a0dbf0defa","actor_username":"veedon.test@local.dev","actor_via_sso":false,"log_type":"account","traits":{"provider":"email"}}	2026-07-05 06:40:06.8369+00	
00000000-0000-0000-0000-000000000000	c3dee3c5-c9fd-49f4-b39d-580779f3d0e7	{"action":"token_refreshed","actor_id":"f69c2370-64a4-467b-9be5-0262b271986a","actor_username":"ashraffarid@gmail.com","actor_via_sso":false,"log_type":"token"}	2026-07-05 07:09:16.27619+00	
00000000-0000-0000-0000-000000000000	7c7bea3b-b476-4e2e-88c4-5ead9abb522c	{"action":"token_revoked","actor_id":"f69c2370-64a4-467b-9be5-0262b271986a","actor_username":"ashraffarid@gmail.com","actor_via_sso":false,"log_type":"token"}	2026-07-05 07:09:16.276769+00	
\.


--
-- Data for Name: custom_oauth_providers; Type: TABLE DATA; Schema: auth; Owner: supabase_auth_admin
--

COPY auth.custom_oauth_providers (id, provider_type, identifier, name, client_id, client_secret, acceptable_client_ids, scopes, pkce_enabled, attribute_mapping, authorization_params, enabled, email_optional, issuer, discovery_url, skip_nonce_check, cached_discovery, discovery_cached_at, authorization_url, token_url, userinfo_url, jwks_uri, created_at, updated_at) FROM stdin;
\.


--
-- Data for Name: flow_state; Type: TABLE DATA; Schema: auth; Owner: supabase_auth_admin
--

COPY auth.flow_state (id, user_id, auth_code, code_challenge_method, code_challenge, provider_type, provider_access_token, provider_refresh_token, created_at, updated_at, authentication_method, auth_code_issued_at, invite_token, referrer, oauth_client_state_id, linking_target_id, email_optional) FROM stdin;
\.


--
-- Data for Name: identities; Type: TABLE DATA; Schema: auth; Owner: supabase_auth_admin
--

COPY auth.identities (provider_id, user_id, identity_data, provider, last_sign_in_at, created_at, updated_at, id) FROM stdin;
f69c2370-64a4-467b-9be5-0262b271986a	f69c2370-64a4-467b-9be5-0262b271986a	{"sub": "f69c2370-64a4-467b-9be5-0262b271986a", "email": "ashraffarid@gmail.com", "email_verified": false, "phone_verified": false}	email	2026-06-12 00:22:09.686819+00	2026-06-12 00:22:09.68684+00	2026-06-12 00:22:09.68684+00	d6dfe4cc-2cab-4f17-bf90-203fcdbc4e33
8526382f-7ebb-4245-b8be-84c1f7a14e40	8526382f-7ebb-4245-b8be-84c1f7a14e40	{"sub": "8526382f-7ebb-4245-b8be-84c1f7a14e40", "email": "admin@admin.com", "email_verified": false, "phone_verified": false}	email	2026-06-12 00:24:01.260355+00	2026-06-12 00:24:01.26038+00	2026-06-12 00:24:01.26038+00	719cafb8-88b9-44c7-9a2c-01b4216fc23c
a7b186ca-e6c3-4ece-9349-26a0dbf0defa	a7b186ca-e6c3-4ece-9349-26a0dbf0defa	{"sub": "a7b186ca-e6c3-4ece-9349-26a0dbf0defa", "email": "veedon.test@local.dev", "email_verified": false, "phone_verified": false}	email	2026-07-04 13:10:17.916671+00	2026-07-04 13:10:17.916693+00	2026-07-04 13:10:17.916693+00	55cb28d5-b602-485b-aeb0-409987313ce7
\.


--
-- Data for Name: instances; Type: TABLE DATA; Schema: auth; Owner: supabase_auth_admin
--

COPY auth.instances (id, uuid, raw_base_config, created_at, updated_at) FROM stdin;
\.


--
-- Data for Name: mfa_amr_claims; Type: TABLE DATA; Schema: auth; Owner: supabase_auth_admin
--

COPY auth.mfa_amr_claims (session_id, created_at, updated_at, authentication_method, id) FROM stdin;
5e2481e9-381d-4653-bc19-24944437d565	2026-06-12 00:24:13.101858+00	2026-06-12 00:24:13.101858+00	password	de2b897b-8f57-4af4-8ccb-83b1292c80fa
cf4deea3-5906-42af-a4c7-a06ac3e4aaec	2026-07-04 17:34:26.165+00	2026-07-04 17:34:26.165+00	password	a50d3bb6-aea3-4ad9-b755-3b0858e1960d
161d4f06-1eb2-4314-885d-cd387aa69b31	2026-07-04 22:39:23.055862+00	2026-07-04 22:39:23.055862+00	password	4a996f8e-a0ad-4d49-ad12-a3a845595b6f
8c92f57b-8cd2-471f-a729-c1cd844ab3ab	2026-07-05 06:01:05.948925+00	2026-07-05 06:01:05.948925+00	password	5cc6058c-3605-49eb-8d3b-9ba1bee80574
884fe246-081b-4631-a5f2-aa0c16da7f93	2026-07-05 06:01:24.966357+00	2026-07-05 06:01:24.966357+00	password	4ffb7e8a-3f4c-4456-bfb4-c89bc755e8eb
70d05132-78da-4c35-9733-35fe23dcfca7	2026-07-05 06:01:57.249769+00	2026-07-05 06:01:57.249769+00	password	ac35d331-8bfc-40e0-935d-7c2de4bba358
45070129-bd31-4083-b0bd-9d5463d7adb4	2026-07-05 06:10:45.725469+00	2026-07-05 06:10:45.725469+00	password	79b22a9c-3078-4164-8097-c6abe3a20e28
fb8bc5fb-a570-417b-bd94-875106aabcc2	2026-07-05 06:40:06.840914+00	2026-07-05 06:40:06.840914+00	password	9851af4b-a74e-4359-8280-c7e18893722c
\.


--
-- Data for Name: mfa_challenges; Type: TABLE DATA; Schema: auth; Owner: supabase_auth_admin
--

COPY auth.mfa_challenges (id, factor_id, created_at, verified_at, ip_address, otp_code, web_authn_session_data) FROM stdin;
\.


--
-- Data for Name: mfa_factors; Type: TABLE DATA; Schema: auth; Owner: supabase_auth_admin
--

COPY auth.mfa_factors (id, user_id, friendly_name, factor_type, status, created_at, updated_at, secret, phone, last_challenged_at, web_authn_credential, web_authn_aaguid, last_webauthn_challenge_data) FROM stdin;
\.


--
-- Data for Name: oauth_authorizations; Type: TABLE DATA; Schema: auth; Owner: supabase_auth_admin
--

COPY auth.oauth_authorizations (id, authorization_id, client_id, user_id, redirect_uri, scope, state, resource, code_challenge, code_challenge_method, response_type, status, authorization_code, created_at, expires_at, approved_at, nonce) FROM stdin;
\.


--
-- Data for Name: oauth_client_states; Type: TABLE DATA; Schema: auth; Owner: supabase_auth_admin
--

COPY auth.oauth_client_states (id, provider_type, code_verifier, created_at) FROM stdin;
\.


--
-- Data for Name: oauth_clients; Type: TABLE DATA; Schema: auth; Owner: supabase_auth_admin
--

COPY auth.oauth_clients (id, client_secret_hash, registration_type, redirect_uris, grant_types, client_name, client_uri, logo_uri, created_at, updated_at, deleted_at, client_type, token_endpoint_auth_method) FROM stdin;
\.


--
-- Data for Name: oauth_consents; Type: TABLE DATA; Schema: auth; Owner: supabase_auth_admin
--

COPY auth.oauth_consents (id, user_id, client_id, scopes, granted_at, revoked_at) FROM stdin;
\.


--
-- Data for Name: one_time_tokens; Type: TABLE DATA; Schema: auth; Owner: supabase_auth_admin
--

COPY auth.one_time_tokens (id, user_id, token_type, token_hash, relates_to, created_at, updated_at) FROM stdin;
\.


--
-- Data for Name: refresh_tokens; Type: TABLE DATA; Schema: auth; Owner: supabase_auth_admin
--

COPY auth.refresh_tokens (instance_id, id, token, user_id, revoked, created_at, updated_at, parent, session_id) FROM stdin;
00000000-0000-0000-0000-000000000000	47	vrmgffgg6crk	a7b186ca-e6c3-4ece-9349-26a0dbf0defa	t	2026-07-05 03:42:30.615571+00	2026-07-05 04:40:50.745943+00	p2tqwgjaactk	161d4f06-1eb2-4314-885d-cd387aa69b31
00000000-0000-0000-0000-000000000000	2	wlqmsuh6fccr	8526382f-7ebb-4245-b8be-84c1f7a14e40	f	2026-06-12 00:24:13.100858+00	2026-06-12 00:24:13.100858+00	\N	5e2481e9-381d-4653-bc19-24944437d565
00000000-0000-0000-0000-000000000000	49	qqib35q6uxp4	a7b186ca-e6c3-4ece-9349-26a0dbf0defa	t	2026-07-05 04:40:50.746336+00	2026-07-05 05:39:22.730813+00	vrmgffgg6crk	161d4f06-1eb2-4314-885d-cd387aa69b31
00000000-0000-0000-0000-000000000000	52	q4h223xydn4v	f69c2370-64a4-467b-9be5-0262b271986a	f	2026-07-05 06:01:05.947652+00	2026-07-05 06:01:05.947652+00	\N	8c92f57b-8cd2-471f-a729-c1cd844ab3ab
00000000-0000-0000-0000-000000000000	53	2isjw3ajw5iy	f69c2370-64a4-467b-9be5-0262b271986a	f	2026-07-05 06:01:24.965256+00	2026-07-05 06:01:24.965256+00	\N	884fe246-081b-4631-a5f2-aa0c16da7f93
00000000-0000-0000-0000-000000000000	54	mx2t4sjkx4p5	f69c2370-64a4-467b-9be5-0262b271986a	f	2026-07-05 06:01:57.248653+00	2026-07-05 06:01:57.248653+00	\N	70d05132-78da-4c35-9733-35fe23dcfca7
00000000-0000-0000-0000-000000000000	51	obrw4vbj3ydb	a7b186ca-e6c3-4ece-9349-26a0dbf0defa	t	2026-07-05 05:39:22.761673+00	2026-07-05 06:37:53.265224+00	qqib35q6uxp4	161d4f06-1eb2-4314-885d-cd387aa69b31
00000000-0000-0000-0000-000000000000	56	fr7xb7aylo2v	a7b186ca-e6c3-4ece-9349-26a0dbf0defa	f	2026-07-05 06:37:53.265705+00	2026-07-05 06:37:53.265705+00	obrw4vbj3ydb	161d4f06-1eb2-4314-885d-cd387aa69b31
00000000-0000-0000-0000-000000000000	57	aei3mefawghe	a7b186ca-e6c3-4ece-9349-26a0dbf0defa	f	2026-07-05 06:40:06.839663+00	2026-07-05 06:40:06.839663+00	\N	fb8bc5fb-a570-417b-bd94-875106aabcc2
00000000-0000-0000-0000-000000000000	55	ekeray74a7m5	f69c2370-64a4-467b-9be5-0262b271986a	t	2026-07-05 06:10:45.724313+00	2026-07-05 07:09:16.277054+00	\N	45070129-bd31-4083-b0bd-9d5463d7adb4
00000000-0000-0000-0000-000000000000	58	nor63s5zv5h3	f69c2370-64a4-467b-9be5-0262b271986a	f	2026-07-05 07:09:16.277522+00	2026-07-05 07:09:16.277522+00	ekeray74a7m5	45070129-bd31-4083-b0bd-9d5463d7adb4
00000000-0000-0000-0000-000000000000	31	xqeufj6ilbn3	a7b186ca-e6c3-4ece-9349-26a0dbf0defa	t	2026-07-04 17:34:26.164006+00	2026-07-04 18:32:50.927989+00	\N	cf4deea3-5906-42af-a4c7-a06ac3e4aaec
00000000-0000-0000-0000-000000000000	33	fh37wbhxbrtk	a7b186ca-e6c3-4ece-9349-26a0dbf0defa	t	2026-07-04 18:32:50.928593+00	2026-07-04 19:30:50.918103+00	xqeufj6ilbn3	cf4deea3-5906-42af-a4c7-a06ac3e4aaec
00000000-0000-0000-0000-000000000000	35	6jwhoiad4cso	a7b186ca-e6c3-4ece-9349-26a0dbf0defa	t	2026-07-04 19:30:50.918439+00	2026-07-04 20:29:20.31403+00	fh37wbhxbrtk	cf4deea3-5906-42af-a4c7-a06ac3e4aaec
00000000-0000-0000-0000-000000000000	37	lg7ulakm6bub	a7b186ca-e6c3-4ece-9349-26a0dbf0defa	t	2026-07-04 20:29:20.314485+00	2026-07-04 21:43:10.513082+00	6jwhoiad4cso	cf4deea3-5906-42af-a4c7-a06ac3e4aaec
00000000-0000-0000-0000-000000000000	39	itq6fkm7yu3q	a7b186ca-e6c3-4ece-9349-26a0dbf0defa	f	2026-07-04 21:43:10.513531+00	2026-07-04 21:43:10.513531+00	lg7ulakm6bub	cf4deea3-5906-42af-a4c7-a06ac3e4aaec
00000000-0000-0000-0000-000000000000	41	p2tqwgjaactk	a7b186ca-e6c3-4ece-9349-26a0dbf0defa	t	2026-07-04 22:39:23.054741+00	2026-07-05 03:42:30.615015+00	\N	161d4f06-1eb2-4314-885d-cd387aa69b31
\.


--
-- Data for Name: saml_providers; Type: TABLE DATA; Schema: auth; Owner: supabase_auth_admin
--

COPY auth.saml_providers (id, sso_provider_id, entity_id, metadata_xml, metadata_url, attribute_mapping, created_at, updated_at, name_id_format) FROM stdin;
\.


--
-- Data for Name: saml_relay_states; Type: TABLE DATA; Schema: auth; Owner: supabase_auth_admin
--

COPY auth.saml_relay_states (id, sso_provider_id, request_id, for_email, redirect_to, created_at, updated_at, flow_state_id) FROM stdin;
\.


--
-- Data for Name: schema_migrations; Type: TABLE DATA; Schema: auth; Owner: supabase_auth_admin
--

COPY auth.schema_migrations (version) FROM stdin;
20171026211738
20171026211808
20171026211834
20180103212743
20180108183307
20180119214651
20180125194653
00
20210710035447
20210722035447
20210730183235
20210909172000
20210927181326
20211122151130
20211124214934
20211202183645
20220114185221
20220114185340
20220224000811
20220323170000
20220429102000
20220531120530
20220614074223
20220811173540
20221003041349
20221003041400
20221011041400
20221020193600
20221021073300
20221021082433
20221027105023
20221114143122
20221114143410
20221125140132
20221208132122
20221215195500
20221215195800
20221215195900
20230116124310
20230116124412
20230131181311
20230322519590
20230402418590
20230411005111
20230508135423
20230523124323
20230818113222
20230914180801
20231027141322
20231114161723
20231117164230
20240115144230
20240214120130
20240306115329
20240314092811
20240427152123
20240612123726
20240729123726
20240802193726
20240806073726
20241009103726
20250717082212
20250731150234
20250804100000
20250901200500
20250903112500
20250904133000
20250925093508
20251007112900
20251104100000
20251111201300
20251201000000
20260115000000
20260121000000
20260219120000
20260302000000
\.


--
-- Data for Name: sessions; Type: TABLE DATA; Schema: auth; Owner: supabase_auth_admin
--

COPY auth.sessions (id, user_id, created_at, updated_at, factor_id, aal, not_after, refreshed_at, user_agent, ip, tag, oauth_client_id, refresh_token_hmac_key, refresh_token_counter, scopes) FROM stdin;
5e2481e9-381d-4653-bc19-24944437d565	8526382f-7ebb-4245-b8be-84c1f7a14e40	2026-06-12 00:24:13.098937+00	2026-06-12 00:24:13.098937+00	\N	aal1	\N	\N	curl/8.19.0	172.30.0.1	\N	\N	\N	\N	\N
cf4deea3-5906-42af-a4c7-a06ac3e4aaec	a7b186ca-e6c3-4ece-9349-26a0dbf0defa	2026-07-04 17:34:26.162382+00	2026-07-04 21:43:10.515345+00	\N	aal1	\N	2026-07-04 21:43:10.515309	Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Claude/1.18286.0 Chrome/148.0.7778.271 Electron/42.5.1 Safari/537.36 MSIX	172.30.0.1	\N	\N	\N	\N	\N
8c92f57b-8cd2-471f-a729-c1cd844ab3ab	f69c2370-64a4-467b-9be5-0262b271986a	2026-07-05 06:01:05.945827+00	2026-07-05 06:01:05.945827+00	\N	aal1	\N	\N	curl/8.21.0	172.30.0.1	\N	\N	\N	\N	\N
884fe246-081b-4631-a5f2-aa0c16da7f93	f69c2370-64a4-467b-9be5-0262b271986a	2026-07-05 06:01:24.963671+00	2026-07-05 06:01:24.963671+00	\N	aal1	\N	\N	curl/8.21.0	172.30.0.1	\N	\N	\N	\N	\N
70d05132-78da-4c35-9733-35fe23dcfca7	f69c2370-64a4-467b-9be5-0262b271986a	2026-07-05 06:01:57.246873+00	2026-07-05 06:01:57.246873+00	\N	aal1	\N	\N	Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/149.0.0.0 Safari/537.36	172.30.0.1	\N	\N	\N	\N	\N
161d4f06-1eb2-4314-885d-cd387aa69b31	a7b186ca-e6c3-4ece-9349-26a0dbf0defa	2026-07-04 22:39:23.052978+00	2026-07-05 06:37:53.267037+00	\N	aal1	\N	2026-07-05 06:37:53.267005	Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Claude/1.18286.0 Chrome/148.0.7778.271 Electron/42.5.1 Safari/537.36 MSIX	172.30.0.1	\N	\N	\N	\N	\N
fb8bc5fb-a570-417b-bd94-875106aabcc2	a7b186ca-e6c3-4ece-9349-26a0dbf0defa	2026-07-05 06:40:06.837992+00	2026-07-05 06:40:06.837992+00	\N	aal1	\N	\N	Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Claude/1.18286.0 Chrome/148.0.7778.271 Electron/42.5.1 Safari/537.36 MSIX	172.30.0.1	\N	\N	\N	\N	\N
45070129-bd31-4083-b0bd-9d5463d7adb4	f69c2370-64a4-467b-9be5-0262b271986a	2026-07-05 06:10:45.722694+00	2026-07-05 07:09:16.27909+00	\N	aal1	\N	2026-07-05 07:09:16.279051	Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/149.0.0.0 Safari/537.36	172.30.0.1	\N	\N	\N	\N	\N
\.


--
-- Data for Name: sso_domains; Type: TABLE DATA; Schema: auth; Owner: supabase_auth_admin
--

COPY auth.sso_domains (id, sso_provider_id, domain, created_at, updated_at) FROM stdin;
\.


--
-- Data for Name: sso_providers; Type: TABLE DATA; Schema: auth; Owner: supabase_auth_admin
--

COPY auth.sso_providers (id, resource_id, created_at, updated_at, disabled) FROM stdin;
\.


--
-- Data for Name: users; Type: TABLE DATA; Schema: auth; Owner: supabase_auth_admin
--

COPY auth.users (instance_id, id, aud, role, email, encrypted_password, email_confirmed_at, invited_at, confirmation_token, confirmation_sent_at, recovery_token, recovery_sent_at, email_change_token_new, email_change, email_change_sent_at, last_sign_in_at, raw_app_meta_data, raw_user_meta_data, is_super_admin, created_at, updated_at, phone, phone_confirmed_at, phone_change, phone_change_token, phone_change_sent_at, email_change_token_current, email_change_confirm_status, banned_until, reauthentication_token, reauthentication_sent_at, is_sso_user, deleted_at, is_anonymous) FROM stdin;
00000000-0000-0000-0000-000000000000	8526382f-7ebb-4245-b8be-84c1f7a14e40	authenticated	authenticated	admin@admin.com	$2a$10$.Bf71zEELeDFNR93vD5JeuqLEWuZ9DO6MyX.R9xvec58ngMcSAi1a	2026-06-12 00:24:01.261576+00	\N		\N		\N			\N	2026-06-12 00:24:13.098873+00	{"provider": "email", "providers": ["email"]}	{"email_verified": true}	\N	2026-06-12 00:24:01.25746+00	2026-06-12 00:24:13.101496+00	\N	\N			\N		0	\N		\N	f	\N	f
00000000-0000-0000-0000-000000000000	a7b186ca-e6c3-4ece-9349-26a0dbf0defa	authenticated	authenticated	veedon.test@local.dev	$2a$10$X67z7dQ.Sqo8oPjZ2SDux.wRj82bwiEZISY0eoeZdGu1M/8gt4e9y	2026-07-04 13:10:17.919015+00	\N		\N		\N			\N	2026-07-05 06:40:06.837935+00	{"provider": "email", "providers": ["email"]}	{"email_verified": true}	\N	2026-07-04 13:10:17.909015+00	2026-07-05 06:40:06.840459+00	\N	\N			\N		0	\N		\N	f	\N	f
00000000-0000-0000-0000-000000000000	f69c2370-64a4-467b-9be5-0262b271986a	authenticated	authenticated	ashraffarid@gmail.com	$2a$10$tqUeGDjjwYj.Ak3UJiNeBeMYmIXyPRTUXnt4stP.BXHjtJjA6WESi	2026-07-04 12:21:13.247005+00	\N		\N		\N			\N	2026-07-05 06:10:45.722631+00	{"provider": "email", "providers": ["email"]}	{"email_verified": true}	\N	2026-06-12 00:22:09.683083+00	2026-07-05 07:09:16.278112+00	\N	\N			\N		0	\N		\N	f	\N	f
\.


--
-- Data for Name: webauthn_challenges; Type: TABLE DATA; Schema: auth; Owner: supabase_auth_admin
--

COPY auth.webauthn_challenges (id, user_id, challenge_type, session_data, created_at, expires_at) FROM stdin;
\.


--
-- Data for Name: webauthn_credentials; Type: TABLE DATA; Schema: auth; Owner: supabase_auth_admin
--

COPY auth.webauthn_credentials (id, user_id, credential_id, public_key, attestation_type, aaguid, sign_count, transports, backup_eligible, backed_up, friendly_name, created_at, updated_at, last_used_at) FROM stdin;
\.


--
-- Data for Name: ai_analysis_logs; Type: TABLE DATA; Schema: public; Owner: postgres
--

COPY public.ai_analysis_logs (id, camera_id, alert_template_id, prompt, response_text, model, image_url, metadata, created_at) FROM stdin;
\.


--
-- Data for Name: ai_models; Type: TABLE DATA; Schema: public; Owner: postgres
--

COPY public.ai_models (id, name, description, category, version, enabled, configuration, created_at) FROM stdin;
\.


--
-- Data for Name: alert_template_events; Type: TABLE DATA; Schema: public; Owner: postgres
--

COPY public.alert_template_events (id, alert_template_id, event_type_id, created_at) FROM stdin;
\.


--
-- Data for Name: alert_template_industries; Type: TABLE DATA; Schema: public; Owner: postgres
--

COPY public.alert_template_industries (id, alert_template_id, industry_id, created_at) FROM stdin;
\.


--
-- Data for Name: alert_templates; Type: TABLE DATA; Schema: public; Owner: postgres
--

COPY public.alert_templates (id, name, name_ar, description, description_ar, detection_method, model_file_url, model_type, huggingface_api_key, model_api_endpoint, enabled, created_at, updated_at, created_by, api_provider) FROM stdin;
0577772b-1164-45e8-9ace-4289bcae6f6a	Fire Detection	كشف الحرائق	Detects fire and smoke in camera feeds	يكشف النار والدخان في لقطات الكاميرا	file	\N	yolov8	\N	\N	t	2026-06-12 00:20:00.515322+00	2026-06-12 00:20:00.515322+00	\N	\N
006481be-c30d-485a-86ee-f2aadcff7f9b	Person Detection	كشف الأشخاص	Detects people in restricted areas	يكشف الأشخاص في المناطق المحظورة	file	\N	yolov8	\N	\N	t	2026-06-12 00:20:00.515322+00	2026-06-12 00:20:00.515322+00	\N	\N
167d1298-4af7-42e2-81b2-cc47809d8f39	Violence Detection	كشف العنف	Detects violent behavior and fights	يكشف السلوك العنيف والمشاجرات	api	\N	\N	\N	\N	t	2026-06-12 00:20:00.515322+00	2026-06-12 00:20:00.515322+00	\N	\N
2768d6b4-b9a2-488b-83a6-78012c2e9a6e	Weapon Detection	كشف الأسلحة	Detects weapons like guns and knives	يكشف الأسلحة مثل المسدسات والسكاكين	file	\N	yolov8	\N	\N	t	2026-06-12 00:20:00.515322+00	2026-06-12 00:20:00.515322+00	\N	\N
\.


--
-- Data for Name: aman_instances; Type: TABLE DATA; Schema: public; Owner: postgres
--

COPY public.aman_instances (id, organization_id, branch_id, name, base_url, access_token, active, created_by, created_at, updated_at, username, password, dashboard_path, aman_api_url) FROM stdin;
\.


--
-- Data for Name: auto_sync_settings; Type: TABLE DATA; Schema: public; Owner: postgres
--

COPY public.auto_sync_settings (id, enabled, interval_minutes, last_sync, next_sync, created_at, updated_at) FROM stdin;
cc3410be-5a77-41af-b0ff-6b2bba3ca6a0	t	30	\N	\N	2026-06-12 00:20:00.905846+00	2026-06-12 00:20:00.905846+00
\.


--
-- Data for Name: branch_roles; Type: TABLE DATA; Schema: public; Owner: postgres
--

COPY public.branch_roles (id, user_id, branch_id, role, created_at) FROM stdin;
\.


--
-- Data for Name: branches; Type: TABLE DATA; Schema: public; Owner: postgres
--

COPY public.branches (id, organization_id, name, address, latitude, longitude, active, created_at, device_token, config_version, last_seen, agent_info, alert_numbers, engine_image, device_status, device_fingerprint, hardware_info, is_vm, allow_vm, device_first_seen) FROM stdin;
59591920-9105-4a8b-a658-8f3489384d71	e8352779-7fc5-4492-9672-7a07a779b25b	Headquarters	Main Location	\N	\N	t	2026-06-12 00:24:01.257248+00	7a4bbdb7704c51432d58a785b425089e8873e388a3e41fc266cf772669379f4e	1	\N	{}		\N	pending	\N	{}	f	f	\N
c81c2c3a-7058-4ec4-9d59-7d342bba78e7	67e83f81-01f6-4621-91dc-bc59048c7c17	Headquarters	Main Location	\N	\N	t	2026-06-12 00:22:09.682823+00	6b3b5fbfb1626e4f8fac1bdc993a871cf4d44475f90c46f18a84da366d1a5b0d	4	\N	{}		\N	approved	5374890627fb1acece2d6ce9f479dc8e5e89afa1e48a49eea67a4d8a0315ba48	{"cpu": "Intel N100", "model": "SER5 N100", "hostname": "veedon-riyadh-01", "cpu_cores": 4, "manufacturer": "Beelink"}	f	f	2026-07-04 18:20:13.850513+00
e0d2a0a4-3cfa-4f26-8e22-0f3b1e0e7fcd	557d5fb7-b321-40ee-a074-9e847b4b8962	Headquarters	Main Location	\N	\N	t	2026-07-04 13:10:17.908345+00	b5b11b3081ed3ca58082196ab68880a5bc8fa7c06703f55a081a368e00e47d73	1	\N	{}		\N	pending	\N	{}	f	f	\N
0ab2ca49-ad88-4630-afb6-3ef008e1cef5	cb9e9cfe-03a8-44b1-adb3-854ce61fbe21	فرع العليا	\N	\N	\N	t	2026-07-04 13:03:02.211031+00	9ca57185caba7e2246cf619e6836dfe09c0869c17e28d1406da4e1f653e2a2ba	21	2026-07-05 07:23:53.295752+00	{"status": "active", "cameras_up": {"demo": true}, "agent_version": "0.1.0"}		\N	approved	6f908075c1d93e8d48f1d917c09c7e5c412b8432eb46d25837bcd30ca90f3202	{"cpu": "Intel(R) Core(TM) Ultra 9 285K", "model": "", "hostname": "74d327f67fd8", "cpu_cores": 24, "vm_reason": "hypervisor-flag", "vm_detected": true, "board_serial": "", "manufacturer": "", "product_uuid": ""}	t	t	2026-07-04 22:50:07.62701+00
\.


--
-- Data for Name: camera_alert_assignments; Type: TABLE DATA; Schema: public; Owner: postgres
--

COPY public.camera_alert_assignments (id, camera_id, alert_template_id, enabled, confidence_threshold, created_at) FROM stdin;
\.


--
-- Data for Name: camera_event_assignments; Type: TABLE DATA; Schema: public; Owner: postgres
--

COPY public.camera_event_assignments (id, camera_id, event_type_id, enabled, confidence_threshold, created_at, config) FROM stdin;
1449af7b-c1af-431a-b543-2f6586ef2d1d	e2491873-0570-4d58-9c54-c9acabd8a86b	434c320c-a7ba-4d81-b9d6-40ef5bcc98ea	t	0.7	2026-07-04 13:03:02.211031+00	{"threshold": 5}
e9eb133a-7925-46eb-81d9-f9d3ee0b4b15	e2491873-0570-4d58-9c54-c9acabd8a86b	a3d044e8-fa0f-4dcd-b223-af9e084e4a8d	t	0.7	2026-07-04 13:05:47.026205+00	{}
42e3bc7d-8c09-4b67-8ad4-78a085dc02d4	e2491873-0570-4d58-9c54-c9acabd8a86b	4010ee56-5741-463c-836c-139e14ddc5ce	t	0.7	2026-07-04 22:49:09.881723+00	{}
6dcc8653-979c-4348-b594-b3b351691681	e2491873-0570-4d58-9c54-c9acabd8a86b	5bef373a-8fd0-439d-b187-26a55abd48e1	t	0.7	2026-07-04 22:49:09.881723+00	{}
8e83808b-5d0d-442a-b04b-ac80f21b189c	e2491873-0570-4d58-9c54-c9acabd8a86b	a35e8907-986d-475a-8e6a-657516d1fd36	t	0.7	2026-07-04 17:35:04.55902+00	{"cooldown_s": 20, "coordinates": "0,0,1280,0,1280,720,0,720"}
3f78fcf7-ddd0-4c3e-bb44-9a849973cb2d	e2491873-0570-4d58-9c54-c9acabd8a86b	4e376f7a-38a1-4a14-af69-43c86e8f6e4c	t	0.7	2026-07-04 23:11:53.081267+00	{"model": "veedon-detect-v1.onnx", "min_conf": 0.4, "interval_s": 15, "detect_labels": ["cell phone"]}
563fd084-7bfa-4f08-9469-a99c3213210c	e2491873-0570-4d58-9c54-c9acabd8a86b	0122a3c6-9eb8-42ea-8a10-374cbacbf34a	t	0.7	2026-07-05 06:56:31.279702+00	{}
07c2abb3-56f2-467b-9cc8-9ed57ad036b5	e2491873-0570-4d58-9c54-c9acabd8a86b	30b2d0b2-2673-4301-9ab4-6d76c631adf0	t	0.7	2026-07-05 06:56:31.279702+00	{}
7603d50b-80c1-48bc-bbf7-4993773292eb	e2491873-0570-4d58-9c54-c9acabd8a86b	5eaa7f79-b05e-4afa-9a1f-554f3ec72841	t	0.7	2026-07-05 06:56:31.279702+00	{}
26f5cc6c-a8e2-4f38-b7a8-f84726fa1ac7	e2491873-0570-4d58-9c54-c9acabd8a86b	c03d8b69-5375-435a-bbd9-158f367d399a	t	0.7	2026-07-05 06:56:31.279702+00	{}
\.


--
-- Data for Name: camera_sources; Type: TABLE DATA; Schema: public; Owner: postgres
--

COPY public.camera_sources (id, name, name_ar, protocol, requires_auth, default_port, url_pattern, description, description_ar, icon, active, created_at, updated_at, created_by) FROM stdin;
6f7c3b05-7ae2-42a6-a4a6-2206850037a4	RTSP Stream	بث RTSP	rtsp	t	554	rtsp://[username]:[password]@[host]:[port]/[path]	Real Time Streaming Protocol for IP cameras	بروتوكول البث المباشر لكاميرات IP	camera	t	2026-06-12 00:20:00.468466+00	2026-06-12 00:20:00.468466+00	\N
bbb88b83-248f-4a2b-8a0b-15f1652846b3	HTTP Stream	بث HTTP	http	f	80	http://[host]:[port]/[path]	HTTP video stream	بث الفيديو عبر HTTP	camera	t	2026-06-12 00:20:00.468466+00	2026-06-12 00:20:00.468466+00	\N
b3ad6295-3240-48ae-883b-b857a1ac8448	HTTPS Stream	بث HTTPS	https	f	443	https://[host]:[port]/[path]	Secure HTTP video stream	بث الفيديو الآمن عبر HTTPS	camera	t	2026-06-12 00:20:00.468466+00	2026-06-12 00:20:00.468466+00	\N
699ed311-3a95-4850-90c3-b56b623cd388	YouTube Live	يوتيوب مباشر	youtube	f	\N	https://youtube.com/watch?v=[id]	YouTube live stream	البث المباشر من يوتيوب	camera	t	2026-06-12 00:20:00.468466+00	2026-06-12 00:20:00.468466+00	\N
ff2d5c2c-8edf-49a5-a330-018f865bf077	File Upload	رفع ملف	file	f	\N	\N	Upload video file	رفع ملف فيديو	camera	t	2026-06-12 00:20:00.468466+00	2026-06-12 00:20:00.468466+00	\N
bc16ba6a-47a5-414a-a5fb-af7e15a68b54	Webcam	كاميرا ويب	webcam	f	\N	\N	Computer webcam	كاميرا الكمبيوتر	camera	t	2026-06-12 00:20:00.468466+00	2026-06-12 00:20:00.468466+00	\N
ed0ffd21-1716-4a31-b9c8-d7a2cdfa88db	HLS Stream	بث HLS	hls	f	\N	http://[host]:[port]/[path].m3u8	HTTP Live Streaming	البث المباشر عبر HTTP	camera	t	2026-06-12 00:20:00.468466+00	2026-06-12 00:20:00.468466+00	\N
\.


--
-- Data for Name: cameras; Type: TABLE DATA; Schema: public; Owner: postgres
--

COPY public.cameras (id, branch_id, name, rtsp_url, frigate_identifier, status, last_connection, config, created_at, model, features, max_resolution, security_zone_id, description, detection_rules, updated_at, enabled, frigate_instance_id) FROM stdin;
e2491873-0570-4d58-9c54-c9acabd8a86b	0ab2ca49-ad88-4630-afb6-3ef008e1cef5	كاميرا شبكة حية (اختبار)	http://95.9.96.3:81/mjpg/video.mjpg	demo	offline	\N	\N	2026-07-04 13:03:02.211031+00	AI-CAM-4K	{"ai_analysis": true, "night_vision": true, "audio_recording": false, "motion_detection": true}	4K	\N	\N	[]	2026-07-05 05:52:22.335968+00	t	\N
\.


--
-- Data for Name: chat_messages; Type: TABLE DATA; Schema: public; Owner: postgres
--

COPY public.chat_messages (id, thread_id, organization_id, sender_id, content, metadata, created_at) FROM stdin;
\.


--
-- Data for Name: chat_thread_participants; Type: TABLE DATA; Schema: public; Owner: postgres
--

COPY public.chat_thread_participants (id, thread_id, user_id, added_at) FROM stdin;
\.


--
-- Data for Name: chat_threads; Type: TABLE DATA; Schema: public; Owner: postgres
--

COPY public.chat_threads (id, organization_id, created_by, name, is_private, created_at, updated_at) FROM stdin;
\.


--
-- Data for Name: chatbot_knowledge_base; Type: TABLE DATA; Schema: public; Owner: postgres
--

COPY public.chatbot_knowledge_base (id, language, content_type, title, data, is_active, display_order, created_at, updated_at, created_by, updated_by) FROM stdin;
516a7c9e-6e24-4538-aded-cbb424fc7f30	ar	company	معلومات الشركة	{"ceo": "م. فهد العواضي", "cto": "م. أشرف فريد", "name": "Beyond Senses", "slogan": "صُنع في المملكة العربية السعودية", "address": "طريق الملك فهد، الرياض، المملكة العربية السعودية", "mapLink": "https://maps.app.goo.gl/gbEdeXjvV7pHVgn46", "location": "الرياض، المملكة العربية السعودية", "ceo_title": "المدير التنفيذي", "cto_title": "رئيس التطوير التقني", "coordinates": "24.7106° شمال، 46.6941° شرق", "description": "شركة متخصصة في تقنيات الذكاء الاصطناعي والحلول الذكية الرائدة في المملكة العربية السعودية"}	t	0	2026-06-12 00:20:00.585342+00	2026-06-12 00:20:00.585342+00	\N	\N
bf1b1ae1-e9d2-4746-8579-414cf438855c	ar	services	خدماتنا	{"services": [{"title": "المساعد الذكي", "features": ["ذكاء اصطناعي متقدم", "حلول مخصصة", "فهم الاحتياجات", "تقنيات حديثة"], "subtitle": "BEYONDSENSES AGENT", "description": "يقودك نحو المستقبل", "fullDescription": "مساعد ذكي متطور يستخدم أحدث تقنيات الذكاء الاصطناعي لفهم احتياجاتك وتقديم حلول مخصصة"}, {"title": "الذكاء الاصطناعي والتعلم الآلي", "features": ["خوارزميات متقدمة", "تعلم عميق", "حلول مخصصة", "أنظمة ذكية"], "subtitle": "AI LAB", "description": "أنظمة ذكية", "fullDescription": "حلول مصممة خصيصاً لتلبية احتياجات عملك الفريدة باستخدام خوارزميات التعلم العميق"}, {"title": "نظام المبنى الذكي", "features": ["إدارة الإضاءة", "التحكم في التكييف", "الأمان المتقدم", "توفير الطاقة"], "subtitle": "BEYONDSENSES BUILDING", "description": "إدارة وتحكم متطور", "fullDescription": "نظام إدارة المباني الذكي الذي يتحكم في الإضاءة والتكييف والأمان والمراقبة بطريقة تلقائية، مما يوفر الطاقة ويحسن الراحة والأمان للمستخدمين"}, {"title": "كشف السرقة بالذكاء الاصطناعي", "features": ["كشف فوري", "دقة 99%", "تنبيهات ذكية", "تسجيل الأحداث", "مراقبة 24/7"], "description": "نظام متقدم للكشف عن السرقة في الوقت الفعلي باستخدام تقنيات الرؤية الحاسوبية"}, {"title": "المراقبة الذكية", "features": ["تحليل السلوك", "كشف الأنماط", "تتبع الحركة", "تحليل الحشود"], "description": "أنظمة مراقبة متطورة مدعومة بالذكاء الاصطناعي لتحليل السلوك والكشف عن الأنماط المشبوهة"}, {"title": "تحليل البيانات الذكي", "features": ["تحليل الأنماط", "تقارير تفصيلية", "توقعات ذكية", "لوحات تحكم"], "description": "تحليل متقدم للبيانات باستخدام الذكاء الاصطناعي لاستخراج رؤى قيمة"}]}	t	0	2026-06-12 00:20:00.585342+00	2026-06-12 00:20:00.585342+00	\N	\N
20eec361-298d-4927-8a97-b6763566fd43	ar	sectors	قطاعاتنا	{"sectors": [{"name": "التجارة والمتاجر", "description": "حلول ذكية لمراقبة المتاجر والمراكز التجارية لضمان الأمان ومنع السرقة", "applications": ["كشف السرقة الفوري", "تحليل سلوك العملاء", "مراقبة المخزون", "تقارير مفصلة"]}, {"name": "الرعاية الصحية", "description": "نظم مراقبة متطورة للمستشفيات والعيادات لضمان سلامة المرضى والطاقم الطبي", "applications": ["مراقبة غرف العمليات", "كشف حالات الطوارئ", "تتبع المعدات الطبية", "حماية المرضى"]}, {"name": "الضيافة والفنادق", "description": "حلول أمنية شاملة للفنادق والمنتجعات لضمان راحة وأمان النزلاء", "applications": ["مراقبة اللوبي والممرات", "أمان المصاعد", "حماية المسابح", "كشف الأنشطة المشبوهة"]}, {"name": "المطاعم والمقاهي", "description": "نظم مراقبة ذكية للمطاعم لضمان سلامة الطعام وأمان العملاء", "applications": ["مراقبة المطبخ", "كشف الحوادث", "تحليل تدفق العملاء", "ضمان النظافة"]}, {"name": "الزراعة والمزارع", "description": "تقنيات مراقبة متقدمة للمزارع والمنشآت الزراعية لحماية المحاصيل والماشية", "applications": ["مراقبة المحاصيل", "كشف الآفات", "تتبع الماشية", "مراقبة البيئة"]}, {"name": "المرافق الرياضية", "description": "حلول أمنية للملاعب والنوادي الرياضية لضمان سلامة الرياضيين والجماهير", "applications": ["مراقبة الملاعب", "كشف الشغب", "أمان المدرجات", "تحليل الحشود"]}, {"name": "المستودعات والمخازن", "description": "حماية المخزون من السرقة والاختلاس مع مراقبة العمال والمعدات", "applications": ["حماية المخزون", "تتبع العمال", "مراقبة المعدات", "كشف النشاط المشبوه"]}]}	t	0	2026-06-12 00:20:00.585342+00	2026-06-12 00:20:00.585342+00	\N	\N
8c312c67-627a-4b8d-8a4b-8c7bc392fa28	ar	integrations	تكاملاتنا	{"integrations": ["Hikvision", "Axis", "Dahua", "Genetec", "Milestone", "Hanwha Vision", "Eagle Eye", "Digital Watchdog", "Mobotix", "NetworkOptix", "Immix", "Tyco ExacqVision", "Synectics", "SureView", "Monitor Computer Systems", "Trackforce", "Patriot", "SafeStar", "Raptor", "Intrado", "Alertus", "Kronos", "iViSEC"]}	t	0	2026-06-12 00:20:00.585342+00	2026-06-12 00:20:00.585342+00	\N	\N
0214ee81-f7cc-4d64-a8fc-245b78d6f6b5	ar	features	ميزاتنا الرئيسية	{"features": [{"title": "كشف السرقة في الوقت الفعلي", "description": "مدعوم بالذكاء الاصطناعي لحماية متجرك من السرقة والاختلاس"}, {"title": "تحليل مستمر لتدفقات الفيديو", "description": "برنامجنا يحلل بشكل مستمر تدفقات الفيديو الخاصة بك"}, {"title": "تنبيهات فورية", "description": "احصل على تنبيهات في الوقت الفعلي عند اكتشاف النشاط المشبوه"}]}	t	0	2026-06-12 00:20:00.585342+00	2026-06-12 00:20:00.585342+00	\N	\N
96ef24d7-5ce5-47e3-a9f9-384c27d7b879	ar	stats	إحصائياتنا	{"stats": [{"label": "مشروع منجز", "number": "500+"}, {"label": "رضا العملاء", "number": "98%"}, {"label": "دعم فني", "number": "24/7"}, {"label": "عميل سعيد", "number": "50+"}]}	t	0	2026-06-12 00:20:00.585342+00	2026-06-12 00:20:00.585342+00	\N	\N
c98c0be4-cff1-449a-ada8-8d83ad07fb38	ar	contact	تواصل معنا	{"email": "info@beyondsenses.sa", "phone": "+966544877622", "website": "https://beyondsenses.sa", "whatsapp": "+966544877622", "workHours": "الأحد - الخميس: 8:00 ص - 6:00 م"}	t	0	2026-06-12 00:20:00.585342+00	2026-06-12 00:20:00.585342+00	\N	\N
f0255543-a8cd-40ad-bc16-85bbcad719ea	en	company	Company Information	{"ceo": "Eng. Fahd Al-Awadi", "cto": "Eng. Ashraf Farid", "name": "Beyond Senses", "slogan": "Made in Saudi Arabia", "address": "King Fahd Road, Riyadh, Saudi Arabia", "mapLink": "https://maps.app.goo.gl/gbEdeXjvV7pHVgn46", "location": "Riyadh, Saudi Arabia", "ceo_title": "Chief Executive Officer", "cto_title": "Chief Technology Officer", "coordinates": "24.7106° N, 46.6941° E", "description": "A leading company specializing in AI technologies and smart solutions in Saudi Arabia"}	t	0	2026-06-12 00:20:00.585342+00	2026-06-12 00:20:00.585342+00	\N	\N
80713579-3c70-4d00-a2ae-a26e6ef6f375	en	services	Our Services	{"services": [{"title": "AI Assistant", "features": ["Advanced AI", "Custom solutions", "Need understanding", "Modern technologies"], "subtitle": "BEYONDSENSES AGENT", "description": "Leading you to the future", "fullDescription": "Advanced AI assistant using cutting-edge artificial intelligence to understand your needs and provide customized solutions"}, {"title": "AI & Machine Learning", "features": ["Advanced algorithms", "Deep learning", "Custom solutions", "Smart systems"], "subtitle": "AI LAB", "description": "Intelligent systems", "fullDescription": "Solutions specifically designed to meet your unique business needs using deep learning algorithms"}, {"title": "Smart Building System", "features": ["Lighting management", "HVAC control", "Advanced security", "Energy saving"], "subtitle": "BEYONDSENSES BUILDING", "description": "Advanced management and control", "fullDescription": "Smart building management system that automatically controls lighting, HVAC, security, and monitoring, saving energy and improving comfort and safety"}]}	t	0	2026-06-12 00:20:00.585342+00	2026-06-12 00:20:00.585342+00	\N	\N
\.


--
-- Data for Name: detection_rules; Type: TABLE DATA; Schema: public; Owner: postgres
--

COPY public.detection_rules (id, organization_id, name, description, object_types, min_confidence, cooldown_seconds, notification_channels, created_at, updated_at) FROM stdin;
6650b86c-4917-44f6-8d8f-0f65a251d05a	\N	Fire Detection	Detect fire and smoke incidents	{fire,smoke}	0.80	60	\N	2026-06-12 00:20:00.473483+00	2026-06-12 00:20:00.473483+00
3148a9a8-b1e4-4e72-b29e-2e034a6389e2	\N	Person Counting	Count number of people in area	{person}	0.70	60	\N	2026-06-12 00:20:00.473483+00	2026-06-12 00:20:00.473483+00
838e9554-72a8-4119-bae9-bf281eb437c6	\N	Cleanliness Monitoring	Monitor cleanliness and hygiene standards	{garbage,spill,mess}	0.60	60	\N	2026-06-12 00:20:00.473483+00	2026-06-12 00:20:00.473483+00
ad4378dd-4f93-4004-806e-4036d4b213d1	\N	Vehicle Detection	Detect vehicles in restricted areas	{car,truck,motorcycle}	0.70	60	\N	2026-06-12 00:20:00.473483+00	2026-06-12 00:20:00.473483+00
f2fa4275-0246-4c54-b320-2a4a3476e5b6	\N	Intrusion Detection	Detect unauthorized access	{person}	0.80	60	\N	2026-06-12 00:20:00.473483+00	2026-06-12 00:20:00.473483+00
\.


--
-- Data for Name: event_types; Type: TABLE DATA; Schema: public; Owner: postgres
--

COPY public.event_types (id, name_en, name_ar, description_en, description_ar, icon, color, enabled, created_at, updated_at, created_by, feature_key, kind, default_config, available, sector) FROM stdin;
b5c97e7f-dd17-4398-a5be-1d9e4416496b	person	شخص	Person detection	اكتشاف الأشخاص	user	#10b981	t	2026-06-12 00:20:00.535256+00	2026-06-12 00:20:00.535256+00	\N	\N	rule	{}	t	general
ebf532ab-cdab-4406-adcf-b3007e16a601	car	سيارة	Vehicle detection	اكتشاف المركبات	car	#3b82f6	t	2026-06-12 00:20:00.535256+00	2026-06-12 00:20:00.535256+00	\N	\N	rule	{}	t	general
fac38019-3320-4e0e-8b58-7db4d3a92fa5	fire	حريق	Fire detection	اكتشاف الحرائق	flame	#ef4444	t	2026-06-12 00:20:00.535256+00	2026-06-12 00:20:00.535256+00	\N	\N	rule	{}	t	general
5775d56e-520a-4629-b5be-ce07ad111e0f	weapon	سلاح	Weapon detection	اكتشاف الأسلحة	shield-alert	#dc2626	t	2026-06-12 00:20:00.535256+00	2026-06-12 00:20:00.535256+00	\N	\N	rule	{}	t	general
3dbe0ee5-7e00-4093-8ce3-31bb4567d2fc	theft	سرقة	Theft detection	اكتشاف السرقة	alert-triangle	#f59e0b	t	2026-06-12 00:20:00.535256+00	2026-06-12 00:20:00.535256+00	\N	\N	rule	{}	t	general
9b369cba-4991-4014-84f6-6126ffc838e0	intrusion	تسلل	Intrusion detection	اكتشاف التسلل	shield-x	#8b5cf6	t	2026-06-12 00:20:00.535256+00	2026-06-12 00:20:00.535256+00	\N	\N	rule	{}	t	general
8938f6a8-e7b8-4036-ba34-736f98c5939d	crowd	حشد	Crowd detection	اكتشاف التجمعات	users	#06b6d4	t	2026-06-12 00:20:00.535256+00	2026-06-12 00:20:00.535256+00	\N	\N	rule	{}	t	general
274ffa1b-c95f-40d9-82eb-0d409b472666	violence	عنف	Violence detection	اكتشاف العنف	zap	#e11d48	t	2026-06-12 00:20:00.535256+00	2026-06-12 00:20:00.535256+00	\N	\N	rule	{}	t	general
a35e8907-986d-475a-8e6a-657516d1fd36	Restricted Zone	منطقة ممنوعة	\N	تنبيه عند دخول شخص منطقة محددة (مخزن، مكتب كاش…)	alert-circle	#3b82f6	t	2026-07-04 12:59:43.685099+00	2026-07-04 12:59:43.685099+00	\N	restricted_zone	rule	{"cooldown_s": 300, "coordinates": ""}	t	general
434c320c-a7ba-4d81-b9d6-40ef5bcc98ea	Crowding	تكدس / ازدحام	\N	تنبيه عند تجاوز عدد الأشخاص حداً معيناً	alert-circle	#3b82f6	t	2026-07-04 12:59:43.685099+00	2026-07-04 12:59:43.685099+00	\N	crowding	rule	{"threshold": 6, "cooldown_s": 600}	t	general
3d18428b-c66e-4789-821e-f9d10559c7ac	Queue Count	عدد المنتظرين في الطابور	\N	قياس دوري لعدد الأشخاص في منطقة الطابور — للتقارير	alert-circle	#3b82f6	t	2026-07-04 12:59:43.685099+00	2026-07-04 12:59:43.685099+00	\N	queue_count	rule	{"coordinates": "", "interval_min": 10}	t	general
21972d97-1417-47b6-8251-90721dd9b901	Camera Health	مراقبة صحة الكاميرات	\N	تنبيه إذا انقطعت كاميرا أو توقف بثها	alert-circle	#3b82f6	t	2026-07-04 12:59:43.685099+00	2026-07-04 12:59:43.685099+00	\N	camera_health	rule	{}	t	general
b727e420-e5f3-4f29-a033-6b97ff2244e2	Face Recognition	التعرف على الوجوه	\N	وحدة محرك: تمييز الوجوه المعروفة ووسم الأحداث بها (إدارة الوجوه من صفحة Faces)	alert-circle	#3b82f6	t	2026-07-04 17:59:18.912507+00	2026-07-04 17:59:18.912507+00	\N	face_recognition	engine	{}	t	general
ebd93cfb-2229-468f-bb8b-77f59ab3c1b8	License Plate Recognition	قراءة لوحات المركبات	\N	وحدة محرك: قراءة لوحات السيارات ووسمها (قوائم مراقبة من صفحة LPR)	alert-circle	#3b82f6	t	2026-07-04 17:59:18.912507+00	2026-07-04 17:59:18.912507+00	\N	lpr	engine	{}	t	general
4010ee56-5741-463c-836c-139e14ddc5ce	Semantic Search	البحث الدلالي بالوصف	\N	وحدة محرك: ابحث بالوصف الطبيعي مثل «شخص بجاكيت أحمر عند الباب»	alert-circle	#3b82f6	t	2026-07-04 17:59:18.912507+00	2026-07-04 17:59:18.912507+00	\N	semantic_search	engine	{}	t	general
34ebf417-a1b2-410e-b372-b4b3cf07d631	Birdseye	عين الطائر (كل الكاميرات)	\N	وحدة محرك: شاشة واحدة تجمع كل الكاميرات النشطة	alert-circle	#3b82f6	t	2026-07-04 17:59:18.912507+00	2026-07-04 17:59:18.912507+00	\N	birdseye	engine	{"mode": "objects"}	t	general
68216a86-e4e3-4286-a1d8-b89a2a80fc58	Continuous Recording	التسجيل المستمر	\N	وحدة محرك لكل كاميرا: تسجيل واحتفاظ بالمقاطع (أيام قابلة للضبط)	alert-circle	#3b82f6	t	2026-07-04 17:59:18.912507+00	2026-07-04 17:59:18.912507+00	\N	recording	engine	{"retain_days": 7}	t	general
24edb0fb-0b7c-4fdf-9af8-94e931c7578f	Audio Detection	كشف الأصوات	\N	وحدة محرك لكل كاميرا: صراخ، إنذار حريق، تحطم زجاج…	alert-circle	#3b82f6	t	2026-07-04 17:59:18.912507+00	2026-07-04 17:59:18.912507+00	\N	audio_detection	engine	{"labels": ["scream", "yell", "fire_alarm", "glass"]}	t	general
8ce0ecd4-336f-4d05-b978-8c08ca3da97b	Motion Mask	قناع الحركة (تجاهل مناطق)	\N	وحدة محرك لكل كاميرا: تجاهل مناطق لتقليل الإنذارات	alert-circle	#3b82f6	t	2026-07-04 17:59:18.912507+00	2026-07-04 17:59:18.912507+00	\N	motion_mask	engine	{"coordinates": ""}	t	general
b38f709b-04d0-48e5-9624-a51c62291bde	GenAI Descriptions	الوصف الذكي للأحداث (GenAI)	\N	وصف نصي تلقائي لكل حدث — يتطلب مفتاح مزود؛ قريباً	alert-circle	#3b82f6	t	2026-07-04 17:59:18.912507+00	2026-07-04 17:59:18.912507+00	\N	genai	engine	{}	f	general
a3d044e8-fa0f-4dcd-b223-af9e084e4a8d	Table Cleanliness	نظافة الطاولات (AI Vision)	\N	لقطة مجدولة تُحلَّل بالذكاء الاصطناعي: هل الطاولات نظيفة؟	alert-circle	#3b82f6	t	2026-07-04 12:59:43.685099+00	2026-07-04 22:36:39.745987+00	\N	table_cleanliness	vlm	{"interval_min": 60}	t	restaurant
a78dd2ab-1f56-45c9-8209-586109902a2b	Smoking Detection	كشف التدخين	\N	نموذج مخصص على الجهاز — قريباً	alert-circle	#3b82f6	t	2026-07-04 12:59:43.685099+00	2026-07-04 22:36:39.745987+00	\N	smoking	edge_model	{"model": "veedon-smoke-v1"}	f	restaurant
dcf4aa2c-33a1-42ad-9cd4-dad9f3d06cd3	Uniform / PPE	الزي / القفازات / غطاء الشعر	\N	نموذج مخصص — قريباً	alert-circle	#3b82f6	t	2026-07-04 12:59:43.685099+00	2026-07-04 22:36:39.745987+00	\N	uniform_ppe	edge_model	{"model": "veedon-ppe-v1"}	f	restaurant
39228aca-b03f-4b41-b87a-ca50165fded4	Poultry Health	مؤشرات صحة الدواجن (AI Vision)	\N	فحص دوري: خمول، نفوق ظاهر، تجمع غير طبيعي	alert-circle	#3b82f6	t	2026-07-04 12:59:43.685099+00	2026-07-04 22:36:39.748362+00	\N	poultry_health	vlm	{"interval_min": 30}	t	farm
8a0582fa-503a-445b-a2c9-e3332b39f3ea	Forklift Proximity	تقارب الرافعات الشوكية بالعمّال	\N	تنبيه عند اقتراب رافعة شوكية من عامل أقل من المسافة الآمنة — أخطر إصابة صناعية	alert-circle	#3b82f6	t	2026-07-04 22:36:39.749724+00	2026-07-04 22:36:39.749724+00	\N	forklift_proximity	edge_model	{"model": "veedon-forklift-v1", "min_distance_m": 2}	f	factory
4e376f7a-38a1-4a14-af69-43c86e8f6e4c	Phone Usage	استخدام الجوال أثناء العمل	\N	نموذج مخصص — قريباً	alert-circle	#3b82f6	t	2026-07-04 12:59:43.685099+00	2026-07-04 23:11:53.081267+00	\N	phone_usage	edge_model	{"model": "veedon-phone-v1"}	t	restaurant
9e0952fd-bda2-4c43-bc20-acb407d2f7a9	Ergonomic Posture	وضعيات العمل الخاطئة (Ergonomic)	\N	كشف الانحناء/الرفع الخاطئ لمنع إصابات العمود الفقري	alert-circle	#3b82f6	t	2026-07-04 22:36:39.749724+00	2026-07-04 22:36:39.749724+00	\N	ergonomic_posture	edge_model	{"model": "veedon-pose-v1"}	f	factory
279c25b1-1859-42e3-aeda-803b91ed2c22	Machine Zone Intrusion	دخول منطقة آلة خطرة	\N	تنبيه فوري عند دخول شخص منطقة آلة قيد التشغيل	alert-circle	#3b82f6	t	2026-07-04 22:36:39.749724+00	2026-07-04 22:36:39.749724+00	\N	machine_zone_intrusion	rule	{"cooldown_s": 120, "coordinates": ""}	t	factory
0122a3c6-9eb8-42ea-8a10-374cbacbf34a	Weapon Detection	كشف الأسلحة والأدوات الحادة	\N	كشف السلاح/الأداة الحادة عند البوابات — يبدأ كمساعد إشعار بتأكيد بشري إجباري	alert-circle	#3b82f6	t	2026-07-04 22:36:39.749724+00	2026-07-04 22:36:39.749724+00	\N	weapon_detection	edge_model	{"model": "veedon-weapon-v1"}	f	education
2936c589-b7f6-46f6-b584-47f7791d5d11	After-hours Intrusion	تسكّع/اقتحام خارج الدوام	\N	دخول أو تسكّع في مناطق محددة خارج أوقات الدوام	alert-circle	#3b82f6	t	2026-07-04 22:36:39.749724+00	2026-07-04 22:36:39.749724+00	\N	after_hours_intrusion	rule	{"cooldown_s": 300, "coordinates": ""}	t	education
30b2d0b2-2673-4301-9ab4-6d76c631adf0	Gate Attendance	عدّ الحضور عند البوابة	\N	قياس تدفّق الحضور والانصراف عند البوابات — بلا تعرّف على الأفراد	alert-circle	#3b82f6	t	2026-07-04 22:36:39.749724+00	2026-07-04 22:36:39.749724+00	\N	gate_attendance	rule	{"coordinates": "", "interval_min": 15}	t	education
9649ee9f-5d10-4f0c-8668-ddba22551d39	Patient Fall / Bed-exit	سقوط المريض / مغادرة السرير	\N	كشف سقوط المريض أو محاولته مغادرة السرير	alert-circle	#3b82f6	t	2026-07-04 22:36:39.749724+00	2026-07-04 22:36:39.749724+00	\N	patient_fall	edge_model	{"model": "veedon-fall-v1"}	f	health
edeb4170-a0d4-417d-940c-b8914c6d0071	Patient Elopement	هروب المريض من منطقة	\N	تنبيه عند وصول مريض مشوّش إلى مخرج أو منطقة ممنوعة	alert-circle	#3b82f6	t	2026-07-04 22:36:39.749724+00	2026-07-04 22:36:39.749724+00	\N	elopement	rule	{"cooldown_s": 60, "coordinates": ""}	t	health
4f1bbcf8-4642-450b-bb4a-dcdd6b949515	Hand Hygiene	الالتزام بنظافة اليدين	\N	رصد الالتزام بتعقيم اليدين عند نقاط الدخول/الخروج	alert-circle	#3b82f6	t	2026-07-04 22:36:39.749724+00	2026-07-04 22:36:39.749724+00	\N	hand_hygiene	edge_model	{"model": "veedon-hygiene-v1"}	f	health
b399745e-05d5-4620-b489-e7425b8d35d4	Staff Aggression	العنف/العدوانية ضد الطواقم	\N	كشف العدوانية تجاه الطواقم الطبية في الطوارئ والاستقبال	alert-circle	#3b82f6	t	2026-07-04 22:36:39.749724+00	2026-07-04 22:36:39.749724+00	\N	aggression_staff	vlm	{"interval_min": 0}	t	health
5bef373a-8fd0-439d-b187-26a55abd48e1	Industrial PPE	معدات الحماية الصناعية (خوذة/سترة/قفازات)	\N	كشف عدم ارتداء الخوذة أو السترة العاكسة أو القفازات في مناطق الخطر	alert-circle	#3b82f6	t	2026-07-04 22:36:39.749724+00	2026-07-04 22:49:09.875537+00	\N	ppe_industrial	edge_model	{"model": "veedon-ppe-ind-v1", "require": ["hardhat", "vest"]}	t	factory
5eaa7f79-b05e-4afa-9a1f-554f3ec72841	Fight Detection	كشف المشاجرات	\N	كشف العنف الجسدي: دفع، ضرب، تشابك، تجمّع مفاجئ حول شخصين	alert-circle	#3b82f6	t	2026-07-04 22:36:39.749724+00	2026-07-04 23:20:41.758671+00	\N	fight_detection	vlm	{"interval_min": 0}	t	education
c03d8b69-5375-435a-bbd9-158f367d399a	Bullying Detection	كشف التنمّر	\N	أنماط التنمّر: استهداف متكرر لطالب، عزل/إقصاء، مضايقة، إيماءات تهديد متكررة	alert-circle	#3b82f6	t	2026-07-04 23:20:41.762383+00	2026-07-04 23:20:41.762383+00	\N	bullying	vlm	{"interval_min": 0}	t	education
522a815b-d350-4370-b13e-1851e92a7c0f	Stair Fall	السقوط على السلالم	\N	كشف سقوط أو تعثّر شخص على الدرج/السلالم — منطقة إصابات عالية الخطورة	alert-circle	#3b82f6	t	2026-07-04 23:20:41.762383+00	2026-07-04 23:20:41.762383+00	\N	stair_fall	vlm	{"interval_min": 0}	t	education
e5f7495e-1f77-4049-b2af-7a4f81ffe706	Student Sleeping	نوم الطلبة في الفصل	\N	رصد الطلاب النائمين أو واضعي الرأس على الطاولة أثناء الحصة	alert-circle	#3b82f6	t	2026-07-04 23:20:41.762383+00	2026-07-04 23:20:41.762383+00	\N	student_sleeping	vlm	{"interval_min": 10}	t	education
d5de08cb-104c-4d25-8695-dc79905c6b70	Entry/Exit Count	عدّ الدخول والخروج	\N	قياس دوري لعدد الأشخاص في منطقة العبور — للزوّار (تجزئة)، الإشغال (مطاعم)، تدفق البوابات/الحافلات (مدارس)	alert-circle	#3b82f6	t	2026-07-05 04:11:43.420087+00	2026-07-05 04:11:43.420087+00	\N	entry_exit_count	rule	{"camera": "", "coordinates": "", "interval_min": 15}	t	general
a06d9b3a-a9bd-4ed1-ba23-2678441c271d	Wet Floor / Spill	أرضية مبتلة / انسكاب	\N	كشف الأرضيات المبتلة والانسكابات قبل الحوادث (مطالبات الانزلاق مكلفة)	alert-circle	#3b82f6	t	2026-07-05 06:54:33.699591+00	2026-07-05 06:54:33.699591+00	\N	slip_wet_floor	vlm	{"interval_min": 20}	t	hotel
411f2c5b-e3d3-4034-b5e3-a23491ddfc56	Pool Area Safety	سلامة منطقة المسبح	\N	طفل قرب المسبح بلا مرافق، أو تجاوز حدود السلامة	alert-circle	#3b82f6	t	2026-07-05 06:54:33.699591+00	2026-07-05 06:54:33.699591+00	\N	pool_safety	vlm	{"interval_min": 5}	t	hotel
28edf54b-3924-4632-b1c0-71615572062b	Unattended Luggage	حقيبة/غرض متروك	\N	رصد حقيبة أو غرض متروك في اللوبي/الممرات (أمن)	alert-circle	#3b82f6	t	2026-07-05 06:54:33.699591+00	2026-07-05 06:54:33.699591+00	\N	luggage_unattended	vlm	{"interval_min": 10}	t	hotel
a0dc5996-6306-455c-b512-d055171a74db	Perimeter Intrusion	اقتحام محيط/مناطق الموظفين	\N	دخول غير مصرّح لمناطق الموظفين، أرصفة التحميل، الأسطح	alert-circle	#3b82f6	t	2026-07-05 06:54:33.699591+00	2026-07-05 06:54:33.699591+00	\N	perimeter_intrusion	rule	{"cooldown_s": 120, "coordinates": ""}	t	hotel
6032e361-7b7d-4063-8a32-b71af7f851b2	Vape Detection	كشف الفيب/الأبخرة	\N	كشف الفيب في دورات المياه (عبر مستشعرات بخار — لا كاميرات)	alert-circle	#3b82f6	t	2026-07-05 06:54:33.699591+00	2026-07-05 06:54:33.699591+00	\N	vape_detection	edge_model	{"model": "veedon-vape-v1"}	f	education
10b5a03a-0314-42ad-a821-7be55f3cc60b	Emergency Lockdown	تفعيل الإغلاق الطارئ	\N	ربط كشف السلاح ببروتوكول إغلاق فوري + تنبيه أولوية	alert-circle	#3b82f6	t	2026-07-05 06:54:33.699591+00	2026-07-05 06:54:33.699591+00	\N	emergency_lockdown	rule	{"cooldown_s": 0, "trigger_on": ["weapon_detection"]}	t	education
5a63915c-0b24-43e7-b552-f47f026fa0ea	Unauthorized Visitor	زائر غير مصرّح	\N	بالغ غير معروف في مناطق الطلاب خلال الدوام	alert-circle	#3b82f6	t	2026-07-05 06:54:33.699591+00	2026-07-05 06:54:33.699591+00	\N	visitor_unknown	vlm	{"interval_min": 5}	t	education
4324c003-b950-48aa-87c2-21250781bfeb	Wrong-way / Tailgating	اتجاه معاكس/تسلل	\N	دخول باتجاه معاكس عند البوابات أو تسلل خلف مصرّح	alert-circle	#3b82f6	t	2026-07-05 06:54:33.699591+00	2026-07-05 06:54:33.699591+00	\N	wrong_direction	rule	{"cooldown_s": 60, "coordinates": ""}	t	education
0f4548e8-0c39-45cf-85fb-c945e5ee0769	Defect Inspection	فحص جودة المنتج (عيوب)	\N	كشف الخدوش/الشقوق/الانحرافات على خط الإنتاج (دقة 95%+)	alert-circle	#3b82f6	t	2026-07-05 06:54:33.699591+00	2026-07-05 06:54:33.699591+00	\N	defect_inspection	edge_model	{"model": "veedon-defect-v1"}	f	factory
5cee6218-e8e9-4f8e-b2c7-94d1e0228dc6	Spill / Leak	انسكاب/تسرب	\N	كشف الانسكابات والتسربات على أرضية المصنع	alert-circle	#3b82f6	t	2026-07-05 06:54:33.699591+00	2026-07-05 06:54:33.699591+00	\N	spill_leak	vlm	{"interval_min": 10}	t	factory
c52b7ae8-305f-4438-86b4-f96030ae4192	Thermal / Fire	حرارة/دخان/حريق	\N	كشف الدخان أو مؤشرات الحرارة الزائدة مبكراً	alert-circle	#3b82f6	t	2026-07-05 06:54:33.699591+00	2026-07-05 06:54:33.699591+00	\N	thermal_fire	vlm	{"interval_min": 3}	t	factory
50efd7af-de0b-4a8c-aa6e-4b778fbbead2	Machine Idle	توقف خط الإنتاج	\N	رصد توقف آلة/خط إنتاج غير مخطط (إنتاجية)	alert-circle	#3b82f6	t	2026-07-05 06:54:33.699591+00	2026-07-05 06:54:33.699591+00	\N	machine_idle	rule	{"coordinates": "", "interval_min": 10}	t	factory
638c6809-5f07-4ada-acf9-c0cf3024729f	Crowd Density / Stampede Risk	كثافة الحشود / خطر التدافع	\N	رصد الكثافة الحرجة والتدافع في الساحات وقاعات الصلاة (حماية الأرواح)	alert-circle	#3b82f6	t	2026-07-05 07:10:03.80636+00	2026-07-05 07:10:03.80636+00	\N	crowd_density	rule	{"camera": "", "threshold": 30, "cooldown_s": 30, "coordinates": ""}	t	mosque
11aabcd4-ddfe-4e5c-8b73-421dea3eb6e6	Crowd Flow	اتجاه وتدفق الحشود	\N	تحليل تدفق الحشود لكشف الاختناقات والاتجاه المعاكس	alert-circle	#3b82f6	t	2026-07-05 07:10:03.80636+00	2026-07-05 07:10:03.80636+00	\N	crowd_flow	rule	{"camera": "", "coordinates": "", "interval_min": 2}	t	mosque
00a480a4-97db-405e-bc6e-53cabd543b55	Fallen Person in Crowd	شخص ساقط وسط الزحام	\N	كشف شخص ساقط بين الحشود قبل التدافع فوقه	alert-circle	#3b82f6	t	2026-07-05 07:10:03.80636+00	2026-07-05 07:10:03.80636+00	\N	fallen_person	edge_model	{"model": "veedon-fall-crowd-v1"}	f	mosque
c560de41-83ca-495d-8b06-aef5ec83c6d2	Lost Child	طفل تائه	\N	رصد طفل بمفرده يبدو تائهاً في الساحات	alert-circle	#3b82f6	t	2026-07-05 07:10:03.80636+00	2026-07-05 07:10:03.80636+00	\N	lost_child	vlm	{"interval_min": 5}	t	mosque
e70e0abd-7f34-40db-b0ed-2ab9141371da	Prayer Hall Occupancy	إشغال قاعة الصلاة	\N	قياس إشغال القاعة لإدارة الطاقة الاستيعابية والتكييف	alert-circle	#3b82f6	t	2026-07-05 07:10:03.80636+00	2026-07-05 07:10:03.80636+00	\N	prayer_occupancy	rule	{"camera": "", "coordinates": "", "interval_min": 5}	t	mosque
d3fd3478-238a-49b2-9602-f47f5f0b6ccb	Loading Dock Activity	نشاط رصيف التحميل	\N	مراقبة نشاط أرصفة التحميل والتفريغ وكشف التأخير	alert-circle	#3b82f6	t	2026-07-05 07:10:03.80636+00	2026-07-05 07:10:03.80636+00	\N	loading_dock	rule	{"camera": "", "coordinates": "", "interval_min": 10}	t	warehouse
1266f7ac-a924-41ae-b088-b7b36effdd8b	Package Damage	تلف الطرود	\N	كشف الطرود التالفة أثناء المناولة	alert-circle	#3b82f6	t	2026-07-05 07:10:03.80636+00	2026-07-05 07:10:03.80636+00	\N	package_damage	vlm	{"interval_min": 10}	t	warehouse
7f1430ed-6ffb-4670-a24f-e5bf58896f91	Suspended Load Zone	المشي تحت حمل معلّق	\N	تنبيه دخول عامل منطقة تحت حمل معلّق (سلامة)	alert-circle	#3b82f6	t	2026-07-05 07:10:03.80636+00	2026-07-05 07:10:03.80636+00	\N	suspended_load	rule	{"cooldown_s": 60, "coordinates": ""}	t	warehouse
299e59d9-523e-43a8-a101-3257f6bae35e	Pallet Count	عدّ المنصات (Pallets)	\N	عدّ المنصات وتتبّع المخزون بصرياً	alert-circle	#3b82f6	t	2026-07-05 07:10:03.80636+00	2026-07-05 07:10:03.80636+00	\N	pallet_count	vlm	{"interval_min": 30}	t	warehouse
1a641673-c958-4145-aabd-671984a0fe25	Shelf Out-of-stock	رفوف فارغة / نفاد	\N	كشف الرفوف الفارغة أو قرب النفاد لإعادة التعبئة	alert-circle	#3b82f6	t	2026-07-05 07:10:03.80636+00	2026-07-05 07:10:03.80636+00	\N	shelf_out_of_stock	vlm	{"interval_min": 30}	t	retail
ba0515bf-75ee-4302-a303-b4d81d44fe5d	Planogram Compliance	التزام ترتيب العرض	\N	مطابقة ترتيب المنتجات على الرفوف للمخطط المعتمد	alert-circle	#3b82f6	t	2026-07-05 07:10:03.80636+00	2026-07-05 07:10:03.80636+00	\N	planogram_compliance	vlm	{"interval_min": 60}	t	retail
3f030a5c-bbc0-465f-a055-23e7bd1ab761	Concealment / Theft	إخفاء منتج / اشتباه سرقة	\N	كشف إخفاء منتج في الملابس/الحقيبة (مؤشر سرقة)	alert-circle	#3b82f6	t	2026-07-05 07:10:03.80636+00	2026-07-05 07:10:03.80636+00	\N	concealment_theft	edge_model	{"model": "veedon-conceal-v1"}	f	retail
bd91e0d3-de28-44c6-bbb6-99c6e01be915	Self-checkout Fraud	احتيال الدفع الذاتي	\N	ربط الفيديو بنظام الكاشير: مسح ناقص، تبديل باركود (POS)	alert-circle	#3b82f6	t	2026-07-05 07:10:03.80636+00	2026-07-05 07:10:03.80636+00	\N	self_checkout_fraud	rule	{"camera": "", "cooldown_s": 60, "pos_integration": true}	t	retail
5e6e9445-8922-4e7f-abc0-4274b0cd1bb0	Dead Bird Detection	كشف الطيور النافقة	\N	رصد الطيور النافقة تلقائياً لخفض النفوق ومنع العدوى	alert-circle	#3b82f6	t	2026-07-05 07:10:03.80636+00	2026-07-05 07:10:03.80636+00	\N	dead_bird_detection	edge_model	{"model": "veedon-deadbird-v1"}	f	farm
28161a33-2c35-421e-bc86-052f4139195e	Bird Count	عدّ الطيور	\N	عدّ الطيور بصرياً لمتابعة المخزون والنفوق	alert-circle	#3b82f6	t	2026-07-05 07:10:03.80636+00	2026-07-05 07:10:03.80636+00	\N	bird_count	vlm	{"interval_min": 60}	t	farm
ba7bc0aa-3a94-4493-ac09-d9e1a6d35cc7	Uneven Growth	نمو غير متجانس	\N	كشف تفاوت أحجام الطيور (مؤشر مرض أو تغذية)	alert-circle	#3b82f6	t	2026-07-05 07:10:03.80636+00	2026-07-05 07:10:03.80636+00	\N	uneven_growth	vlm	{"interval_min": 120}	t	farm
efaeb068-56f5-4673-866f-6e7e9eff8ad1	Patient Wait Time	زمن انتظار المرضى	\N	قياس أزمنة الانتظار في الطوارئ والاستقبال	alert-circle	#3b82f6	t	2026-07-05 07:10:03.80636+00	2026-07-05 07:10:03.80636+00	\N	patient_wait_time	rule	{"camera": "", "coordinates": "", "interval_min": 10}	t	health
ab9c747d-1188-4f58-8622-5529d8d597e9	Bed/Area Occupancy	إشغال الأسرّة/المناطق	\N	متابعة إشغال الأسرّة ومناطق العناية	alert-circle	#3b82f6	t	2026-07-05 07:10:03.80636+00	2026-07-05 07:10:03.80636+00	\N	bed_occupancy	rule	{"camera": "", "coordinates": "", "interval_min": 15}	t	health
5dbaf222-38e2-4d50-8841-c559613f8348	Unattended Child	طفل بلا مرافق	\N	رصد طفل بمفرده دون مرافق بالغ في منطقة اللعب	alert-circle	#3b82f6	t	2026-07-05 07:14:22.866724+00	2026-07-05 07:14:22.866724+00	\N	child_unattended	vlm	{"interval_min": 3}	t	kids
c6a90f37-4182-4acb-a332-bb2c076d3cf6	Child Fall	سقوط طفل	\N	كشف سقوط أو إصابة طفل في الألعاب (ترامبولين/زحاليق)	alert-circle	#3b82f6	t	2026-07-05 07:14:22.866724+00	2026-07-05 07:14:22.866724+00	\N	child_fall	edge_model	{"model": "veedon-childfall-v1"}	f	kids
b5c78d0e-e698-4549-948e-4c32dd2ceba7	Child Elopement	خروج طفل من المنطقة	\N	تنبيه عند خروج طفل من المنطقة المخصصة/الآمنة	alert-circle	#3b82f6	t	2026-07-05 07:14:22.866724+00	2026-07-05 07:14:22.866724+00	\N	child_elopement	rule	{"cooldown_s": 30, "coordinates": ""}	t	kids
6886d57c-7099-4379-b04a-7b787f2733b0	Play Area Capacity	تكدس منطقة اللعب	\N	تجاوز الطاقة الاستيعابية الآمنة لمنطقة اللعب	alert-circle	#3b82f6	t	2026-07-05 07:14:22.866724+00	2026-07-05 07:14:22.866724+00	\N	play_area_capacity	rule	{"camera": "", "threshold": 15, "cooldown_s": 120, "coordinates": ""}	t	kids
be9bb564-05c2-4135-8c1c-9eeb7abd5fb6	Rough / Unsafe Play	لعب عنيف / خطِر	\N	كشف السلوك العنيف أو الخطِر بين الأطفال	alert-circle	#3b82f6	t	2026-07-05 07:14:22.866724+00	2026-07-05 07:14:22.866724+00	\N	rough_play	vlm	{"interval_min": 2}	t	kids
9467732a-4777-413b-af1d-88c95f3a3f27	Flare / Smoke	شعلة/دخان/ألعاب نارية	\N	كشف الشعلات والدخان والألعاب النارية في المدرجات	alert-circle	#3b82f6	t	2026-07-05 07:14:22.866724+00	2026-07-05 07:14:22.866724+00	\N	flare_smoke	vlm	{"interval_min": 1}	t	sports
b1c4e044-8d3a-46a4-b4c8-7b48c16b8c81	Fan Violence	عنف الجماهير	\N	كشف الشجار والعنف بين الجماهير مبكراً	alert-circle	#3b82f6	t	2026-07-05 07:14:22.866724+00	2026-07-05 07:14:22.866724+00	\N	fan_violence	vlm	{"interval_min": 1}	t	sports
8260a67a-116c-4c8f-9d52-5b98b5ea0ebf	Masked Person	شخص ملثّم	\N	رصد الملثّمين (مرتبط بالمشاغبين والشعلات)	alert-circle	#3b82f6	t	2026-07-05 07:14:22.866724+00	2026-07-05 07:14:22.866724+00	\N	masked_person	edge_model	{"model": "veedon-mask-v1"}	f	sports
2d8c37e6-ad69-4b56-a3c4-bf207d642abb	Stand Occupancy / Crush	إشغال المدرجات / كثافة حرجة	\N	قياس الإشغال وكشف الكثافة الحرجة قبل التدافع في المدرجات	alert-circle	#3b82f6	t	2026-07-05 07:14:22.866724+00	2026-07-05 07:14:22.866724+00	\N	stand_occupancy	rule	{"camera": "", "threshold": 40, "cooldown_s": 30, "coordinates": ""}	t	sports
f8de9628-8295-4085-b226-724a1c282315	Pitch Invasion	اقتحام أرض الملعب	\N	كشف نزول جمهور إلى أرض الملعب	alert-circle	#3b82f6	t	2026-07-05 07:18:37.048188+00	2026-07-05 07:18:37.048188+00	\N	pitch_invasion	rule	{"camera": "", "cooldown_s": 30, "coordinates": ""}	t	sports
\.


--
-- Data for Name: events; Type: TABLE DATA; Schema: public; Owner: postgres
--

COPY public.events (id, camera_id, event_type, severity, metadata, snapshot_url, detected_at, reviewed, attributes, face_id, license_plate, zones, sub_label, top_score, start_time, end_time, has_clip, has_snapshot, frigate_id) FROM stdin;
3070d0d3-0de5-49ae-b9b6-3750736f71e6	e2491873-0570-4d58-9c54-c9acabd8a86b	restricted_zone	high	{"score": 0.75390625, "source": "veedon-edge", "branch_id": "0ab2ca49-ad88-4630-afb6-3ef008e1cef5", "feature_key": "restricted_zone", "engine_event": "1783232830.704921-jl8t38"}	http://localhost:8600/snapshots/3070d0d3-0de5-49ae-b9b6-3750736f71e6.jpg	2026-07-05 06:27:18.205318+00	f	{}	\N	\N	\N	\N	\N	\N	\N	f	f	\N
5bd76ec5-9309-420a-ad98-6aed31872e29	e2491873-0570-4d58-9c54-c9acabd8a86b	restricted_zone	high	{"score": 0.8046875, "source": "veedon-edge", "branch_id": "0ab2ca49-ad88-4630-afb6-3ef008e1cef5", "feature_key": "restricted_zone", "engine_event": "1783209510.602633-u0v2cm"}	http://localhost:8600/snapshots/5bd76ec5-9309-420a-ad98-6aed31872e29.jpg	2026-07-04 23:58:36.203311+00	f	{}	\N	\N	\N	\N	\N	\N	\N	f	f	\N
b7215bd9-f633-44c1-8de7-8079284f26c4	e2491873-0570-4d58-9c54-c9acabd8a86b	restricted_zone	high	{"score": 0.83203125, "source": "veedon-edge", "branch_id": "0ab2ca49-ad88-4630-afb6-3ef008e1cef5", "feature_key": "restricted_zone", "engine_event": "1783209564.60037-y3zayg"}	http://localhost:8600/snapshots/b7215bd9-f633-44c1-8de7-8079284f26c4.jpg	2026-07-04 23:59:30.603093+00	f	{}	\N	\N	\N	\N	\N	\N	\N	f	f	\N
9806d1df-b6c2-4918-b0b2-058b478c45bb	e2491873-0570-4d58-9c54-c9acabd8a86b	restricted_zone	high	{"score": 0.84375, "source": "veedon-edge", "branch_id": "0ab2ca49-ad88-4630-afb6-3ef008e1cef5", "feature_key": "restricted_zone", "engine_event": "1783209636.182568-4i20hs"}	http://localhost:8600/snapshots/9806d1df-b6c2-4918-b0b2-058b478c45bb.jpg	2026-07-05 00:00:37.212017+00	f	{}	\N	\N	\N	\N	\N	\N	\N	f	f	\N
d0a3d245-af55-441b-acf0-fe20bd300b18	e2491873-0570-4d58-9c54-c9acabd8a86b	restricted_zone	high	{"score": 0.83203125, "source": "veedon-edge", "branch_id": "0ab2ca49-ad88-4630-afb6-3ef008e1cef5", "feature_key": "restricted_zone", "engine_event": "1783209672.347136-m2y3h9"}	http://localhost:8600/snapshots/d0a3d245-af55-441b-acf0-fe20bd300b18.jpg	2026-07-05 00:01:13.46039+00	f	{}	\N	\N	\N	\N	\N	\N	\N	f	f	\N
f8f15d9d-bbca-4a59-8c93-18e9ae3b1320	e2491873-0570-4d58-9c54-c9acabd8a86b	restricted_zone	high	{"score": 0.84375, "source": "veedon-edge", "branch_id": "0ab2ca49-ad88-4630-afb6-3ef008e1cef5", "feature_key": "restricted_zone", "engine_event": "1783209726.345081-jmo8vi"}	http://localhost:8600/snapshots/f8f15d9d-bbca-4a59-8c93-18e9ae3b1320.jpg	2026-07-05 00:02:08.001345+00	f	{}	\N	\N	\N	\N	\N	\N	\N	f	f	\N
3f982556-3eda-4a58-a083-7cf5b9e166d1	e2491873-0570-4d58-9c54-c9acabd8a86b	crowding	high	{"count": 5, "score": 5.0, "source": "veedon-edge", "branch_id": "0ab2ca49-ad88-4630-afb6-3ef008e1cef5", "feature_key": "crowding"}	http://localhost:8600/snapshots/3f982556-3eda-4a58-a083-7cf5b9e166d1.jpg	2026-07-05 06:27:18.241405+00	f	{}	\N	\N	\N	\N	\N	\N	\N	f	f	\N
2c047fd0-5ed0-41ab-b4fc-ee4d974a05d2	e2491873-0570-4d58-9c54-c9acabd8a86b	restricted_zone	high	{"score": 0.8046875, "source": "veedon-edge", "branch_id": "0ab2ca49-ad88-4630-afb6-3ef008e1cef5", "feature_key": "restricted_zone", "engine_event": "1783209780.175631-jsz7x5"}	http://localhost:8600/snapshots/2c047fd0-5ed0-41ab-b4fc-ee4d974a05d2.jpg	2026-07-05 00:03:02.579023+00	f	{}	\N	\N	\N	\N	\N	\N	\N	f	f	\N
336acb3b-1fef-4cdf-84aa-73954086bf72	e2491873-0570-4d58-9c54-c9acabd8a86b	restricted_zone	high	{"score": 0.84375, "source": "veedon-edge", "branch_id": "0ab2ca49-ad88-4630-afb6-3ef008e1cef5", "feature_key": "restricted_zone", "engine_event": "1783209834.173808-pm5yr1"}	http://localhost:8600/snapshots/336acb3b-1fef-4cdf-84aa-73954086bf72.jpg	2026-07-05 00:03:57.00611+00	f	{}	\N	\N	\N	\N	\N	\N	\N	f	f	\N
6589bba7-56b8-435a-90f2-ab3cb35da77e	e2491873-0570-4d58-9c54-c9acabd8a86b	restricted_zone	high	{"score": 0.84375, "source": "veedon-edge", "branch_id": "0ab2ca49-ad88-4630-afb6-3ef008e1cef5", "feature_key": "restricted_zone", "engine_event": "1783209887.922242-ezcn9j"}	http://localhost:8600/snapshots/6589bba7-56b8-435a-90f2-ab3cb35da77e.jpg	2026-07-05 00:04:51.482309+00	f	{}	\N	\N	\N	\N	\N	\N	\N	f	f	\N
9eb8e539-217f-4cb0-b47f-faf2020ac24c	e2491873-0570-4d58-9c54-c9acabd8a86b	restricted_zone	high	{"score": 0.796875, "source": "veedon-edge", "branch_id": "0ab2ca49-ad88-4630-afb6-3ef008e1cef5", "feature_key": "restricted_zone", "engine_event": "1783232891.422097-1de74v"}	http://localhost:8600/snapshots/9eb8e539-217f-4cb0-b47f-faf2020ac24c.jpg	2026-07-05 06:28:55.008342+00	f	{}	\N	\N	\N	\N	\N	\N	\N	f	f	\N
e8b496fc-e0e7-4c76-8e7e-ee32d9b1e13e	e2491873-0570-4d58-9c54-c9acabd8a86b	restricted_zone	high	{"score": 0.8046875, "source": "veedon-edge", "branch_id": "0ab2ca49-ad88-4630-afb6-3ef008e1cef5", "feature_key": "restricted_zone", "engine_event": "1783209941.920488-lafzjz"}	http://localhost:8600/snapshots/e8b496fc-e0e7-4c76-8e7e-ee32d9b1e13e.jpg	2026-07-05 00:05:45.936405+00	f	{}	\N	\N	\N	\N	\N	\N	\N	f	f	\N
8333e944-e7a9-47ff-8e14-f282446cd826	e2491873-0570-4d58-9c54-c9acabd8a86b	restricted_zone	high	{"score": 0.84375, "source": "veedon-edge", "branch_id": "0ab2ca49-ad88-4630-afb6-3ef008e1cef5", "feature_key": "restricted_zone", "engine_event": "1783209995.917491-071av6"}	http://localhost:8600/snapshots/8333e944-e7a9-47ff-8e14-f282446cd826.jpg	2026-07-05 00:06:40.45153+00	f	{}	\N	\N	\N	\N	\N	\N	\N	f	f	\N
dca9ac84-e1bc-4a94-82ee-7fe407a0a1dd	e2491873-0570-4d58-9c54-c9acabd8a86b	restricted_zone	high	{"score": 0.8046875, "source": "veedon-edge", "branch_id": "0ab2ca49-ad88-4630-afb6-3ef008e1cef5", "feature_key": "restricted_zone", "engine_event": "1783210049.748484-fpmqqx"}	http://localhost:8600/snapshots/dca9ac84-e1bc-4a94-82ee-7fe407a0a1dd.jpg	2026-07-05 00:07:34.872776+00	f	{}	\N	\N	\N	\N	\N	\N	\N	f	f	\N
801201a1-8017-47d4-9682-66007036c58d	e2491873-0570-4d58-9c54-c9acabd8a86b	restricted_zone	high	{"score": 0.84375, "source": "veedon-edge", "branch_id": "0ab2ca49-ad88-4630-afb6-3ef008e1cef5", "feature_key": "restricted_zone", "engine_event": "1783210103.746731-rtw5xe"}	http://localhost:8600/snapshots/801201a1-8017-47d4-9682-66007036c58d.jpg	2026-07-05 00:08:29.368452+00	f	{}	\N	\N	\N	\N	\N	\N	\N	f	f	\N
ba1652de-4f90-4dc4-ac9a-285609f71b38	e2491873-0570-4d58-9c54-c9acabd8a86b	restricted_zone	high	{"score": 0.8046875, "source": "veedon-edge", "branch_id": "0ab2ca49-ad88-4630-afb6-3ef008e1cef5", "feature_key": "restricted_zone", "engine_event": "1783210157.57841-a5fpa2"}	http://localhost:8600/snapshots/ba1652de-4f90-4dc4-ac9a-285609f71b38.jpg	2026-07-05 00:09:23.883441+00	f	{}	\N	\N	\N	\N	\N	\N	\N	f	f	\N
a947b9a2-4658-45e3-b79e-6146376d6d09	e2491873-0570-4d58-9c54-c9acabd8a86b	restricted_zone	high	{"score": 0.84375, "source": "veedon-edge", "branch_id": "0ab2ca49-ad88-4630-afb6-3ef008e1cef5", "feature_key": "restricted_zone", "engine_event": "1783210229.159168-sp9qnn"}	http://localhost:8600/snapshots/a947b9a2-4658-45e3-b79e-6146376d6d09.jpg	2026-07-05 00:10:30.46297+00	f	{}	\N	\N	\N	\N	\N	\N	\N	f	f	\N
20ef9de4-00a6-4148-b506-f4aea26fd22a	e2491873-0570-4d58-9c54-c9acabd8a86b	restricted_zone	high	{"score": 0.84375, "source": "veedon-edge", "branch_id": "0ab2ca49-ad88-4630-afb6-3ef008e1cef5", "feature_key": "restricted_zone", "engine_event": "1783210265.574427-9aerzn"}	http://localhost:8600/snapshots/20ef9de4-00a6-4148-b506-f4aea26fd22a.jpg	2026-07-05 00:11:06.783143+00	f	{}	\N	\N	\N	\N	\N	\N	\N	f	f	\N
47bf88f4-1b16-444a-8cee-a04c8a7d5fa6	e2491873-0570-4d58-9c54-c9acabd8a86b	restricted_zone	high	{"score": 0.8046875, "source": "veedon-edge", "branch_id": "0ab2ca49-ad88-4630-afb6-3ef008e1cef5", "feature_key": "restricted_zone", "engine_event": "1783210319.319931-lk0nne"}	http://localhost:8600/snapshots/47bf88f4-1b16-444a-8cee-a04c8a7d5fa6.jpg	2026-07-05 00:12:01.216098+00	f	{}	\N	\N	\N	\N	\N	\N	\N	f	f	\N
12b8e601-c52c-448a-ade2-86f26dcff601	e2491873-0570-4d58-9c54-c9acabd8a86b	table_cleanliness	info	{"score": 0.0, "source": "veedon-edge", "ai_note": "تحليل AI غير مفعّل (ANTHROPIC_API_KEY غير موجود)", "branch_id": "0ab2ca49-ad88-4630-afb6-3ef008e1cef5", "feature_key": "table_cleanliness"}	http://localhost:8600/snapshots/12b8e601-c52c-448a-ade2-86f26dcff601.jpg	2026-07-05 00:12:51.643552+00	t	{}	\N	\N	\N	\N	\N	\N	\N	f	f	\N
f537f8a8-9678-4fa0-8b2d-77e1c921b57d	e2491873-0570-4d58-9c54-c9acabd8a86b	restricted_zone	high	{"score": 0.84375, "source": "veedon-edge", "branch_id": "0ab2ca49-ad88-4630-afb6-3ef008e1cef5", "feature_key": "restricted_zone", "engine_event": "1783210373.317408-4q4gns"}	http://localhost:8600/snapshots/f537f8a8-9678-4fa0-8b2d-77e1c921b57d.jpg	2026-07-05 00:12:55.698282+00	f	{}	\N	\N	\N	\N	\N	\N	\N	f	f	\N
2499e01a-d76a-47b3-83d9-234a48d0e36d	e2491873-0570-4d58-9c54-c9acabd8a86b	restricted_zone	high	{"score": 0.84375, "source": "veedon-edge", "branch_id": "0ab2ca49-ad88-4630-afb6-3ef008e1cef5", "feature_key": "restricted_zone", "engine_event": "1783233061.174616-neyo9v"}	http://localhost:8600/snapshots/2499e01a-d76a-47b3-83d9-234a48d0e36d.jpg	2026-07-05 06:31:08.022089+00	f	{}	\N	\N	\N	\N	\N	\N	\N	f	f	\N
01ad170e-96fd-42a8-9684-0c58c8487ad9	e2491873-0570-4d58-9c54-c9acabd8a86b	restricted_zone	high	{"score": 0.8046875, "source": "veedon-edge", "branch_id": "0ab2ca49-ad88-4630-afb6-3ef008e1cef5", "feature_key": "restricted_zone", "engine_event": "1783210427.148848-zzjll8"}	http://localhost:8600/snapshots/01ad170e-96fd-42a8-9684-0c58c8487ad9.jpg	2026-07-05 00:13:50.143575+00	f	{}	\N	\N	\N	\N	\N	\N	\N	f	f	\N
ba317616-f5ae-45d7-adca-0d83a41166d1	e2491873-0570-4d58-9c54-c9acabd8a86b	restricted_zone	high	{"score": 0.84375, "source": "veedon-edge", "branch_id": "0ab2ca49-ad88-4630-afb6-3ef008e1cef5", "feature_key": "restricted_zone", "engine_event": "1783210481.147037-8ijram"}	http://localhost:8600/snapshots/ba317616-f5ae-45d7-adca-0d83a41166d1.jpg	2026-07-05 00:14:44.594365+00	f	{}	\N	\N	\N	\N	\N	\N	\N	f	f	\N
70dc1578-0c99-44f1-922f-92aecd2ee475	e2491873-0570-4d58-9c54-c9acabd8a86b	restricted_zone	high	{"score": 0.84375, "source": "veedon-edge", "branch_id": "0ab2ca49-ad88-4630-afb6-3ef008e1cef5", "feature_key": "restricted_zone", "engine_event": "1783210534.893028-6xw0m9"}	http://localhost:8600/snapshots/70dc1578-0c99-44f1-922f-92aecd2ee475.jpg	2026-07-05 00:15:38.968932+00	f	{}	\N	\N	\N	\N	\N	\N	\N	f	f	\N
0fb42684-4cf5-42a0-8f56-71154cc76279	e2491873-0570-4d58-9c54-c9acabd8a86b	restricted_zone	high	{"score": 0.8046875, "source": "veedon-edge", "branch_id": "0ab2ca49-ad88-4630-afb6-3ef008e1cef5", "feature_key": "restricted_zone", "engine_event": "1783210588.890603-5arrln"}	http://localhost:8600/snapshots/0fb42684-4cf5-42a0-8f56-71154cc76279.jpg	2026-07-05 00:16:33.446482+00	f	{}	\N	\N	\N	\N	\N	\N	\N	f	f	\N
b51353f5-7301-4500-8457-f4278a7f65f8	e2491873-0570-4d58-9c54-c9acabd8a86b	restricted_zone	high	{"score": 0.84375, "source": "veedon-edge", "branch_id": "0ab2ca49-ad88-4630-afb6-3ef008e1cef5", "feature_key": "restricted_zone", "engine_event": "1783210642.886964-v8os5z"}	http://localhost:8600/snapshots/b51353f5-7301-4500-8457-f4278a7f65f8.jpg	2026-07-05 00:17:27.906001+00	f	{}	\N	\N	\N	\N	\N	\N	\N	f	f	\N
ac01a986-d0e8-43df-a45b-3ceb2201c077	e2491873-0570-4d58-9c54-c9acabd8a86b	restricted_zone	high	{"score": 0.8046875, "source": "veedon-edge", "branch_id": "0ab2ca49-ad88-4630-afb6-3ef008e1cef5", "feature_key": "restricted_zone", "engine_event": "1783210696.718905-msc8m2"}	http://localhost:8600/snapshots/ac01a986-d0e8-43df-a45b-3ceb2201c077.jpg	2026-07-05 00:18:22.344491+00	f	{}	\N	\N	\N	\N	\N	\N	\N	f	f	\N
4374c9f0-807f-452e-a180-b5b3c65879a8	e2491873-0570-4d58-9c54-c9acabd8a86b	restricted_zone	high	{"score": 0.84375, "source": "veedon-edge", "branch_id": "0ab2ca49-ad88-4630-afb6-3ef008e1cef5", "feature_key": "restricted_zone", "engine_event": "1783210750.714788-3wkh77"}	http://localhost:8600/snapshots/4374c9f0-807f-452e-a180-b5b3c65879a8.jpg	2026-07-05 00:19:16.746658+00	f	{}	\N	\N	\N	\N	\N	\N	\N	f	f	\N
50a10f38-e631-4dae-a12a-9648d9ca53af	e2491873-0570-4d58-9c54-c9acabd8a86b	restricted_zone	high	{"score": 0.84375, "source": "veedon-edge", "branch_id": "0ab2ca49-ad88-4630-afb6-3ef008e1cef5", "feature_key": "restricted_zone", "engine_event": "1783210821.878817-sgdz50"}	http://localhost:8600/snapshots/50a10f38-e631-4dae-a12a-9648d9ca53af.jpg	2026-07-05 00:20:23.352236+00	f	{}	\N	\N	\N	\N	\N	\N	\N	f	f	\N
7b51b7fc-5e99-4ae5-a170-a268fea8abfd	e2491873-0570-4d58-9c54-c9acabd8a86b	restricted_zone	high	{"score": 0.83203125, "source": "veedon-edge", "branch_id": "0ab2ca49-ad88-4630-afb6-3ef008e1cef5", "feature_key": "restricted_zone", "engine_event": "1783210858.543037-3d0fi2"}	http://localhost:8600/snapshots/7b51b7fc-5e99-4ae5-a170-a268fea8abfd.jpg	2026-07-05 00:20:59.640248+00	f	{}	\N	\N	\N	\N	\N	\N	\N	f	f	\N
5c4fcba2-a7a3-489e-a138-49195b308d32	e2491873-0570-4d58-9c54-c9acabd8a86b	restricted_zone	high	{"score": 0.84375, "source": "veedon-edge", "branch_id": "0ab2ca49-ad88-4630-afb6-3ef008e1cef5", "feature_key": "restricted_zone", "engine_event": "1783210912.540278-qt1ybx"}	http://localhost:8600/snapshots/5c4fcba2-a7a3-489e-a138-49195b308d32.jpg	2026-07-05 00:21:54.088395+00	f	{}	\N	\N	\N	\N	\N	\N	\N	f	f	\N
5b1d50ab-710c-4a92-a10d-987f8453d42a	e2491873-0570-4d58-9c54-c9acabd8a86b	restricted_zone	high	{"score": 0.8046875, "source": "veedon-edge", "branch_id": "0ab2ca49-ad88-4630-afb6-3ef008e1cef5", "feature_key": "restricted_zone", "engine_event": "1783210966.287956-t7twiz"}	http://localhost:8600/snapshots/5b1d50ab-710c-4a92-a10d-987f8453d42a.jpg	2026-07-05 00:22:48.54061+00	f	{}	\N	\N	\N	\N	\N	\N	\N	f	f	\N
434e7ddf-933f-4460-86bc-f932d85726c9	e2491873-0570-4d58-9c54-c9acabd8a86b	restricted_zone	high	{"score": 0.84375, "source": "veedon-edge", "branch_id": "0ab2ca49-ad88-4630-afb6-3ef008e1cef5", "feature_key": "restricted_zone", "engine_event": "1783211020.2844-hmpgiw"}	http://localhost:8600/snapshots/434e7ddf-933f-4460-86bc-f932d85726c9.jpg	2026-07-05 00:23:42.925275+00	f	{}	\N	\N	\N	\N	\N	\N	\N	f	f	\N
0b5b20aa-d835-4509-99bc-eaaca448f6f9	e2491873-0570-4d58-9c54-c9acabd8a86b	restricted_zone	high	{"score": 0.8046875, "source": "veedon-edge", "branch_id": "0ab2ca49-ad88-4630-afb6-3ef008e1cef5", "feature_key": "restricted_zone", "engine_event": "1783211074.115512-swpias"}	http://localhost:8600/snapshots/0b5b20aa-d835-4509-99bc-eaaca448f6f9.jpg	2026-07-05 00:24:37.466271+00	f	{}	\N	\N	\N	\N	\N	\N	\N	f	f	\N
12189c25-68b4-41d3-8dc3-e048cc3869cd	e2491873-0570-4d58-9c54-c9acabd8a86b	restricted_zone	high	{"score": 0.84375, "source": "veedon-edge", "branch_id": "0ab2ca49-ad88-4630-afb6-3ef008e1cef5", "feature_key": "restricted_zone", "engine_event": "1783211128.200912-9ovfui"}	http://localhost:8600/snapshots/12189c25-68b4-41d3-8dc3-e048cc3869cd.jpg	2026-07-05 00:25:31.986847+00	f	{}	\N	\N	\N	\N	\N	\N	\N	f	f	\N
8789fdea-909f-4fe7-b260-5ae639de6f67	e2491873-0570-4d58-9c54-c9acabd8a86b	restricted_zone	high	{"score": 0.84375, "source": "veedon-edge", "branch_id": "0ab2ca49-ad88-4630-afb6-3ef008e1cef5", "feature_key": "restricted_zone", "engine_event": "1783211181.859021-5p2j19"}	http://localhost:8600/snapshots/8789fdea-909f-4fe7-b260-5ae639de6f67.jpg	2026-07-05 00:26:26.40188+00	f	{}	\N	\N	\N	\N	\N	\N	\N	f	f	\N
669ccd79-d8bd-41f6-91c8-233bdf055953	e2491873-0570-4d58-9c54-c9acabd8a86b	restricted_zone	high	{"score": 0.8046875, "source": "veedon-edge", "branch_id": "0ab2ca49-ad88-4630-afb6-3ef008e1cef5", "feature_key": "restricted_zone", "engine_event": "1783211235.857989-e3tf9r"}	http://localhost:8600/snapshots/669ccd79-d8bd-41f6-91c8-233bdf055953.jpg	2026-07-05 00:27:20.831871+00	f	{}	\N	\N	\N	\N	\N	\N	\N	f	f	\N
a112f3ff-db8f-4c2f-8c0b-ae695350f0b2	e2491873-0570-4d58-9c54-c9acabd8a86b	restricted_zone	high	{"score": 0.84375, "source": "veedon-edge", "branch_id": "0ab2ca49-ad88-4630-afb6-3ef008e1cef5", "feature_key": "restricted_zone", "engine_event": "1783211290.104562-xba0on"}	http://localhost:8600/snapshots/a112f3ff-db8f-4c2f-8c0b-ae695350f0b2.jpg	2026-07-05 00:28:15.44516+00	f	{}	\N	\N	\N	\N	\N	\N	\N	f	f	\N
810e1891-fde1-4ddc-9269-26fca5d6115a	e2491873-0570-4d58-9c54-c9acabd8a86b	restricted_zone	high	{"score": 0.8046875, "source": "veedon-edge", "branch_id": "0ab2ca49-ad88-4630-afb6-3ef008e1cef5", "feature_key": "restricted_zone", "engine_event": "1783211343.684867-v1jnbp"}	http://localhost:8600/snapshots/810e1891-fde1-4ddc-9269-26fca5d6115a.jpg	2026-07-05 00:29:09.832581+00	f	{}	\N	\N	\N	\N	\N	\N	\N	f	f	\N
2e55acd5-bcee-49fc-acab-dd26cbc747a0	e2491873-0570-4d58-9c54-c9acabd8a86b	restricted_zone	high	{"score": 0.84375, "source": "veedon-edge", "branch_id": "0ab2ca49-ad88-4630-afb6-3ef008e1cef5", "feature_key": "restricted_zone", "engine_event": "1783211415.265357-64g0th"}	http://localhost:8600/snapshots/2e55acd5-bcee-49fc-acab-dd26cbc747a0.jpg	2026-07-05 00:30:16.410308+00	f	{}	\N	\N	\N	\N	\N	\N	\N	f	f	\N
41a49300-fd24-4ba9-98d3-8acd912aa15f	e2491873-0570-4d58-9c54-c9acabd8a86b	table_cleanliness	info	{"score": 0.0, "source": "veedon-edge", "ai_note": "تحليل AI غير مفعّل (ANTHROPIC_API_KEY غير موجود)", "branch_id": "0ab2ca49-ad88-4630-afb6-3ef008e1cef5", "feature_key": "table_cleanliness"}	http://localhost:8600/snapshots/41a49300-fd24-4ba9-98d3-8acd912aa15f.jpg	2026-07-05 01:19:04.151499+00	t	{}	\N	\N	\N	\N	\N	\N	\N	f	f	\N
638ae0c0-7048-4fb8-9458-a7c9b0f3ab66	e2491873-0570-4d58-9c54-c9acabd8a86b	crowding	high	{"score": 7.0, "source": "veedon-edge", "branch_id": "0ab2ca49-ad88-4630-afb6-3ef008e1cef5", "feature_key": "crowding"}	http://localhost:8600/snapshots/638ae0c0-7048-4fb8-9458-a7c9b0f3ab66.jpg	2026-07-04 13:05:46.852761+00	f	{}	\N	\N	\N	\N	\N	\N	\N	f	f	\N
32fb32a5-d033-4b33-9f60-0f08930aced3	e2491873-0570-4d58-9c54-c9acabd8a86b	table_cleanliness	info	{"score": 0.0, "source": "veedon-edge", "ai_note": "تحليل AI غير مفعّل (ANTHROPIC_API_KEY غير موجود)", "branch_id": "0ab2ca49-ad88-4630-afb6-3ef008e1cef5", "feature_key": "table_cleanliness"}	http://localhost:8600/snapshots/32fb32a5-d033-4b33-9f60-0f08930aced3.jpg	2026-07-04 13:05:47.170161+00	t	{}	\N	\N	\N	\N	\N	\N	\N	f	f	\N
85e41300-08f4-4b66-a55f-cf35bdfd7b62	e2491873-0570-4d58-9c54-c9acabd8a86b	table_cleanliness	info	{"score": 0.0, "source": "veedon-edge", "ai_note": "تحليل AI غير مفعّل (ANTHROPIC_API_KEY غير موجود)", "branch_id": "0ab2ca49-ad88-4630-afb6-3ef008e1cef5", "feature_key": "table_cleanliness"}	http://localhost:8600/snapshots/85e41300-08f4-4b66-a55f-cf35bdfd7b62.jpg	2026-07-05 02:19:04.263561+00	t	{}	\N	\N	\N	\N	\N	\N	\N	f	f	\N
c5fd7410-4d72-4af7-a59b-18e2c5a1c3cf	e2491873-0570-4d58-9c54-c9acabd8a86b	table_cleanliness	info	{"score": 0.0, "source": "veedon-edge", "ai_note": "تحليل AI غير مفعّل (ANTHROPIC_API_KEY غير موجود)", "branch_id": "0ab2ca49-ad88-4630-afb6-3ef008e1cef5", "feature_key": "table_cleanliness"}	http://localhost:8600/snapshots/c5fd7410-4d72-4af7-a59b-18e2c5a1c3cf.jpg	2026-07-05 03:19:33.1333+00	t	{}	\N	\N	\N	\N	\N	\N	\N	f	f	\N
05416574-8376-45e6-a39e-d41877082708	e2491873-0570-4d58-9c54-c9acabd8a86b	restricted_zone	high	{"score": 0.82421875, "source": "veedon-edge", "branch_id": "0ab2ca49-ad88-4630-afb6-3ef008e1cef5", "feature_key": "restricted_zone", "engine_event": "1783230765.247697-c9slue"}	http://localhost:8600/snapshots/05416574-8376-45e6-a39e-d41877082708.jpg	2026-07-05 05:52:55.48703+00	f	{}	\N	\N	\N	\N	\N	\N	\N	f	f	\N
67c78818-189a-4433-86c2-ede90e7f2abf	e2491873-0570-4d58-9c54-c9acabd8a86b	restricted_zone	high	{"score": 0.8046875, "source": "veedon-edge", "branch_id": "0ab2ca49-ad88-4630-afb6-3ef008e1cef5", "feature_key": "restricted_zone", "engine_event": "1783230836.380229-tv9b07"}	http://localhost:8600/snapshots/67c78818-189a-4433-86c2-ede90e7f2abf.jpg	2026-07-05 05:54:02.068003+00	f	{}	\N	\N	\N	\N	\N	\N	\N	f	f	\N
faf8fae7-172e-4ebf-adef-08b0e6613655	e2491873-0570-4d58-9c54-c9acabd8a86b	restricted_zone	high	{"score": 0.7265625, "source": "veedon-edge", "branch_id": "0ab2ca49-ad88-4630-afb6-3ef008e1cef5", "feature_key": "restricted_zone", "engine_event": "1783230914.892457-juzv05"}	http://localhost:8600/snapshots/faf8fae7-172e-4ebf-adef-08b0e6613655.jpg	2026-07-05 05:55:20.66937+00	f	{}	\N	\N	\N	\N	\N	\N	\N	f	f	\N
189a91db-be7b-483e-802d-835629f3c790	e2491873-0570-4d58-9c54-c9acabd8a86b	restricted_zone	high	{"score": 0.734375, "source": "veedon-edge", "branch_id": "0ab2ca49-ad88-4630-afb6-3ef008e1cef5", "feature_key": "restricted_zone", "engine_event": "1783230951.469168-x3jc0s"}	http://localhost:8600/snapshots/189a91db-be7b-483e-802d-835629f3c790.jpg	2026-07-05 05:55:56.917038+00	f	{}	\N	\N	\N	\N	\N	\N	\N	f	f	\N
a9ed11c5-a91f-411f-8bf4-a849b79585e4	e2491873-0570-4d58-9c54-c9acabd8a86b	restricted_zone	high	{"score": 0.76171875, "source": "veedon-edge", "branch_id": "0ab2ca49-ad88-4630-afb6-3ef008e1cef5", "feature_key": "restricted_zone", "engine_event": "1783231121.797938-pgqk69"}	http://localhost:8600/snapshots/a9ed11c5-a91f-411f-8bf4-a849b79585e4.jpg	2026-07-05 05:58:46.300513+00	f	{}	\N	\N	\N	\N	\N	\N	\N	f	f	\N
2d121828-a74a-4e4e-8c6e-0af6eb292c89	e2491873-0570-4d58-9c54-c9acabd8a86b	restricted_zone	high	{"score": 0.78125, "source": "veedon-edge", "branch_id": "0ab2ca49-ad88-4630-afb6-3ef008e1cef5", "feature_key": "restricted_zone", "engine_event": "1783231314.516511-xogjo9"}	http://localhost:8600/snapshots/2d121828-a74a-4e4e-8c6e-0af6eb292c89.jpg	2026-07-05 06:01:59.858287+00	f	{}	\N	\N	\N	\N	\N	\N	\N	f	f	\N
78649c6e-85d3-44f6-9018-9eff6af823e3	e2491873-0570-4d58-9c54-c9acabd8a86b	restricted_zone	high	{"score": 0.84375, "source": "veedon-edge", "branch_id": "0ab2ca49-ad88-4630-afb6-3ef008e1cef5", "feature_key": "restricted_zone", "engine_event": "1783231475.395726-6u8lh8"}	http://localhost:8600/snapshots/78649c6e-85d3-44f6-9018-9eff6af823e3.jpg	2026-07-05 06:04:43.196135+00	f	{}	\N	\N	\N	\N	\N	\N	\N	f	f	\N
bef6b0c9-9a25-4ee5-a6e6-3816e13bb0bf	e2491873-0570-4d58-9c54-c9acabd8a86b	crowding	high	{"count": 5, "score": 5.0, "source": "veedon-edge", "branch_id": "0ab2ca49-ad88-4630-afb6-3ef008e1cef5", "feature_key": "crowding"}	http://localhost:8600/snapshots/bef6b0c9-9a25-4ee5-a6e6-3816e13bb0bf.jpg	2026-07-05 06:04:59.459505+00	f	{}	\N	\N	\N	\N	\N	\N	\N	f	f	\N
7ea50015-be94-42b8-ab01-2d913dc9eda0	e2491873-0570-4d58-9c54-c9acabd8a86b	restricted_zone	high	{"score": 0.84375, "source": "veedon-edge", "branch_id": "0ab2ca49-ad88-4630-afb6-3ef008e1cef5", "feature_key": "restricted_zone", "engine_event": "1783231539.418516-69dius"}	http://localhost:8600/snapshots/7ea50015-be94-42b8-ab01-2d913dc9eda0.jpg	2026-07-05 06:05:43.845906+00	f	{}	\N	\N	\N	\N	\N	\N	\N	f	f	\N
0050c4b1-8aa5-4969-8494-ca17dcce35a0	e2491873-0570-4d58-9c54-c9acabd8a86b	restricted_zone	high	{"score": 0.7265625, "source": "veedon-edge", "branch_id": "0ab2ca49-ad88-4630-afb6-3ef008e1cef5", "feature_key": "restricted_zone", "engine_event": "1783231601.400437-rs6rqj"}	http://localhost:8600/snapshots/0050c4b1-8aa5-4969-8494-ca17dcce35a0.jpg	2026-07-05 06:06:56.516033+00	f	{}	\N	\N	\N	\N	\N	\N	\N	f	f	\N
b4cd5af0-4e08-4144-a957-b5fb0f1fd35e	e2491873-0570-4d58-9c54-c9acabd8a86b	restricted_zone	high	{"score": 0.734375, "source": "veedon-edge", "branch_id": "0ab2ca49-ad88-4630-afb6-3ef008e1cef5", "feature_key": "restricted_zone", "engine_event": "1783231660.215616-tkp5ci"}	http://localhost:8600/snapshots/b4cd5af0-4e08-4144-a957-b5fb0f1fd35e.jpg	2026-07-05 06:08:03.062798+00	f	{}	\N	\N	\N	\N	\N	\N	\N	f	f	\N
a02fc502-f44e-4b49-9413-b3fd626a26e0	e2491873-0570-4d58-9c54-c9acabd8a86b	restricted_zone	high	{"score": 0.7890625, "source": "veedon-edge", "branch_id": "0ab2ca49-ad88-4630-afb6-3ef008e1cef5", "feature_key": "restricted_zone", "engine_event": "1783231720.673589-1088xd"}	http://localhost:8600/snapshots/a02fc502-f44e-4b49-9413-b3fd626a26e0.jpg	2026-07-05 06:08:45.431844+00	f	{}	\N	\N	\N	\N	\N	\N	\N	f	f	\N
3ccf2171-98dd-48f1-a627-411a19c47abd	e2491873-0570-4d58-9c54-c9acabd8a86b	restricted_zone	high	{"score": 0.78125, "source": "veedon-edge", "branch_id": "0ab2ca49-ad88-4630-afb6-3ef008e1cef5", "feature_key": "restricted_zone", "engine_event": "1783231731.069419-rne4b8"}	http://localhost:8600/snapshots/3ccf2171-98dd-48f1-a627-411a19c47abd.jpg	2026-07-05 06:09:09.691765+00	f	{}	\N	\N	\N	\N	\N	\N	\N	f	f	\N
0f26cf17-f52b-4869-b1cb-750157c1bc06	e2491873-0570-4d58-9c54-c9acabd8a86b	restricted_zone	high	{"score": 0.76953125, "source": "veedon-edge", "branch_id": "0ab2ca49-ad88-4630-afb6-3ef008e1cef5", "feature_key": "restricted_zone", "engine_event": "1783231885.22818-lvy8gq"}	http://localhost:8600/snapshots/0f26cf17-f52b-4869-b1cb-750157c1bc06.jpg	2026-07-05 06:11:53.149359+00	f	{}	\N	\N	\N	\N	\N	\N	\N	f	f	\N
2b1fcd37-82d1-4387-a891-e32c3b85a2a0	e2491873-0570-4d58-9c54-c9acabd8a86b	restricted_zone	high	{"score": 0.8203125, "source": "veedon-edge", "branch_id": "0ab2ca49-ad88-4630-afb6-3ef008e1cef5", "feature_key": "restricted_zone", "engine_event": "1783231948.226225-eldjj5"}	http://localhost:8600/snapshots/2b1fcd37-82d1-4387-a891-e32c3b85a2a0.jpg	2026-07-05 06:12:35.527983+00	f	{}	\N	\N	\N	\N	\N	\N	\N	f	f	\N
6ea348ba-8c14-4e04-9e45-3cbe3e1d6e35	e2491873-0570-4d58-9c54-c9acabd8a86b	restricted_zone	high	{"score": 0.734375, "source": "veedon-edge", "branch_id": "0ab2ca49-ad88-4630-afb6-3ef008e1cef5", "feature_key": "restricted_zone", "engine_event": "1783232662.474057-dptaeh"}	http://localhost:8600/snapshots/6ea348ba-8c14-4e04-9e45-3cbe3e1d6e35.jpg	2026-07-05 06:24:28.666153+00	f	{}	\N	\N	\N	\N	\N	\N	\N	f	f	\N
7a970c65-4702-4e3a-9c26-345bca896379	e2491873-0570-4d58-9c54-c9acabd8a86b	restricted_zone	high	{"score": 0.6953125, "source": "veedon-edge", "branch_id": "0ab2ca49-ad88-4630-afb6-3ef008e1cef5", "feature_key": "restricted_zone", "engine_event": "1783232703.201239-ai6tfa"}	http://localhost:8600/snapshots/7a970c65-4702-4e3a-9c26-345bca896379.jpg	2026-07-05 06:25:10.921754+00	f	{}	\N	\N	\N	\N	\N	\N	\N	f	f	\N
2b579adf-2e1a-4db1-aecd-74d51392acf4	e2491873-0570-4d58-9c54-c9acabd8a86b	restricted_zone	high	{"score": 0.75390625, "source": "veedon-edge", "branch_id": "0ab2ca49-ad88-4630-afb6-3ef008e1cef5", "feature_key": "restricted_zone", "engine_event": "1783205543.91255-fke0ki"}	http://localhost:8600/snapshots/2b579adf-2e1a-4db1-aecd-74d51392acf4.jpg	2026-07-04 22:52:28.851297+00	f	{}	\N	\N	\N	\N	\N	\N	\N	f	f	\N
7bde9161-0841-4003-b139-6ffe7f183e2b	e2491873-0570-4d58-9c54-c9acabd8a86b	restricted_zone	high	{"score": 0.8046875, "source": "veedon-edge", "branch_id": "0ab2ca49-ad88-4630-afb6-3ef008e1cef5", "feature_key": "restricted_zone", "engine_event": "1783205580.494367-b8o5ki"}	http://localhost:8600/snapshots/7bde9161-0841-4003-b139-6ffe7f183e2b.jpg	2026-07-04 22:53:05.023856+00	f	{}	\N	\N	\N	\N	\N	\N	\N	f	f	\N
a4a09c3b-1895-4736-9ca9-4086055f8bbc	e2491873-0570-4d58-9c54-c9acabd8a86b	restricted_zone	high	{"score": 0.84375, "source": "veedon-edge", "branch_id": "0ab2ca49-ad88-4630-afb6-3ef008e1cef5", "feature_key": "restricted_zone", "engine_event": "1783205634.492541-lcufax"}	http://localhost:8600/snapshots/a4a09c3b-1895-4736-9ca9-4086055f8bbc.jpg	2026-07-04 22:53:59.291947+00	f	{}	\N	\N	\N	\N	\N	\N	\N	f	f	\N
12f0e931-ef57-40d7-947f-ea05122914bc	e2491873-0570-4d58-9c54-c9acabd8a86b	restricted_zone	high	{"score": 0.8046875, "source": "veedon-edge", "branch_id": "0ab2ca49-ad88-4630-afb6-3ef008e1cef5", "feature_key": "restricted_zone", "engine_event": "1783205688.323326-fhqhrw"}	http://localhost:8600/snapshots/12f0e931-ef57-40d7-947f-ea05122914bc.jpg	2026-07-04 22:54:53.553213+00	f	{}	\N	\N	\N	\N	\N	\N	\N	f	f	\N
3b1d65c0-147d-4e4d-a2e3-bb63217054d2	e2491873-0570-4d58-9c54-c9acabd8a86b	restricted_zone	high	{"score": 0.84375, "source": "veedon-edge", "branch_id": "0ab2ca49-ad88-4630-afb6-3ef008e1cef5", "feature_key": "restricted_zone", "engine_event": "1783205742.322386-173ilr"}	http://localhost:8600/snapshots/3b1d65c0-147d-4e4d-a2e3-bb63217054d2.jpg	2026-07-04 22:55:47.813651+00	f	{}	\N	\N	\N	\N	\N	\N	\N	f	f	\N
ff99fbae-49e7-4035-b3a9-d1460e0875ef	e2491873-0570-4d58-9c54-c9acabd8a86b	restricted_zone	high	{"score": 0.84375, "source": "veedon-edge", "branch_id": "0ab2ca49-ad88-4630-afb6-3ef008e1cef5", "feature_key": "restricted_zone", "engine_event": "1783205796.06811-ajneiz"}	http://localhost:8600/snapshots/ff99fbae-49e7-4035-b3a9-d1460e0875ef.jpg	2026-07-04 22:56:42.070277+00	f	{}	\N	\N	\N	\N	\N	\N	\N	f	f	\N
d71899cd-95f3-4580-b841-fc7782c6900b	e2491873-0570-4d58-9c54-c9acabd8a86b	restricted_zone	high	{"score": 0.8046875, "source": "veedon-edge", "branch_id": "0ab2ca49-ad88-4630-afb6-3ef008e1cef5", "feature_key": "restricted_zone", "engine_event": "1783205850.065856-2vt2hm"}	http://localhost:8600/snapshots/d71899cd-95f3-4580-b841-fc7782c6900b.jpg	2026-07-04 22:57:36.319489+00	f	{}	\N	\N	\N	\N	\N	\N	\N	f	f	\N
ce974066-d062-431f-9ec0-131aa5208f8d	e2491873-0570-4d58-9c54-c9acabd8a86b	restricted_zone	high	{"score": 0.84375, "source": "veedon-edge", "branch_id": "0ab2ca49-ad88-4630-afb6-3ef008e1cef5", "feature_key": "restricted_zone", "engine_event": "1783205904.063411-hsxpwi"}	http://localhost:8600/snapshots/ce974066-d062-431f-9ec0-131aa5208f8d.jpg	2026-07-04 22:58:30.575367+00	f	{}	\N	\N	\N	\N	\N	\N	\N	f	f	\N
03fda4c1-3076-4dcf-baae-d5c280090c09	e2491873-0570-4d58-9c54-c9acabd8a86b	restricted_zone	high	{"score": 0.84375, "source": "veedon-edge", "branch_id": "0ab2ca49-ad88-4630-afb6-3ef008e1cef5", "feature_key": "restricted_zone", "engine_event": "1783205975.310755-1pm0du"}	http://localhost:8600/snapshots/03fda4c1-3076-4dcf-baae-d5c280090c09.jpg	2026-07-04 22:59:36.895171+00	f	{}	\N	\N	\N	\N	\N	\N	\N	f	f	\N
ac4b72f3-4910-4e54-b012-eded6bf3f310	e2491873-0570-4d58-9c54-c9acabd8a86b	restricted_zone	high	{"score": 0.84375, "source": "veedon-edge", "branch_id": "0ab2ca49-ad88-4630-afb6-3ef008e1cef5", "feature_key": "restricted_zone", "engine_event": "1783206011.892803-xe4kf6"}	http://localhost:8600/snapshots/ac4b72f3-4910-4e54-b012-eded6bf3f310.jpg	2026-07-04 23:00:13.077831+00	f	{}	\N	\N	\N	\N	\N	\N	\N	f	f	\N
95c8f8d6-83ee-45a9-83f6-c8609c1b5a6b	e2491873-0570-4d58-9c54-c9acabd8a86b	restricted_zone	high	{"score": 0.8046875, "source": "veedon-edge", "branch_id": "0ab2ca49-ad88-4630-afb6-3ef008e1cef5", "feature_key": "restricted_zone", "engine_event": "1783206065.72338-z08n4g"}	http://localhost:8600/snapshots/95c8f8d6-83ee-45a9-83f6-c8609c1b5a6b.jpg	2026-07-04 23:01:07.32537+00	f	{}	\N	\N	\N	\N	\N	\N	\N	f	f	\N
e4d69b82-f77f-48a8-8bea-73ab103a30de	e2491873-0570-4d58-9c54-c9acabd8a86b	restricted_zone	high	{"score": 0.83203125, "source": "veedon-edge", "branch_id": "0ab2ca49-ad88-4630-afb6-3ef008e1cef5", "feature_key": "restricted_zone", "engine_event": "1783206119.720692-mhtmya"}	http://localhost:8600/snapshots/e4d69b82-f77f-48a8-8bea-73ab103a30de.jpg	2026-07-04 23:02:01.585996+00	f	{}	\N	\N	\N	\N	\N	\N	\N	f	f	\N
d5c38b24-cea1-47a4-8ded-6f504251a2f0	e2491873-0570-4d58-9c54-c9acabd8a86b	restricted_zone	high	{"score": 0.84375, "source": "veedon-edge", "branch_id": "0ab2ca49-ad88-4630-afb6-3ef008e1cef5", "feature_key": "restricted_zone", "engine_event": "1783206173.718637-2xxf9w"}	http://localhost:8600/snapshots/d5c38b24-cea1-47a4-8ded-6f504251a2f0.jpg	2026-07-04 23:02:55.882101+00	f	{}	\N	\N	\N	\N	\N	\N	\N	f	f	\N
f043f1e0-668e-493e-8e4a-d18d1c20fb34	e2491873-0570-4d58-9c54-c9acabd8a86b	restricted_zone	high	{"score": 0.8046875, "source": "veedon-edge", "branch_id": "0ab2ca49-ad88-4630-afb6-3ef008e1cef5", "feature_key": "restricted_zone", "engine_event": "1783206227.466742-ynb3or"}	http://localhost:8600/snapshots/f043f1e0-668e-493e-8e4a-d18d1c20fb34.jpg	2026-07-04 23:03:50.141811+00	f	{}	\N	\N	\N	\N	\N	\N	\N	f	f	\N
d36d5b16-1df5-4ef6-90a1-0c2ee8aca273	e2491873-0570-4d58-9c54-c9acabd8a86b	restricted_zone	high	{"score": 0.84375, "source": "veedon-edge", "branch_id": "0ab2ca49-ad88-4630-afb6-3ef008e1cef5", "feature_key": "restricted_zone", "engine_event": "1783206281.463835-g9yag7"}	http://localhost:8600/snapshots/d36d5b16-1df5-4ef6-90a1-0c2ee8aca273.jpg	2026-07-04 23:04:44.470839+00	f	{}	\N	\N	\N	\N	\N	\N	\N	f	f	\N
bbd05e3e-3d3c-4d1d-8861-6876a378d1e7	e2491873-0570-4d58-9c54-c9acabd8a86b	restricted_zone	high	{"score": 0.8046875, "source": "veedon-edge", "branch_id": "0ab2ca49-ad88-4630-afb6-3ef008e1cef5", "feature_key": "restricted_zone", "engine_event": "1783206335.294295-5qo402"}	http://localhost:8600/snapshots/bbd05e3e-3d3c-4d1d-8861-6876a378d1e7.jpg	2026-07-04 23:05:38.731958+00	f	{}	\N	\N	\N	\N	\N	\N	\N	f	f	\N
a1511a36-0382-4fca-9039-a87c3375cba2	e2491873-0570-4d58-9c54-c9acabd8a86b	restricted_zone	high	{"score": 0.84375, "source": "veedon-edge", "branch_id": "0ab2ca49-ad88-4630-afb6-3ef008e1cef5", "feature_key": "restricted_zone", "engine_event": "1783206389.292761-1ciqgo"}	http://localhost:8600/snapshots/a1511a36-0382-4fca-9039-a87c3375cba2.jpg	2026-07-04 23:06:33.010703+00	f	{}	\N	\N	\N	\N	\N	\N	\N	f	f	\N
462f2e2e-b3cd-48e0-b547-ac6b9876fa0b	e2491873-0570-4d58-9c54-c9acabd8a86b	restricted_zone	high	{"score": 0.84375, "source": "veedon-edge", "branch_id": "0ab2ca49-ad88-4630-afb6-3ef008e1cef5", "feature_key": "restricted_zone", "engine_event": "1783206443.039491-svcgsc"}	http://localhost:8600/snapshots/462f2e2e-b3cd-48e0-b547-ac6b9876fa0b.jpg	2026-07-04 23:07:27.325247+00	f	{}	\N	\N	\N	\N	\N	\N	\N	f	f	\N
d2f9311e-d6f8-4081-9cfa-1dcffeff2919	e2491873-0570-4d58-9c54-c9acabd8a86b	restricted_zone	high	{"score": 0.8046875, "source": "veedon-edge", "branch_id": "0ab2ca49-ad88-4630-afb6-3ef008e1cef5", "feature_key": "restricted_zone", "engine_event": "1783206497.038366-2a6iad"}	http://localhost:8600/snapshots/d2f9311e-d6f8-4081-9cfa-1dcffeff2919.jpg	2026-07-04 23:08:21.598328+00	f	{}	\N	\N	\N	\N	\N	\N	\N	f	f	\N
427935d4-1bd2-4ddd-9cde-aadbba12f737	e2491873-0570-4d58-9c54-c9acabd8a86b	restricted_zone	high	{"score": 0.84375, "source": "veedon-edge", "branch_id": "0ab2ca49-ad88-4630-afb6-3ef008e1cef5", "feature_key": "restricted_zone", "engine_event": "1783206551.035562-jzan27"}	http://localhost:8600/snapshots/427935d4-1bd2-4ddd-9cde-aadbba12f737.jpg	2026-07-04 23:09:15.833331+00	f	{}	\N	\N	\N	\N	\N	\N	\N	f	f	\N
8324f519-edcf-46ce-b454-c46a69a39a43	e2491873-0570-4d58-9c54-c9acabd8a86b	restricted_zone	high	{"score": 0.8046875, "source": "veedon-edge", "branch_id": "0ab2ca49-ad88-4630-afb6-3ef008e1cef5", "feature_key": "restricted_zone", "engine_event": "1783206604.86684-ngw14a"}	http://localhost:8600/snapshots/8324f519-edcf-46ce-b454-c46a69a39a43.jpg	2026-07-04 23:10:10.097051+00	f	{}	\N	\N	\N	\N	\N	\N	\N	f	f	\N
d75abb3e-c979-4f97-a986-0953e5ffeaa7	e2491873-0570-4d58-9c54-c9acabd8a86b	restricted_zone	high	{"score": 0.84375, "source": "veedon-edge", "branch_id": "0ab2ca49-ad88-4630-afb6-3ef008e1cef5", "feature_key": "restricted_zone", "engine_event": "1783206658.864657-wqd4ha"}	http://localhost:8600/snapshots/d75abb3e-c979-4f97-a986-0953e5ffeaa7.jpg	2026-07-04 23:11:04.350215+00	f	{}	\N	\N	\N	\N	\N	\N	\N	f	f	\N
565729ca-bf02-4620-9951-f886aad36274	e2491873-0570-4d58-9c54-c9acabd8a86b	restricted_zone	high	{"score": 0.8046875, "source": "veedon-edge", "branch_id": "0ab2ca49-ad88-4630-afb6-3ef008e1cef5", "feature_key": "restricted_zone", "engine_event": "1783206712.695188-evd4tr"}	http://localhost:8600/snapshots/565729ca-bf02-4620-9951-f886aad36274.jpg	2026-07-04 23:11:58.621825+00	f	{}	\N	\N	\N	\N	\N	\N	\N	f	f	\N
90fc02d6-4256-43ba-9b4b-522eed18b13c	e2491873-0570-4d58-9c54-c9acabd8a86b	restricted_zone	high	{"score": 0.75390625, "source": "veedon-edge", "branch_id": "0ab2ca49-ad88-4630-afb6-3ef008e1cef5", "feature_key": "restricted_zone", "engine_event": "1783206752.89819-80crmz"}	http://localhost:8600/snapshots/90fc02d6-4256-43ba-9b4b-522eed18b13c.jpg	2026-07-04 23:12:37.459902+00	f	{}	\N	\N	\N	\N	\N	\N	\N	f	f	\N
772699f5-8c11-4c2e-803a-8f2ead401bb9	e2491873-0570-4d58-9c54-c9acabd8a86b	restricted_zone	high	{"score": 0.75390625, "source": "veedon-edge", "branch_id": "0ab2ca49-ad88-4630-afb6-3ef008e1cef5", "feature_key": "restricted_zone", "engine_event": "1783206775.415885-ahrht3"}	http://localhost:8600/snapshots/772699f5-8c11-4c2e-803a-8f2ead401bb9.jpg	2026-07-04 23:13:00.198279+00	f	{}	\N	\N	\N	\N	\N	\N	\N	f	f	\N
960d9b81-08e1-4071-a6d2-9fabc7410fed	e2491873-0570-4d58-9c54-c9acabd8a86b	restricted_zone	high	{"score": 0.8046875, "source": "veedon-edge", "branch_id": "0ab2ca49-ad88-4630-afb6-3ef008e1cef5", "feature_key": "restricted_zone", "engine_event": "1783206811.998238-cihvoy"}	http://localhost:8600/snapshots/960d9b81-08e1-4071-a6d2-9fabc7410fed.jpg	2026-07-04 23:13:36.618917+00	f	{}	\N	\N	\N	\N	\N	\N	\N	f	f	\N
d5c8fb3f-28c0-41c9-9bab-d88e266162d4	e2491873-0570-4d58-9c54-c9acabd8a86b	restricted_zone	high	{"score": 0.84375, "source": "veedon-edge", "branch_id": "0ab2ca49-ad88-4630-afb6-3ef008e1cef5", "feature_key": "restricted_zone", "engine_event": "1783206865.995816-mt4e9g"}	http://localhost:8600/snapshots/d5c8fb3f-28c0-41c9-9bab-d88e266162d4.jpg	2026-07-04 23:14:31.147789+00	f	{}	\N	\N	\N	\N	\N	\N	\N	f	f	\N
0d64d151-7ef1-41fe-b833-50ddab4d7e10	e2491873-0570-4d58-9c54-c9acabd8a86b	restricted_zone	high	{"score": 0.8046875, "source": "veedon-edge", "branch_id": "0ab2ca49-ad88-4630-afb6-3ef008e1cef5", "feature_key": "restricted_zone", "engine_event": "1783206919.826902-ua9fe3"}	http://localhost:8600/snapshots/0d64d151-7ef1-41fe-b833-50ddab4d7e10.jpg	2026-07-04 23:15:25.686632+00	f	{}	\N	\N	\N	\N	\N	\N	\N	f	f	\N
9c89cfd7-99f4-4c1a-af32-5de655d3fbe0	e2491873-0570-4d58-9c54-c9acabd8a86b	restricted_zone	high	{"score": 0.82421875, "source": "veedon-edge", "branch_id": "0ab2ca49-ad88-4630-afb6-3ef008e1cef5", "feature_key": "restricted_zone", "engine_event": "1783233147.984474-y7iql3"}	http://localhost:8600/snapshots/9c89cfd7-99f4-4c1a-af32-5de655d3fbe0.jpg	2026-07-05 06:32:50.909895+00	f	{}	\N	\N	\N	\N	\N	\N	\N	f	f	\N
5e7f6711-690e-448d-a893-1b900716a970	e2491873-0570-4d58-9c54-c9acabd8a86b	restricted_zone	high	{"score": 0.75390625, "source": "veedon-edge", "branch_id": "0ab2ca49-ad88-4630-afb6-3ef008e1cef5", "feature_key": "restricted_zone", "engine_event": "1783206988.04369-guc8hb"}	http://localhost:8600/snapshots/5e7f6711-690e-448d-a893-1b900716a970.jpg	2026-07-04 23:16:32.659838+00	f	{}	\N	\N	\N	\N	\N	\N	\N	f	f	\N
d880300d-716e-447f-874f-6b9fef7777c3	e2491873-0570-4d58-9c54-c9acabd8a86b	restricted_zone	high	{"score": 0.8046875, "source": "veedon-edge", "branch_id": "0ab2ca49-ad88-4630-afb6-3ef008e1cef5", "feature_key": "restricted_zone", "engine_event": "1783207024.624731-ic4q1d"}	http://localhost:8600/snapshots/d880300d-716e-447f-874f-6b9fef7777c3.jpg	2026-07-04 23:17:09.096371+00	f	{}	\N	\N	\N	\N	\N	\N	\N	f	f	\N
73c5f6ac-92f6-4e6f-90dc-9ff62521bae3	e2491873-0570-4d58-9c54-c9acabd8a86b	restricted_zone	high	{"score": 0.74609375, "source": "veedon-edge", "branch_id": "0ab2ca49-ad88-4630-afb6-3ef008e1cef5", "feature_key": "restricted_zone", "engine_event": "1783233282.035664-euudck"}	http://localhost:8600/snapshots/73c5f6ac-92f6-4e6f-90dc-9ff62521bae3.jpg	2026-07-05 06:34:51.921282+00	f	{}	\N	\N	\N	\N	\N	\N	\N	f	f	\N
6dd2d064-49e8-4c9c-bcee-34c74da372b3	e2491873-0570-4d58-9c54-c9acabd8a86b	restricted_zone	high	{"score": 0.75390625, "source": "veedon-edge", "branch_id": "0ab2ca49-ad88-4630-afb6-3ef008e1cef5", "feature_key": "restricted_zone", "engine_event": "1783207047.87198-7qew7h"}	http://localhost:8600/snapshots/6dd2d064-49e8-4c9c-bcee-34c74da372b3.jpg	2026-07-04 23:17:32.744393+00	f	{}	\N	\N	\N	\N	\N	\N	\N	f	f	\N
65b25b7c-f631-41c6-a964-d57b801094fe	e2491873-0570-4d58-9c54-c9acabd8a86b	restricted_zone	high	{"score": 0.8046875, "source": "veedon-edge", "branch_id": "0ab2ca49-ad88-4630-afb6-3ef008e1cef5", "feature_key": "restricted_zone", "engine_event": "1783207084.453663-gejey3"}	http://localhost:8600/snapshots/65b25b7c-f631-41c6-a964-d57b801094fe.jpg	2026-07-04 23:18:09.089659+00	f	{}	\N	\N	\N	\N	\N	\N	\N	f	f	\N
0d33cb52-3984-4937-a49f-8ffb9be5cbb3	e2491873-0570-4d58-9c54-c9acabd8a86b	restricted_zone	high	{"score": 0.8203125, "source": "veedon-edge", "branch_id": "0ab2ca49-ad88-4630-afb6-3ef008e1cef5", "feature_key": "restricted_zone", "engine_event": "1783207153.034336-2pl3xu"}	http://localhost:8600/snapshots/0d33cb52-3984-4937-a49f-8ffb9be5cbb3.jpg	2026-07-04 23:19:15.818304+00	f	{}	\N	\N	\N	\N	\N	\N	\N	f	f	\N
c18f3957-27d5-4207-a07e-51884c78f50b	e2491873-0570-4d58-9c54-c9acabd8a86b	restricted_zone	high	{"score": 0.8046875, "source": "veedon-edge", "branch_id": "0ab2ca49-ad88-4630-afb6-3ef008e1cef5", "feature_key": "restricted_zone", "engine_event": "1783207192.282915-ntqwdj"}	http://localhost:8600/snapshots/c18f3957-27d5-4207-a07e-51884c78f50b.jpg	2026-07-04 23:19:58.322744+00	f	{}	\N	\N	\N	\N	\N	\N	\N	f	f	\N
6085dd2e-394f-4797-91bc-0e7e0ff8326b	e2491873-0570-4d58-9c54-c9acabd8a86b	restricted_zone	high	{"score": 0.84375, "source": "veedon-edge", "branch_id": "0ab2ca49-ad88-4630-afb6-3ef008e1cef5", "feature_key": "restricted_zone", "engine_event": "1783207246.281438-721go7"}	http://localhost:8600/snapshots/6085dd2e-394f-4797-91bc-0e7e0ff8326b.jpg	2026-07-04 23:20:52.692713+00	f	{}	\N	\N	\N	\N	\N	\N	\N	f	f	\N
831e87a4-5afd-47d9-b5fd-d577b021d87d	e2491873-0570-4d58-9c54-c9acabd8a86b	restricted_zone	high	{"score": 0.82421875, "source": "veedon-edge", "branch_id": "0ab2ca49-ad88-4630-afb6-3ef008e1cef5", "feature_key": "restricted_zone", "engine_event": "1783233405.881339-34j2rf"}	http://localhost:8600/snapshots/831e87a4-5afd-47d9-b5fd-d577b021d87d.jpg	2026-07-05 06:36:52.866819+00	f	{}	\N	\N	\N	\N	\N	\N	\N	f	f	\N
272906c0-ba7f-4816-aa48-18018fc5a39d	e2491873-0570-4d58-9c54-c9acabd8a86b	restricted_zone	high	{"score": 0.8125, "source": "veedon-edge", "branch_id": "0ab2ca49-ad88-4630-afb6-3ef008e1cef5", "feature_key": "restricted_zone", "engine_event": "1783233712.249782-j10r46"}	http://localhost:8600/snapshots/272906c0-ba7f-4816-aa48-18018fc5a39d.jpg	2026-07-05 06:42:19.370557+00	f	{}	\N	\N	\N	\N	\N	\N	\N	f	f	\N
6f6a1df9-a3f8-48f4-a57b-e41661de6a1e	e2491873-0570-4d58-9c54-c9acabd8a86b	restricted_zone	high	{"score": 0.796875, "source": "veedon-edge", "branch_id": "0ab2ca49-ad88-4630-afb6-3ef008e1cef5", "feature_key": "restricted_zone", "engine_event": "1783232767.675383-5dp9p7"}	http://localhost:8600/snapshots/6f6a1df9-a3f8-48f4-a57b-e41661de6a1e.jpg	2026-07-05 06:26:35.858935+00	f	{}	\N	\N	\N	\N	\N	\N	\N	f	f	\N
fb31bbc0-70a3-4e38-a566-54e403dd5011	e2491873-0570-4d58-9c54-c9acabd8a86b	restricted_zone	high	{"score": 0.76171875, "source": "veedon-edge", "branch_id": "0ab2ca49-ad88-4630-afb6-3ef008e1cef5", "feature_key": "restricted_zone", "engine_event": "1783233804.468121-pqb0eb"}	http://localhost:8600/snapshots/fb31bbc0-70a3-4e38-a566-54e403dd5011.jpg	2026-07-05 06:43:44.387761+00	f	{}	\N	\N	\N	\N	\N	\N	\N	f	f	\N
c9b16cf9-d46c-4f79-b865-9dd1e33d93ff	e2491873-0570-4d58-9c54-c9acabd8a86b	restricted_zone	high	{"score": 0.8046875, "source": "veedon-edge", "branch_id": "0ab2ca49-ad88-4630-afb6-3ef008e1cef5", "feature_key": "restricted_zone", "engine_event": "1783233848.699597-a8jqum"}	http://localhost:8600/snapshots/c9b16cf9-d46c-4f79-b865-9dd1e33d93ff.jpg	2026-07-05 06:44:14.59821+00	f	{}	\N	\N	\N	\N	\N	\N	\N	f	f	\N
1ed2a378-0322-4b07-943c-89a751f6c0c4	e2491873-0570-4d58-9c54-c9acabd8a86b	restricted_zone	high	{"score": 0.84375, "source": "veedon-edge", "branch_id": "0ab2ca49-ad88-4630-afb6-3ef008e1cef5", "feature_key": "restricted_zone", "engine_event": "1783207300.02809-3i7vd8"}	http://localhost:8600/snapshots/1ed2a378-0322-4b07-943c-89a751f6c0c4.jpg	2026-07-04 23:21:41.094571+00	f	{}	\N	\N	\N	\N	\N	\N	\N	f	f	\N
6f8df193-6dca-4aa8-95d4-ff44578eebf5	e2491873-0570-4d58-9c54-c9acabd8a86b	restricted_zone	high	{"score": 0.83203125, "source": "veedon-edge", "branch_id": "0ab2ca49-ad88-4630-afb6-3ef008e1cef5", "feature_key": "restricted_zone", "engine_event": "1783207354.025622-2y2hmf"}	http://localhost:8600/snapshots/6f8df193-6dca-4aa8-95d4-ff44578eebf5.jpg	2026-07-04 23:22:35.502084+00	f	{}	\N	\N	\N	\N	\N	\N	\N	f	f	\N
0a0eeca7-34ed-4b52-b011-5da96a8f67a9	e2491873-0570-4d58-9c54-c9acabd8a86b	restricted_zone	high	{"score": 0.84375, "source": "veedon-edge", "branch_id": "0ab2ca49-ad88-4630-afb6-3ef008e1cef5", "feature_key": "restricted_zone", "engine_event": "1783207408.023636-gc1dss"}	http://localhost:8600/snapshots/0a0eeca7-34ed-4b52-b011-5da96a8f67a9.jpg	2026-07-04 23:23:30.026469+00	f	{}	\N	\N	\N	\N	\N	\N	\N	f	f	\N
b12464ad-f01c-4529-a99e-166c14e528c2	e2491873-0570-4d58-9c54-c9acabd8a86b	restricted_zone	high	{"score": 0.8046875, "source": "veedon-edge", "branch_id": "0ab2ca49-ad88-4630-afb6-3ef008e1cef5", "feature_key": "restricted_zone", "engine_event": "1783207461.854711-gb76ir"}	http://localhost:8600/snapshots/b12464ad-f01c-4529-a99e-166c14e528c2.jpg	2026-07-04 23:24:24.492821+00	f	{}	\N	\N	\N	\N	\N	\N	\N	f	f	\N
97d78609-b951-4056-9acd-f15552b9b682	e2491873-0570-4d58-9c54-c9acabd8a86b	restricted_zone	high	{"score": 0.84375, "source": "veedon-edge", "branch_id": "0ab2ca49-ad88-4630-afb6-3ef008e1cef5", "feature_key": "restricted_zone", "engine_event": "1783207515.853142-2zwu9w"}	http://localhost:8600/snapshots/97d78609-b951-4056-9acd-f15552b9b682.jpg	2026-07-04 23:25:18.965005+00	f	{}	\N	\N	\N	\N	\N	\N	\N	f	f	\N
5364ef16-5676-43dc-a5b9-cbc17cb080fb	e2491873-0570-4d58-9c54-c9acabd8a86b	restricted_zone	high	{"score": 0.8046875, "source": "veedon-edge", "branch_id": "0ab2ca49-ad88-4630-afb6-3ef008e1cef5", "feature_key": "restricted_zone", "engine_event": "1783207569.684298-mcdfw2"}	http://localhost:8600/snapshots/5364ef16-5676-43dc-a5b9-cbc17cb080fb.jpg	2026-07-04 23:26:13.43555+00	f	{}	\N	\N	\N	\N	\N	\N	\N	f	f	\N
fb5ee03f-3c87-4bb3-9b68-5fe82f05247d	e2491873-0570-4d58-9c54-c9acabd8a86b	restricted_zone	high	{"score": 0.83203125, "source": "veedon-edge", "branch_id": "0ab2ca49-ad88-4630-afb6-3ef008e1cef5", "feature_key": "restricted_zone", "engine_event": "1783207623.684005-1qep9k"}	http://localhost:8600/snapshots/fb5ee03f-3c87-4bb3-9b68-5fe82f05247d.jpg	2026-07-04 23:27:07.891722+00	f	{}	\N	\N	\N	\N	\N	\N	\N	f	f	\N
2e3d0cc8-9f04-457f-ada3-5001fab31fad	e2491873-0570-4d58-9c54-c9acabd8a86b	restricted_zone	high	{"score": 0.84375, "source": "veedon-edge", "branch_id": "0ab2ca49-ad88-4630-afb6-3ef008e1cef5", "feature_key": "restricted_zone", "engine_event": "1783207677.679405-dhneuj"}	http://localhost:8600/snapshots/2e3d0cc8-9f04-457f-ada3-5001fab31fad.jpg	2026-07-04 23:28:02.368944+00	f	{}	\N	\N	\N	\N	\N	\N	\N	f	f	\N
1eff6e0f-6aeb-4831-9ee7-821bc368b6c1	e2491873-0570-4d58-9c54-c9acabd8a86b	restricted_zone	high	{"score": 0.8046875, "source": "veedon-edge", "branch_id": "0ab2ca49-ad88-4630-afb6-3ef008e1cef5", "feature_key": "restricted_zone", "engine_event": "1783207731.425803-aq2gze"}	http://localhost:8600/snapshots/1eff6e0f-6aeb-4831-9ee7-821bc368b6c1.jpg	2026-07-04 23:28:56.770151+00	f	{}	\N	\N	\N	\N	\N	\N	\N	f	f	\N
f5778185-77f7-4c07-818d-f8109efc51fb	e2491873-0570-4d58-9c54-c9acabd8a86b	restricted_zone	high	{"score": 0.84375, "source": "veedon-edge", "branch_id": "0ab2ca49-ad88-4630-afb6-3ef008e1cef5", "feature_key": "restricted_zone", "engine_event": "1783207785.425318-ljss7j"}	http://localhost:8600/snapshots/f5778185-77f7-4c07-818d-f8109efc51fb.jpg	2026-07-04 23:29:51.204424+00	f	{}	\N	\N	\N	\N	\N	\N	\N	f	f	\N
2d7d7798-99d2-417c-93cb-49cc42af98cf	e2491873-0570-4d58-9c54-c9acabd8a86b	restricted_zone	high	{"score": 0.8046875, "source": "veedon-edge", "branch_id": "0ab2ca49-ad88-4630-afb6-3ef008e1cef5", "feature_key": "restricted_zone", "engine_event": "1783207839.256188-r24rim"}	http://localhost:8600/snapshots/2d7d7798-99d2-417c-93cb-49cc42af98cf.jpg	2026-07-04 23:30:45.65118+00	f	{}	\N	\N	\N	\N	\N	\N	\N	f	f	\N
138603dd-b618-40e6-8587-22784cb81fb5	e2491873-0570-4d58-9c54-c9acabd8a86b	restricted_zone	high	{"score": 0.84375, "source": "veedon-edge", "branch_id": "0ab2ca49-ad88-4630-afb6-3ef008e1cef5", "feature_key": "restricted_zone", "engine_event": "1783207910.669453-zhibcp"}	http://localhost:8600/snapshots/138603dd-b618-40e6-8587-22784cb81fb5.jpg	2026-07-04 23:31:52.180205+00	f	{}	\N	\N	\N	\N	\N	\N	\N	f	f	\N
1d8414de-8769-44e4-ad84-2dfc6554d4ad	e2491873-0570-4d58-9c54-c9acabd8a86b	restricted_zone	high	{"score": 0.84375, "source": "veedon-edge", "branch_id": "0ab2ca49-ad88-4630-afb6-3ef008e1cef5", "feature_key": "restricted_zone", "engine_event": "1783207947.001887-bnubvn"}	http://localhost:8600/snapshots/1d8414de-8769-44e4-ad84-2dfc6554d4ad.jpg	2026-07-04 23:32:28.578715+00	f	{}	\N	\N	\N	\N	\N	\N	\N	f	f	\N
7044ba81-10ff-435b-91a9-f0cf9510ac44	e2491873-0570-4d58-9c54-c9acabd8a86b	restricted_zone	high	{"score": 0.8046875, "source": "veedon-edge", "branch_id": "0ab2ca49-ad88-4630-afb6-3ef008e1cef5", "feature_key": "restricted_zone", "engine_event": "1783208001.000649-thp3bf"}	http://localhost:8600/snapshots/7044ba81-10ff-435b-91a9-f0cf9510ac44.jpg	2026-07-04 23:33:23.040372+00	f	{}	\N	\N	\N	\N	\N	\N	\N	f	f	\N
1dd70f9d-6ae5-4e5d-a6c0-13fa9f4ae54d	e2491873-0570-4d58-9c54-c9acabd8a86b	restricted_zone	high	{"score": 0.84375, "source": "veedon-edge", "branch_id": "0ab2ca49-ad88-4630-afb6-3ef008e1cef5", "feature_key": "restricted_zone", "engine_event": "1783208054.996809-xqibru"}	http://localhost:8600/snapshots/1dd70f9d-6ae5-4e5d-a6c0-13fa9f4ae54d.jpg	2026-07-04 23:34:17.4471+00	f	{}	\N	\N	\N	\N	\N	\N	\N	f	f	\N
58c73adf-8f57-4b4a-ac2d-b5e5eae832ba	e2491873-0570-4d58-9c54-c9acabd8a86b	restricted_zone	high	{"score": 0.8046875, "source": "veedon-edge", "branch_id": "0ab2ca49-ad88-4630-afb6-3ef008e1cef5", "feature_key": "restricted_zone", "engine_event": "1783208108.827621-l7vg1b"}	http://localhost:8600/snapshots/58c73adf-8f57-4b4a-ac2d-b5e5eae832ba.jpg	2026-07-04 23:35:11.907008+00	f	{}	\N	\N	\N	\N	\N	\N	\N	f	f	\N
8c88a756-833f-4462-9cbd-3370c28efe68	e2491873-0570-4d58-9c54-c9acabd8a86b	restricted_zone	high	{"score": 0.84375, "source": "veedon-edge", "branch_id": "0ab2ca49-ad88-4630-afb6-3ef008e1cef5", "feature_key": "restricted_zone", "engine_event": "1783208162.825788-izmijd"}	http://localhost:8600/snapshots/8c88a756-833f-4462-9cbd-3370c28efe68.jpg	2026-07-04 23:36:06.413686+00	f	{}	\N	\N	\N	\N	\N	\N	\N	f	f	\N
1a1d65c8-418f-47c5-89e9-abe06280dfa1	e2491873-0570-4d58-9c54-c9acabd8a86b	restricted_zone	high	{"score": 0.8046875, "source": "veedon-edge", "branch_id": "0ab2ca49-ad88-4630-afb6-3ef008e1cef5", "feature_key": "restricted_zone", "engine_event": "1783208216.657711-ztz13w"}	http://localhost:8600/snapshots/1a1d65c8-418f-47c5-89e9-abe06280dfa1.jpg	2026-07-04 23:37:00.807864+00	f	{}	\N	\N	\N	\N	\N	\N	\N	f	f	\N
0f07d97f-9411-4c39-87a0-f99156793951	e2491873-0570-4d58-9c54-c9acabd8a86b	restricted_zone	high	{"score": 0.83203125, "source": "veedon-edge", "branch_id": "0ab2ca49-ad88-4630-afb6-3ef008e1cef5", "feature_key": "restricted_zone", "engine_event": "1783208270.653947-3bgylu"}	http://localhost:8600/snapshots/0f07d97f-9411-4c39-87a0-f99156793951.jpg	2026-07-04 23:37:55.27957+00	f	{}	\N	\N	\N	\N	\N	\N	\N	f	f	\N
a352530b-892f-45e9-9161-d3b2a9244bc1	e2491873-0570-4d58-9c54-c9acabd8a86b	restricted_zone	high	{"score": 0.84375, "source": "veedon-edge", "branch_id": "0ab2ca49-ad88-4630-afb6-3ef008e1cef5", "feature_key": "restricted_zone", "engine_event": "1783208324.652071-kcl2a9"}	http://localhost:8600/snapshots/a352530b-892f-45e9-9161-d3b2a9244bc1.jpg	2026-07-04 23:38:49.767473+00	f	{}	\N	\N	\N	\N	\N	\N	\N	f	f	\N
cb177c79-8d1a-4fea-bc99-8dd9fd9c0d7d	e2491873-0570-4d58-9c54-c9acabd8a86b	restricted_zone	high	{"score": 0.8046875, "source": "veedon-edge", "branch_id": "0ab2ca49-ad88-4630-afb6-3ef008e1cef5", "feature_key": "restricted_zone", "engine_event": "1783208378.400442-z2egbw"}	http://localhost:8600/snapshots/cb177c79-8d1a-4fea-bc99-8dd9fd9c0d7d.jpg	2026-07-04 23:39:44.144215+00	f	{}	\N	\N	\N	\N	\N	\N	\N	f	f	\N
6fb5fb70-1cdb-4d35-9ca1-094172e9bf62	e2491873-0570-4d58-9c54-c9acabd8a86b	restricted_zone	high	{"score": 0.84375, "source": "veedon-edge", "branch_id": "0ab2ca49-ad88-4630-afb6-3ef008e1cef5", "feature_key": "restricted_zone", "engine_event": "1783208432.398644-royskw"}	http://localhost:8600/snapshots/6fb5fb70-1cdb-4d35-9ca1-094172e9bf62.jpg	2026-07-04 23:40:38.641332+00	f	{}	\N	\N	\N	\N	\N	\N	\N	f	f	\N
e5100eb6-5cc5-42ea-9098-ff5082f75e63	e2491873-0570-4d58-9c54-c9acabd8a86b	restricted_zone	high	{"score": 0.83203125, "source": "veedon-edge", "branch_id": "0ab2ca49-ad88-4630-afb6-3ef008e1cef5", "feature_key": "restricted_zone", "engine_event": "1783208486.228731-dpfj46"}	http://localhost:8600/snapshots/e5100eb6-5cc5-42ea-9098-ff5082f75e63.jpg	2026-07-04 23:41:27.15444+00	f	{}	\N	\N	\N	\N	\N	\N	\N	f	f	\N
747e50fa-65ec-4a89-8aa4-a7ec2d2e7aa9	e2491873-0570-4d58-9c54-c9acabd8a86b	restricted_zone	high	{"score": 0.84375, "source": "veedon-edge", "branch_id": "0ab2ca49-ad88-4630-afb6-3ef008e1cef5", "feature_key": "restricted_zone", "engine_event": "1783208540.22623-x8i08w"}	http://localhost:8600/snapshots/747e50fa-65ec-4a89-8aa4-a7ec2d2e7aa9.jpg	2026-07-04 23:42:21.562408+00	f	{}	\N	\N	\N	\N	\N	\N	\N	f	f	\N
a857be7d-fb8f-4646-9f4c-be9144a2a5d8	e2491873-0570-4d58-9c54-c9acabd8a86b	restricted_zone	high	{"score": 0.84375, "source": "veedon-edge", "branch_id": "0ab2ca49-ad88-4630-afb6-3ef008e1cef5", "feature_key": "restricted_zone", "engine_event": "1783208593.974439-3mm77d"}	http://localhost:8600/snapshots/a857be7d-fb8f-4646-9f4c-be9144a2a5d8.jpg	2026-07-04 23:43:16.018082+00	f	{}	\N	\N	\N	\N	\N	\N	\N	f	f	\N
f8462fad-68e9-4ddf-83a9-6798491e08e6	e2491873-0570-4d58-9c54-c9acabd8a86b	restricted_zone	high	{"score": 0.8046875, "source": "veedon-edge", "branch_id": "0ab2ca49-ad88-4630-afb6-3ef008e1cef5", "feature_key": "restricted_zone", "engine_event": "1783208647.972116-19ti8x"}	http://localhost:8600/snapshots/f8462fad-68e9-4ddf-83a9-6798491e08e6.jpg	2026-07-04 23:44:10.491348+00	f	{}	\N	\N	\N	\N	\N	\N	\N	f	f	\N
64703895-8fd4-4f0e-b8c5-923b37acb503	e2491873-0570-4d58-9c54-c9acabd8a86b	restricted_zone	high	{"score": 0.84375, "source": "veedon-edge", "branch_id": "0ab2ca49-ad88-4630-afb6-3ef008e1cef5", "feature_key": "restricted_zone", "engine_event": "1783208701.969762-cz64kx"}	http://localhost:8600/snapshots/64703895-8fd4-4f0e-b8c5-923b37acb503.jpg	2026-07-04 23:45:04.904071+00	f	{}	\N	\N	\N	\N	\N	\N	\N	f	f	\N
22c9dc1f-ea84-406e-87f0-4b6b8405038d	e2491873-0570-4d58-9c54-c9acabd8a86b	table_cleanliness	info	{"score": 0.0, "source": "veedon-edge", "ai_note": "تحليل AI غير مفعّل (ANTHROPIC_API_KEY غير موجود)", "branch_id": "0ab2ca49-ad88-4630-afb6-3ef008e1cef5", "feature_key": "table_cleanliness"}	http://localhost:8600/snapshots/22c9dc1f-ea84-406e-87f0-4b6b8405038d.jpg	2026-07-05 04:20:02.101136+00	t	{}	\N	\N	\N	\N	\N	\N	\N	f	f	\N
541b5b52-b616-488d-b7b3-6b7b8ad809be	e2491873-0570-4d58-9c54-c9acabd8a86b	table_cleanliness	info	{"score": 0.0, "source": "veedon-edge", "ai_note": "تحليل AI غير مفعّل (ANTHROPIC_API_KEY غير موجود)", "branch_id": "0ab2ca49-ad88-4630-afb6-3ef008e1cef5", "feature_key": "table_cleanliness"}	http://localhost:8600/snapshots/541b5b52-b616-488d-b7b3-6b7b8ad809be.jpg	2026-07-05 05:20:32.288545+00	t	{}	\N	\N	\N	\N	\N	\N	\N	f	f	\N
9a9763f7-e42b-49d1-835c-e944ecaece65	e2491873-0570-4d58-9c54-c9acabd8a86b	restricted_zone	high	{"score": 0.796875, "source": "veedon-edge", "branch_id": "0ab2ca49-ad88-4630-afb6-3ef008e1cef5", "feature_key": "restricted_zone", "engine_event": "1783233961.293247-wbpx6z"}	http://localhost:8600/snapshots/9a9763f7-e42b-49d1-835c-e944ecaece65.jpg	2026-07-05 06:46:33.776603+00	f	{}	\N	\N	\N	\N	\N	\N	\N	f	f	\N
63e37a11-d4a3-4f65-9b3c-de677e3b99d0	e2491873-0570-4d58-9c54-c9acabd8a86b	phone_usage	high	{"model": "veedon-detect-v1.onnx", "score": 0.8319178819656372, "source": "veedon-edge", "branch_id": "0ab2ca49-ad88-4630-afb6-3ef008e1cef5", "detections": ["chair"], "feature_key": "phone_usage"}	http://localhost:8600/snapshots/63e37a11-d4a3-4f65-9b3c-de677e3b99d0.jpg	2026-07-05 05:51:06.687922+00	f	{}	\N	\N	\N	\N	\N	\N	\N	f	f	\N
e926731e-92d5-4e41-969d-87231af1604d	e2491873-0570-4d58-9c54-c9acabd8a86b	phone_usage	high	{"model": "veedon-detect-v1.onnx", "score": 0.8344289064407349, "source": "veedon-edge", "branch_id": "0ab2ca49-ad88-4630-afb6-3ef008e1cef5", "detections": ["chair"], "feature_key": "phone_usage"}	http://localhost:8600/snapshots/e926731e-92d5-4e41-969d-87231af1604d.jpg	2026-07-05 05:51:16.804249+00	f	{}	\N	\N	\N	\N	\N	\N	\N	f	f	\N
4fbd9ce1-927b-4215-8e1c-8c360d1e0994	e2491873-0570-4d58-9c54-c9acabd8a86b	phone_usage	high	{"model": "veedon-detect-v1.onnx", "score": 0.7994805574417114, "source": "veedon-edge", "branch_id": "0ab2ca49-ad88-4630-afb6-3ef008e1cef5", "detections": ["chair"], "feature_key": "phone_usage"}	http://localhost:8600/snapshots/4fbd9ce1-927b-4215-8e1c-8c360d1e0994.jpg	2026-07-05 05:51:26.921557+00	f	{}	\N	\N	\N	\N	\N	\N	\N	f	f	\N
c0f45dd9-fb94-4a9c-ba1f-278df138ce67	e2491873-0570-4d58-9c54-c9acabd8a86b	table_cleanliness	info	{"score": 0.0, "source": "veedon-edge", "ai_note": "تحليل AI غير مفعّل (ANTHROPIC_API_KEY غير موجود)", "branch_id": "0ab2ca49-ad88-4630-afb6-3ef008e1cef5", "feature_key": "table_cleanliness"}	http://localhost:8600/snapshots/c0f45dd9-fb94-4a9c-ba1f-278df138ce67.jpg	2026-07-05 06:47:04.010667+00	t	{}	\N	\N	\N	\N	\N	\N	\N	f	f	\N
be54176d-8111-433c-9be5-67c2b1996826	e2491873-0570-4d58-9c54-c9acabd8a86b	restricted_zone	high	{"score": 0.84375, "source": "veedon-edge", "branch_id": "0ab2ca49-ad88-4630-afb6-3ef008e1cef5", "feature_key": "restricted_zone", "engine_event": "1783234082.963893-yimysc"}	http://localhost:8600/snapshots/be54176d-8111-433c-9be5-67c2b1996826.jpg	2026-07-05 06:48:10.605387+00	f	{}	\N	\N	\N	\N	\N	\N	\N	f	f	\N
6a66c4e6-c11d-45c9-82c3-de7f6aa7b4d4	e2491873-0570-4d58-9c54-c9acabd8a86b	restricted_zone	high	{"score": 0.53515625, "source": "veedon-edge", "branch_id": "0ab2ca49-ad88-4630-afb6-3ef008e1cef5", "feature_key": "restricted_zone", "engine_event": "1783234119.263521-rmxj5e"}	http://localhost:8600/snapshots/6a66c4e6-c11d-45c9-82c3-de7f6aa7b4d4.jpg	2026-07-05 06:48:46.935171+00	f	{}	\N	\N	\N	\N	\N	\N	\N	f	f	\N
94b8265b-6098-496a-9f4c-bfee9c7adff3	e2491873-0570-4d58-9c54-c9acabd8a86b	restricted_zone	high	{"score": 0.84375, "source": "veedon-edge", "branch_id": "0ab2ca49-ad88-4630-afb6-3ef008e1cef5", "feature_key": "restricted_zone", "engine_event": "1783234162.070256-gcsyj8"}	http://localhost:8600/snapshots/94b8265b-6098-496a-9f4c-bfee9c7adff3.jpg	2026-07-05 06:49:29.303499+00	f	{}	\N	\N	\N	\N	\N	\N	\N	f	f	\N
cbc9a0af-3b6b-444d-bdce-42b89816e1f4	e2491873-0570-4d58-9c54-c9acabd8a86b	restricted_zone	high	{"score": 0.84375, "source": "veedon-edge", "branch_id": "0ab2ca49-ad88-4630-afb6-3ef008e1cef5", "feature_key": "restricted_zone", "engine_event": "1783234318.412942-mjq70c"}	http://localhost:8600/snapshots/cbc9a0af-3b6b-444d-bdce-42b89816e1f4.jpg	2026-07-05 06:52:06.515825+00	f	{}	\N	\N	\N	\N	\N	\N	\N	f	f	\N
c55e897c-b16c-446e-bd0e-b30ecf73c03b	e2491873-0570-4d58-9c54-c9acabd8a86b	restricted_zone	high	{"score": 0.7265625, "source": "veedon-edge", "branch_id": "0ab2ca49-ad88-4630-afb6-3ef008e1cef5", "feature_key": "restricted_zone", "engine_event": "1783234518.363859-xjdjbq"}	http://localhost:8600/snapshots/c55e897c-b16c-446e-bd0e-b30ecf73c03b.jpg	2026-07-05 06:55:26.172115+00	f	{}	\N	\N	\N	\N	\N	\N	\N	f	f	\N
caf72369-1b53-43de-aa63-3fa3b1de45f6	e2491873-0570-4d58-9c54-c9acabd8a86b	restricted_zone	high	{"score": 0.76171875, "source": "veedon-edge", "branch_id": "0ab2ca49-ad88-4630-afb6-3ef008e1cef5", "feature_key": "restricted_zone", "engine_event": "1783234524.880551-gxn7n1"}	http://localhost:8600/snapshots/caf72369-1b53-43de-aa63-3fa3b1de45f6.jpg	2026-07-05 06:55:56.532527+00	f	{}	\N	\N	\N	\N	\N	\N	\N	f	f	\N
43a44c5b-b8f0-473c-a604-fbb9ce0e683c	e2491873-0570-4d58-9c54-c9acabd8a86b	crowding	high	{"count": 5, "score": 5.0, "source": "veedon-edge", "branch_id": "0ab2ca49-ad88-4630-afb6-3ef008e1cef5", "feature_key": "crowding"}	http://localhost:8600/snapshots/43a44c5b-b8f0-473c-a604-fbb9ce0e683c.jpg	2026-07-05 06:56:20.739087+00	f	{}	\N	\N	\N	\N	\N	\N	\N	f	f	\N
f51867f8-b2c4-4b1d-9082-8ac48d225864	e2491873-0570-4d58-9c54-c9acabd8a86b	restricted_zone	high	{"score": 0.8046875, "source": "veedon-edge", "branch_id": "0ab2ca49-ad88-4630-afb6-3ef008e1cef5", "feature_key": "restricted_zone", "engine_event": "1783208755.799993-2py1fv"}	http://localhost:8600/snapshots/f51867f8-b2c4-4b1d-9082-8ac48d225864.jpg	2026-07-04 23:45:59.491896+00	f	{}	\N	\N	\N	\N	\N	\N	\N	f	f	\N
b5ff5b20-372c-44a3-ae00-39abe1ca674b	e2491873-0570-4d58-9c54-c9acabd8a86b	restricted_zone	high	{"score": 0.84375, "source": "veedon-edge", "branch_id": "0ab2ca49-ad88-4630-afb6-3ef008e1cef5", "feature_key": "restricted_zone", "engine_event": "1783208809.797668-hyiqka"}	http://localhost:8600/snapshots/b5ff5b20-372c-44a3-ae00-39abe1ca674b.jpg	2026-07-04 23:46:53.915649+00	f	{}	\N	\N	\N	\N	\N	\N	\N	f	f	\N
18f81628-dc93-47b8-a1c4-6c62755514cb	e2491873-0570-4d58-9c54-c9acabd8a86b	restricted_zone	high	{"score": 0.8046875, "source": "veedon-edge", "branch_id": "0ab2ca49-ad88-4630-afb6-3ef008e1cef5", "feature_key": "restricted_zone", "engine_event": "1783208863.629376-niiku5"}	http://localhost:8600/snapshots/18f81628-dc93-47b8-a1c4-6c62755514cb.jpg	2026-07-04 23:47:48.302855+00	f	{}	\N	\N	\N	\N	\N	\N	\N	f	f	\N
2d0d3928-c6f9-4df4-be4e-51d9002145bb	e2491873-0570-4d58-9c54-c9acabd8a86b	restricted_zone	high	{"score": 0.83203125, "source": "veedon-edge", "branch_id": "0ab2ca49-ad88-4630-afb6-3ef008e1cef5", "feature_key": "restricted_zone", "engine_event": "1783208917.627414-ze2j47"}	http://localhost:8600/snapshots/2d0d3928-c6f9-4df4-be4e-51d9002145bb.jpg	2026-07-04 23:48:42.738961+00	f	{}	\N	\N	\N	\N	\N	\N	\N	f	f	\N
9713bc7a-6e14-4ce0-879a-2c193dc6e1f9	e2491873-0570-4d58-9c54-c9acabd8a86b	restricted_zone	high	{"score": 0.84375, "source": "veedon-edge", "branch_id": "0ab2ca49-ad88-4630-afb6-3ef008e1cef5", "feature_key": "restricted_zone", "engine_event": "1783208971.624316-ytsgrx"}	http://localhost:8600/snapshots/9713bc7a-6e14-4ce0-879a-2c193dc6e1f9.jpg	2026-07-04 23:49:37.203005+00	f	{}	\N	\N	\N	\N	\N	\N	\N	f	f	\N
25bc6102-1980-4a3d-8f37-5420f5204c97	e2491873-0570-4d58-9c54-c9acabd8a86b	restricted_zone	high	{"score": 0.8046875, "source": "veedon-edge", "branch_id": "0ab2ca49-ad88-4630-afb6-3ef008e1cef5", "feature_key": "restricted_zone", "engine_event": "1783209025.371525-cw2dxg"}	http://localhost:8600/snapshots/25bc6102-1980-4a3d-8f37-5420f5204c97.jpg	2026-07-04 23:50:31.754138+00	f	{}	\N	\N	\N	\N	\N	\N	\N	f	f	\N
e605e4ed-581a-4811-8d5e-c0e8d41fff50	e2491873-0570-4d58-9c54-c9acabd8a86b	restricted_zone	high	{"score": 0.83984375, "source": "veedon-edge", "branch_id": "0ab2ca49-ad88-4630-afb6-3ef008e1cef5", "feature_key": "restricted_zone", "engine_event": "1783209096.786148-jkrkvg"}	http://localhost:8600/snapshots/e605e4ed-581a-4811-8d5e-c0e8d41fff50.jpg	2026-07-04 23:51:38.317786+00	f	{}	\N	\N	\N	\N	\N	\N	\N	f	f	\N
b23128ad-b018-45eb-8f9e-81abb999885c	e2491873-0570-4d58-9c54-c9acabd8a86b	restricted_zone	high	{"score": 0.83203125, "source": "veedon-edge", "branch_id": "0ab2ca49-ad88-4630-afb6-3ef008e1cef5", "feature_key": "restricted_zone", "engine_event": "1783209133.201511-jq7ytr"}	http://localhost:8600/snapshots/b23128ad-b018-45eb-8f9e-81abb999885c.jpg	2026-07-04 23:52:14.608428+00	f	{}	\N	\N	\N	\N	\N	\N	\N	f	f	\N
30b4625f-7d3a-453d-95dd-315a287027db	e2491873-0570-4d58-9c54-c9acabd8a86b	restricted_zone	high	{"score": 0.84375, "source": "veedon-edge", "branch_id": "0ab2ca49-ad88-4630-afb6-3ef008e1cef5", "feature_key": "restricted_zone", "engine_event": "1783209187.199343-4qhvck"}	http://localhost:8600/snapshots/30b4625f-7d3a-453d-95dd-315a287027db.jpg	2026-07-04 23:53:09.030156+00	f	{}	\N	\N	\N	\N	\N	\N	\N	f	f	\N
6ae4ed2f-6b1a-4e25-98e1-19c837143a3d	e2491873-0570-4d58-9c54-c9acabd8a86b	restricted_zone	high	{"score": 0.84375, "source": "veedon-edge", "branch_id": "0ab2ca49-ad88-4630-afb6-3ef008e1cef5", "feature_key": "restricted_zone", "engine_event": "1783209240.945716-hlmigc"}	http://localhost:8600/snapshots/6ae4ed2f-6b1a-4e25-98e1-19c837143a3d.jpg	2026-07-04 23:54:03.498783+00	f	{}	\N	\N	\N	\N	\N	\N	\N	f	f	\N
ec601291-0edc-470a-ae94-c270266f31a8	e2491873-0570-4d58-9c54-c9acabd8a86b	fight_detection	high	{"source": "veedon-edge", "ai_note": "تشابك بين طالبين قرب البوابة", "feature_key": "fight_detection"}	\N	2026-07-05 06:49:32.09742+00	f	{}	\N	\N	\N	\N	\N	\N	\N	f	f	\N
ae5ff0cb-aeb3-4e76-8d1b-9581e44ef274	e2491873-0570-4d58-9c54-c9acabd8a86b	student_sleeping	info	{"source": "veedon-edge", "ai_note": "طالب واضع رأسه على الطاولة", "feature_key": "student_sleeping"}	\N	2026-07-05 06:49:32.09742+00	f	{}	\N	\N	\N	\N	\N	\N	\N	f	f	\N
39c7a08e-4fd2-4cc4-9c3d-9664db67b172	e2491873-0570-4d58-9c54-c9acabd8a86b	restricted_zone	high	{"score": 0.8046875, "source": "veedon-edge", "branch_id": "0ab2ca49-ad88-4630-afb6-3ef008e1cef5", "feature_key": "restricted_zone", "engine_event": "1783234636.293847-84ownz"}	http://localhost:8600/snapshots/39c7a08e-4fd2-4cc4-9c3d-9664db67b172.jpg	2026-07-05 06:57:20.368758+00	f	{}	\N	\N	\N	\N	\N	\N	\N	f	f	\N
36a0ef48-19ef-45e3-9f5d-abe5e5ec9966	e2491873-0570-4d58-9c54-c9acabd8a86b	restricted_zone	high	{"score": 0.71484375, "source": "veedon-edge", "branch_id": "0ab2ca49-ad88-4630-afb6-3ef008e1cef5", "feature_key": "restricted_zone", "engine_event": "1783234731.192493-rd64lb"}	http://localhost:8600/snapshots/36a0ef48-19ef-45e3-9f5d-abe5e5ec9966.jpg	2026-07-05 06:58:57.168708+00	f	{}	\N	\N	\N	\N	\N	\N	\N	f	f	\N
598f5fc4-4899-4d3a-8443-f5bc923e1c2f	e2491873-0570-4d58-9c54-c9acabd8a86b	restricted_zone	high	{"score": 0.76953125, "source": "veedon-edge", "branch_id": "0ab2ca49-ad88-4630-afb6-3ef008e1cef5", "feature_key": "restricted_zone", "engine_event": "1783234756.192097-sqn46h"}	http://localhost:8600/snapshots/598f5fc4-4899-4d3a-8443-f5bc923e1c2f.jpg	2026-07-05 06:59:21.413989+00	f	{}	\N	\N	\N	\N	\N	\N	\N	f	f	\N
ac8d3f88-a100-4c33-8209-2e30e8fceeb8	e2491873-0570-4d58-9c54-c9acabd8a86b	restricted_zone	high	{"score": 0.83984375, "source": "veedon-edge", "branch_id": "0ab2ca49-ad88-4630-afb6-3ef008e1cef5", "feature_key": "restricted_zone", "engine_event": "1783234820.109391-sog7bd"}	http://localhost:8600/snapshots/ac8d3f88-a100-4c33-8209-2e30e8fceeb8.jpg	2026-07-05 07:00:27.947719+00	f	{}	\N	\N	\N	\N	\N	\N	\N	f	f	\N
eea8fa9a-e8fe-4807-a4f6-82f0070261a9	e2491873-0570-4d58-9c54-c9acabd8a86b	restricted_zone	high	{"score": 0.76171875, "source": "veedon-edge", "branch_id": "0ab2ca49-ad88-4630-afb6-3ef008e1cef5", "feature_key": "restricted_zone", "engine_event": "1783234924.281956-qnnx12"}	http://localhost:8600/snapshots/eea8fa9a-e8fe-4807-a4f6-82f0070261a9.jpg	2026-07-05 07:02:10.810044+00	f	{}	\N	\N	\N	\N	\N	\N	\N	f	f	\N
3db37a7e-c487-40b3-85b4-781b3ee709b1	e2491873-0570-4d58-9c54-c9acabd8a86b	restricted_zone	high	{"score": 0.7265625, "source": "veedon-edge", "branch_id": "0ab2ca49-ad88-4630-afb6-3ef008e1cef5", "feature_key": "restricted_zone", "engine_event": "1783235019.233667-n1crbq"}	http://localhost:8600/snapshots/3db37a7e-c487-40b3-85b4-781b3ee709b1.jpg	2026-07-05 07:03:47.656871+00	f	{}	\N	\N	\N	\N	\N	\N	\N	f	f	\N
f1721cbb-ec6f-46ce-9198-329ec3f3180a	e2491873-0570-4d58-9c54-c9acabd8a86b	restricted_zone	high	{"score": 0.70703125, "source": "veedon-edge", "branch_id": "0ab2ca49-ad88-4630-afb6-3ef008e1cef5", "feature_key": "restricted_zone", "engine_event": "1783235313.344533-gvyj29"}	http://localhost:8600/snapshots/f1721cbb-ec6f-46ce-9198-329ec3f3180a.jpg	2026-07-05 07:08:37.986958+00	f	{}	\N	\N	\N	\N	\N	\N	\N	f	f	\N
694a882c-06f8-402f-a0e8-ac16b990bf2e	e2491873-0570-4d58-9c54-c9acabd8a86b	restricted_zone	high	{"score": 0.82421875, "source": "veedon-edge", "branch_id": "0ab2ca49-ad88-4630-afb6-3ef008e1cef5", "feature_key": "restricted_zone", "engine_event": "1783235415.475989-wd9uim"}	http://localhost:8600/snapshots/694a882c-06f8-402f-a0e8-ac16b990bf2e.jpg	2026-07-05 07:10:20.885923+00	f	{}	\N	\N	\N	\N	\N	\N	\N	f	f	\N
e92e3973-b3c7-4312-9b02-36d0848b57f9	e2491873-0570-4d58-9c54-c9acabd8a86b	restricted_zone	high	{"score": 0.84375, "source": "veedon-edge", "branch_id": "0ab2ca49-ad88-4630-afb6-3ef008e1cef5", "feature_key": "restricted_zone", "engine_event": "1783235445.028126-nupa91"}	http://localhost:8600/snapshots/e92e3973-b3c7-4312-9b02-36d0848b57f9.jpg	2026-07-05 07:10:51.125732+00	f	{}	\N	\N	\N	\N	\N	\N	\N	f	f	\N
87ba9e5f-4dea-4327-8873-ae195d792ee9	e2491873-0570-4d58-9c54-c9acabd8a86b	restricted_zone	high	{"score": 0.71484375, "source": "veedon-edge", "branch_id": "0ab2ca49-ad88-4630-afb6-3ef008e1cef5", "feature_key": "restricted_zone", "engine_event": "1783235842.170349-1yz4qv"}	http://localhost:8600/snapshots/87ba9e5f-4dea-4327-8873-ae195d792ee9.jpg	2026-07-05 07:17:54.501767+00	f	{}	\N	\N	\N	\N	\N	\N	\N	f	f	\N
3f7ebc0e-88ea-4d40-b9ff-c9da46dc08c5	e2491873-0570-4d58-9c54-c9acabd8a86b	restricted_zone	high	{"score": 0.78125, "source": "veedon-edge", "branch_id": "0ab2ca49-ad88-4630-afb6-3ef008e1cef5", "feature_key": "restricted_zone", "engine_event": "1783236039.134-wifrq1"}	http://localhost:8600/snapshots/3f7ebc0e-88ea-4d40-b9ff-c9da46dc08c5.jpg	2026-07-05 07:20:43.795052+00	f	{}	\N	\N	\N	\N	\N	\N	\N	f	f	\N
71cfe54b-df03-4fe9-901d-89944b244fc2	e2491873-0570-4d58-9c54-c9acabd8a86b	restricted_zone	high	{"score": 0.71484375, "source": "veedon-edge", "branch_id": "0ab2ca49-ad88-4630-afb6-3ef008e1cef5", "feature_key": "restricted_zone", "engine_event": "1783236157.606061-hqdxwt"}	http://localhost:8600/snapshots/71cfe54b-df03-4fe9-901d-89944b244fc2.jpg	2026-07-05 07:22:50.803742+00	f	{}	\N	\N	\N	\N	\N	\N	\N	f	f	\N
32bfb254-101e-4093-b004-eff7a2d13abe	e2491873-0570-4d58-9c54-c9acabd8a86b	restricted_zone	high	{"score": 0.8046875, "source": "veedon-edge", "branch_id": "0ab2ca49-ad88-4630-afb6-3ef008e1cef5", "feature_key": "restricted_zone", "engine_event": "1783209294.944139-xvdo6d"}	http://localhost:8600/snapshots/32bfb254-101e-4093-b004-eff7a2d13abe.jpg	2026-07-04 23:54:57.99426+00	f	{}	\N	\N	\N	\N	\N	\N	\N	f	f	\N
98822da5-5e43-4eaa-ac27-a2aa218edc52	e2491873-0570-4d58-9c54-c9acabd8a86b	restricted_zone	high	{"score": 0.84375, "source": "veedon-edge", "branch_id": "0ab2ca49-ad88-4630-afb6-3ef008e1cef5", "feature_key": "restricted_zone", "engine_event": "1783209348.941291-a5qhkn"}	http://localhost:8600/snapshots/98822da5-5e43-4eaa-ac27-a2aa218edc52.jpg	2026-07-04 23:55:52.414055+00	f	{}	\N	\N	\N	\N	\N	\N	\N	f	f	\N
dde28748-5a68-4c64-ae6c-baa0b05eb150	e2491873-0570-4d58-9c54-c9acabd8a86b	restricted_zone	high	{"score": 0.8046875, "source": "veedon-edge", "branch_id": "0ab2ca49-ad88-4630-afb6-3ef008e1cef5", "feature_key": "restricted_zone", "engine_event": "1783209402.774088-cs08nm"}	http://localhost:8600/snapshots/dde28748-5a68-4c64-ae6c-baa0b05eb150.jpg	2026-07-04 23:56:47.034291+00	f	{}	\N	\N	\N	\N	\N	\N	\N	f	f	\N
0b2775ef-667d-4b97-bcbe-97d7470875a4	e2491873-0570-4d58-9c54-c9acabd8a86b	restricted_zone	high	{"score": 0.84375, "source": "veedon-edge", "branch_id": "0ab2ca49-ad88-4630-afb6-3ef008e1cef5", "feature_key": "restricted_zone", "engine_event": "1783209456.772252-euv2z0"}	http://localhost:8600/snapshots/0b2775ef-667d-4b97-bcbe-97d7470875a4.jpg	2026-07-04 23:57:41.683502+00	f	{}	\N	\N	\N	\N	\N	\N	\N	f	f	\N
\.


--
-- Data for Name: form_assignments; Type: TABLE DATA; Schema: public; Owner: postgres
--

COPY public.form_assignments (id, workflow_form_id, organization_id, representative_id, assigned_by, due_date, reminder_frequency, is_active, created_at, updated_at) FROM stdin;
\.


--
-- Data for Name: form_distribution_settings; Type: TABLE DATA; Schema: public; Owner: postgres
--

COPY public.form_distribution_settings (id, workflow_form_id, distribution_type, target_groups, target_users, schedule_type, schedule_data, notification_settings, created_by, created_at, updated_at) FROM stdin;
\.


--
-- Data for Name: form_submissions; Type: TABLE DATA; Schema: public; Owner: postgres
--

COPY public.form_submissions (id, form_assignment_id, submitted_data, submitted_at, submitted_by, status) FROM stdin;
\.


--
-- Data for Name: frigate_alert_rules; Type: TABLE DATA; Schema: public; Owner: postgres
--

COPY public.frigate_alert_rules (id, camera_id, rule_name, object_types, zones, min_confidence, cooldown_seconds, notification_methods, enabled, created_at, updated_at) FROM stdin;
\.


--
-- Data for Name: frigate_deployed_models; Type: TABLE DATA; Schema: public; Owner: postgres
--

COPY public.frigate_deployed_models (id, frigate_instance_id, model_id, model_name, category, labels, onnx_path, pt_path, config_snippet, runtime, status, download_url, license, accuracy, error_message, deployed_at, applied_to_cameras, created_at, updated_at) FROM stdin;
\.


--
-- Data for Name: frigate_exports; Type: TABLE DATA; Schema: public; Owner: postgres
--

COPY public.frigate_exports (id, export_id, frigate_instance_id, camera, start_time, end_time, path, status, url, metadata, created_at, updated_at) FROM stdin;
\.


--
-- Data for Name: frigate_faces; Type: TABLE DATA; Schema: public; Owner: postgres
--

COPY public.frigate_faces (id, camera_id, embedding, label, confidence, thumbnail_url, created_at, updated_at) FROM stdin;
\.


--
-- Data for Name: frigate_instances; Type: TABLE DATA; Schema: public; Owner: postgres
--

COPY public.frigate_instances (id, branch_id, name, description, host_url, api_key, config_yaml, enabled, last_sync_at, created_at, updated_at, sync_interval_seconds) FROM stdin;
48c9e5dc-6641-4331-91a0-44a1cede5152	c81c2c3a-7058-4ec4-9d59-7d342bba78e7	البيت		http://192.168.8.106:5000/			t	2026-06-12 23:02:46.732+00	2026-06-12 13:46:27.836355+00	2026-06-12 23:02:46.733583+00	300
4c597f99-e472-44f7-ac2e-88c03965269d	0ab2ca49-ad88-4630-afb6-3ef008e1cef5	Veedon Edge (dev)	\N	http://host.docker.internal:5000	\N	\N	t	\N	2026-07-04 18:02:32.635556+00	2026-07-04 18:02:32.635556+00	300
\.


--
-- Data for Name: frigate_license_plates; Type: TABLE DATA; Schema: public; Owner: postgres
--

COPY public.frigate_license_plates (id, plate_number, camera_id, confidence, region, vehicle_make, vehicle_model, vehicle_color, thumbnail_url, created_at, updated_at, frigate_instance_id, is_watchlisted, watchlist_notes, recognized_count, last_seen_at) FROM stdin;
\.


--
-- Data for Name: frigate_model_deployments; Type: TABLE DATA; Schema: public; Owner: postgres
--

COPY public.frigate_model_deployments (id, model_id, frigate_instance_id, deployment_status, applied_to_cameras, applied_zones, runtime, threshold, remote_path, config_snippet, last_sync_at, last_verified_at, last_event_count, error_message, deployed_by, deployed_at, created_at, updated_at) FROM stdin;
\.


--
-- Data for Name: frigate_model_registry; Type: TABLE DATA; Schema: public; Owner: postgres
--

COPY public.frigate_model_registry (id, model_id, name_ar, name_en, category, sector_ar, description_ar, publisher, source_url, framework, labels, label_to_frigate, license, commercial_ok, preferred_runtime, accuracy, last_updated, stars, recommendation, compliance_note_ar, storage_path, storage_size_bytes, storage_etag, storage_updated_at, formats, frigate_config_yaml, status, download_count, created_at, updated_at) FROM stdin;
e7c9331e-0296-4f49-9382-8491b7c097d7	abonai_fire_smoke	Abonia1 Fire+Smoke YOLOv8n	Abonia1 YOLOv8 Fire and Smoke	fire_smoke	حراسة عامة، خفيف للأجهزة المحدودة	الأعلى نجوماً (375 ⭐) — YOLOv8n وYOLOv8s مدرَّبان مسبقاً	Abonia Sojasingarayar	https://github.com/Abonia1/YOLOv8-Fire-and-Smoke-Detection	yolov8-detect	["fire", "smoke"]	{"fire": "fire", "smoke": "smoke"}	AGPL-3.0	f	{cpu,cuda}	\N	2024-06-01	375	alternate	AGPL-3.0: يتطلب نشر الكود المصدري عند التوزيع. مناسب للبحث والاختبار.	models/abonai_fire_smoke/yolov8n.pt	6534387		2026-06-14 07:41:53.746372+00	[{"url": "https://github.com/Abonia1/YOLOv8-Fire-and-Smoke-Detection/raw/main/yolov8n.pt", "type": "pt", "size_mb": 6, "prebuilt": true}, {"url": "https://github.com/Abonia1/YOLOv8-Fire-and-Smoke-Detection/raw/main/yolov8s.pt", "type": "pt", "size_mb": 22, "prebuilt": true}]		available	0	2026-06-14 07:41:53.764719+00	2026-06-14 07:41:53.764719+00
208277d2-0994-4367-b4aa-72d0c8f67ec3	dfire_yolov8m	D-Fire YOLOv8m — حريق + دخان	AlimTleuliyev wildfire-detection (D-Fire)	fire_smoke	غابات، مباني، مراكز بيانات	YOLOv8m مدرَّب على D-Fire dataset (21K صورة) — فئتين: حريق ودخان	ISSAI — Nazarbayev University	https://github.com/AlimTleuliyev/wildfire-detection	yolov8-detect	["fire", "smoke"]	{"fire": "fire", "smoke": "smoke"}	MIT	t	{cuda,rocm,cpu}	{"value": 0.801, "metric": "mAP@0.5 (YOLOv8m)"}	2024-06-01	\N	alternate	\N	\N	0	\N	2026-06-14 07:47:13.523261+00	[{"url": "https://github.com/AlimTleuliyev/wildfire-detection/releases/download/v1.0/best.pt", "type": "pt", "size_mb": 52, "prebuilt": false}]	# ─────────────────────────────────────────────────────────\n# Beyond Senses auto-generated config for:\n#   AlimTleuliyev wildfire-detection (D-Fire)  (dfire_yolov8m)\n# Frigate instance: dfire_yolov8m\n# ─────────────────────────────────────────────────────────\ndetectors:\n  dfire_yolov8m_dfire_yolov8m:\n    type: onnx\n    device: cuda\n    provider: cuda\n    num_threads: 3\n\nmodel:\n  custom_recognizer: dfire_yolov8m\n  # النماذج المُحمَّلة من الكتالوج تُسجَّل في DB\n  # frigate يفحص /config/model_cache/dfire_yolov8m_dfire_yolov8m.onnx تلقائياً\n\n# zones & labels جاهزة (يمكن تخصيصها)\nlabels:\n  fire:\n  smoke:\n\n# مثال: كيف يُطبَّق النموذج على كاميرا معيّنة\n# cameras:\n#   cam_01:\n#     detect:\n#       enabled: true\n#     model:\n#       type: dfire_yolov8m\n#     zones:\n#       - name: work_zone\n#         coordinates: "0,0,1000,0,1000,1000,0,1000"\n#         filters:\n#           fire_threshold: 0.6\n# ─────────────────────────────────────────────────────────\n	error	0	2026-06-14 07:41:50.401667+00	2026-06-14 07:47:13.56873+00
d38a91f5-bf76-43ad-aaf2-d2c1087b2893	hexmon_vyra_ppe	Hexmon Vyra PPE — 14 فئة شاملة	Hexmon/vyra-yolo-ppe-detection	ppe	صناعات نفط وغاز، بناء، مستودعات	النموذج الأشمل: خوذة، سترة، كمامة، قفازات، نظارات، Fall-Detected، Ladder، Cone — 14 فئة	Hexmon	https://huggingface.co/Hexmon/vyra-yolo-ppe-detection	yolov8-detect	["Hardhat", "NO-Hardhat", "Safety Vest", "NO-Safety Vest", "Mask", "NO-Mask", "Gloves", "NO-Gloves", "Goggles", "NO-Goggles", "Person", "Safety Cone", "Ladder", "Fall-Detected"]	{"Mask": "mask", "Gloves": "gloves", "Ladder": "ladder", "Person": "person", "Goggles": "goggles", "Hardhat": "hardhat", "NO-Mask": "no_mask", "NO-Gloves": "no_gloves", "NO-Goggles": "no_goggles", "NO-Hardhat": "no_hardhat", "Safety Cone": "cone", "Safety Vest": "vest", "Fall-Detected": "fall", "NO-Safety Vest": "no_vest"}	CC-BY-4.0	t	{cuda,cpu}	{"value": 0.88, "metric": "mAP@0.5"}	2025-01-01	\N	primary	CC-BY-4.0: يتطلب ذكر المصدر. للاستخدام التجاري ذكر إلزامي.	models/hexmon_vyra_ppe/best.pt	52056210		2026-06-14 07:41:59.308884+00	[{"url": "https://huggingface.co/Hexmon/vyra-yolo-ppe-detection/resolve/main/best.pt", "type": "pt", "size_mb": 50, "prebuilt": true}]		available	0	2026-06-14 07:41:59.311354+00	2026-06-14 07:41:59.311354+00
830af4ba-fc63-4640-88b0-da23a5e63729	keremberke_ppe	Keremberke PPE — 15 فئة	keremberke/yolov8s-protective-equipment-detection	ppe	صناعات، بناء، مطارات	YOLOv8s 15+ فئة PPE + معدات (machinery, vehicle, harness, ear-protector)	keremberke	https://huggingface.co/keremberke/yolov8s-protective-equipment-detection	yolov8-detect	["Hardhat", "Mask", "NO-Hardhat", "NO-Mask", "NO-Safety Vest", "Person", "Safety Cone", "Safety Vest", "machinery", "vehicle", "glasses", "gloves", "PPE-suit", "ear-protector", "safety-harness"]	{"Mask": "mask", "Person": "person", "Hardhat": "hardhat", "Safety Vest": "vest"}	CC-BY-4.0	t	{cpu,cuda}	{"value": 0.87, "metric": "mAP@0.5"}	2024-01-01	\N	alternate	\N	models/keremberke_ppe/best.pt	22500088		2026-06-14 07:42:01.372673+00	[{"url": "https://huggingface.co/keremberke/yolov8s-protective-equipment-detection/resolve/main/best.pt", "type": "pt", "size_mb": 22, "prebuilt": true}]	# ─────────────────────────────────────────────────────────\n# Beyond Senses auto-generated config for:\n#   keremberke/yolov8s-protective-equipment-detection  (keremberke_ppe)\n# Frigate instance: keremberke_ppe\n# ─────────────────────────────────────────────────────────\ndetectors:\n  keremberke_ppe_keremberke_ppe:\n    type: onnx\n    device: cpu\n    num_threads: 3\n\nmodel:\n  custom_recognizer: keremberke_ppe\n  # النماذج المُحمَّلة من الكتالوج تُسجَّل في DB\n  # frigate يفحص /config/model_cache/keremberke_ppe_keremberke_ppe.onnx تلقائياً\n\n# zones & labels جاهزة (يمكن تخصيصها)\nlabels:\n  Hardhat:\n  Mask:\n  NO-Hardhat:\n  NO-Mask:\n  NO-Safety Vest:\n  Person:\n  Safety Cone:\n  Safety Vest:\n  machinery:\n  vehicle:\n  glasses:\n  gloves:\n  PPE-suit:\n  ear-protector:\n  safety-harness:\n\n# مثال: كيف يُطبَّق النموذج على كاميرا معيّنة\n# cameras:\n#   cam_01:\n#     detect:\n#       enabled: true\n#     model:\n#       type: keremberke_ppe\n#     zones:\n#       - name: work_zone\n#         coordinates: "0,0,1000,0,1000,1000,0,1000"\n#         filters:\n#           Hardhat_threshold: 0.6\n# ─────────────────────────────────────────────────────────\n	available	0	2026-06-14 07:42:01.375691+00	2026-06-14 07:42:01.375691+00
76481478-617f-4d3b-b149-64d335dad3a7	subh_threat	Threat Detection — 4 فئات	Subh775/Threat-Detection-YOLOv8n	weapon	حراسة عامة، منشآت حساسة، مطارات	أربع فئات: Gun + Explosive + Grenade + Knife — mAP 81.1% (Gun 96.7%)	Subh775	https://huggingface.co/Subh775/Threat-Detection-YOLOv8n	yolov8-detect	["gun", "explosive", "grenade", "knife"]	{"gun": "weapon_gun", "knife": "weapon_knife", "grenade": "weapon_grenade", "explosive": "weapon_explosive"}	MIT	t	{cpu,cuda,edgetpu}	{"value": 0.811, "metric": "mAP@0.5"}	2025-01-01	\N	primary	⚠️ الاستخدام محصور بالمراقبة المشروعة (الأماكن العامة، المنشآت السعودية). يخضع لقانون PDPL.	models/subh_threat/best.pt	6251747		2026-06-14 07:42:04.46042+00	[{"url": "https://huggingface.co/Subh775/Threat-Detection-YOLOv8n/resolve/main/weights/best.pt", "type": "pt", "size_mb": 6, "prebuilt": true}]		available	0	2026-06-14 07:42:04.48194+00	2026-06-14 07:42:04.48194+00
6f7d2a39-2170-405a-9feb-ce23891fe952	subh_firearm	Firearm Detection YOLOv8n — دقة عالية	Subh775/Firearm_Detection_Yolov8n	weapon	حراسة عامة، بنوك، مدارس	كشف أسلحة نارية بدقة mAP 89% — فئة Gun فقط، Apache-2.0	Subh775	https://huggingface.co/Subh775/Firearm_Detection_Yolov8n	yolov8-detect	["gun"]	{"gun": "weapon_gun"}	Apache-2.0	t	{cpu,cuda,edgetpu}	{"value": 0.89, "metric": "mAP@0.5"}	2025-01-01	\N	alternate	⚠️ استخدام محصور بالمراقبة المشروعة	models/subh_firearm/best.pt	6238307		2026-06-14 07:42:07.315642+00	[{"url": "https://huggingface.co/Subh775/Firearm_Detection_Yolov8n/resolve/main/weights/best.pt", "type": "pt", "size_mb": 6, "prebuilt": true}]		available	0	2026-06-14 07:42:07.33696+00	2026-06-14 07:42:07.33696+00
66988456-196c-4cea-8a07-7a0b348fb0d3	enos_traffic_accident	Traffic Accident Detection YOLO11x	Enos-123/traffic-accident-detection-yolo11x	traffic	طرق، جسور، تقاطعات	YOLOv11x لاكتشاف الحوادث المرورية — mAP 82.6%	Enos-123	https://huggingface.co/Enos-123/traffic-accident-detection-yolo11x	yolov11-detect	["accident", "vehicle"]	{"vehicle": "vehicle", "accident": "traffic_accident"}	MIT	t	{cuda,rocm}	{"value": 0.826, "metric": "mAP@0.5"}	2025-06-01	\N	primary	\N	models/enos_traffic_accident/epoch61.pt	114368274		2026-06-14 07:47:20.539898+00	[{"url": "https://huggingface.co/Enos-123/traffic-accident-detection-yolo11x/resolve/main/weights/epoch61.pt", "type": "pt", "size_mb": 110, "prebuilt": true}]	# ─────────────────────────────────────────────────────────\n# Beyond Senses auto-generated config for:\n#   Enos-123/traffic-accident-detection-yolo11x  (enos_traffic_accident)\n# Frigate instance: enos_traffic_accident\n# ─────────────────────────────────────────────────────────\ndetectors:\n  enos_traffic_accident_enos_traffic_accident:\n    type: onnx\n    device: cuda\n    provider: cuda\n    num_threads: 3\n\nmodel:\n  custom_recognizer: enos_traffic_accident\n  # النماذج المُحمَّلة من الكتالوج تُسجَّل في DB\n  # frigate يفحص /config/model_cache/enos_traffic_accident_enos_traffic_accident.onnx تلقائياً\n\n# zones & labels جاهزة (يمكن تخصيصها)\nlabels:\n  accident:\n  vehicle:\n\n# مثال: كيف يُطبَّق النموذج على كاميرا معيّنة\n# cameras:\n#   cam_01:\n#     detect:\n#       enabled: true\n#     model:\n#       type: enos_traffic_accident\n#     zones:\n#       - name: work_zone\n#         coordinates: "0,0,1000,0,1000,1000,0,1000"\n#         filters:\n#           accident_threshold: 0.6\n# ─────────────────────────────────────────────────────────\n	available	0	2026-06-14 07:42:08.100672+00	2026-06-14 07:47:20.55805+00
f6ab4bd7-267d-4ede-b695-4c30013d8fee	melih_fall	Human Fall Detection YOLOv11	melihuzunoglu/human-fall-detection	behavior	مستشفيات، دور رعاية، منشآت عامة	كشف السقوط — 3 فئات: Fallen, Sitting, Standing	Melih Uzunoglu	https://huggingface.co/melihuzunoglu/human-fall-detection	yolov11-detect	["Fallen", "Sitting", "Standing"]	{"Fallen": "fall_detected", "Sitting": "sitting", "Standing": "standing"}	AGPL-3.0	f	{cpu,cuda}	\N	2025-01-01	\N	alternate	AGPL-3.0: مقيّد تجارياً.	models/melih_fall/best.pt	5472282		2026-06-14 07:42:11.714312+00	[{"url": "https://huggingface.co/melihuzunoglu/human-fall-detection/resolve/main/best.pt", "type": "pt", "size_mb": 6, "prebuilt": true}]		available	0	2026-06-14 07:42:11.717314+00	2026-06-14 07:42:11.717314+00
ac6ae798-8737-4b31-9ee7-b92e26fb5625	risef_seatbelt	Seatbelt Detection YOLOv11s	RISEF/yolov11s-seatbelt	traffic	أسطول نقل، طرق سريعة، شركات تأجير	كشف حزام الأمان (seatbelt / no_seatbelt) — DeepStream + Triton ready	RISEF	https://huggingface.co/RISEF/yolov11s-seatbelt	yolov11-detect	["no_seatbelt", "seat_belt"]	{"seat_belt": "seatbelt", "no_seatbelt": "no_seatbelt"}	AGPL-3.0	f	{cuda,cpu}	{"value": 1, "metric": "val-top-1"}	2025-01-01	\N	alternate	AGPL-3.0: يتطلب نشر الكود عند التوزيع التجاري.	models/risef_seatbelt/best.pt	11024315		2026-06-14 07:47:24.011033+00	[{"url": "https://huggingface.co/RISEF/yolov11s-seatbelt/resolve/main/weights/best.pt", "type": "pt", "size_mb": 11, "prebuilt": true}, {"url": "https://huggingface.co/RISEF/yolov11s-seatbelt/resolve/main/weights/best.onnx", "type": "onnx", "size_mb": 21, "prebuilt": true}]		available	0	2026-06-14 07:42:09.6085+00	2026-06-14 07:47:24.017141+00
fc561f96-6a7a-4c1f-84a4-aa98a677d9c7	mkgoud_lpr	License Plate Detection YOLOv8	MKgoud/License-Plate-Recognizer	traffic	مواقف، بوابات، طرق	كشف لوحات السيارات (Detection only — يحتاج OCR لاحقاً)	MKgoud	https://huggingface.co/MKgoud/License-Plate-Recognizer	yolov8-detect	["license_plate"]	{"license_plate": "license_plate"}	MIT	t	{cpu,cuda,edgetpu}	\N	2024-01-01	\N	primary	للوحات السعودية/العربية يُنصح بضبط دقيق على بيانات محلية (Qari-OCR للقراءة).	models/mkgoud_lpr/LP-detection.pt	6239992		2026-06-14 07:47:28.533354+00	[{"url": "https://huggingface.co/MKgoud/License-Plate-Recognizer/resolve/main/LP-detection.pt", "type": "pt", "size_mb": 6, "prebuilt": true}]		available	0	2026-06-14 07:42:10.365488+00	2026-06-14 07:47:28.56436+00
d7baae49-582a-40c9-a5b1-a09059d7f05b	musawer_fight	Fight/Violence Detection YOLOv8	Musawer1214/Fight-Violence-detection-yolov8	behavior	مدارس، جامعات، مراكز تجارية	كشف الشجار والعنف — YOLOv8n/s مدرب مسبقاً	Musawer1214	https://github.com/Musawer1214/Fight-Violence-detection-yolov8	yolov8-detect	["Violence", "NoViolence"]	{"Violence": "violence_detected", "NoViolence": "normal"}	MIT	t	{cpu,cuda}	\N	2025-01-01	\N	primary	⚠️ الإنذارات الكاذبة عالية، يفضل ربطه بتتبع الحركة وZones.	models/musawer_fight/Yolo_nano_weights.pt	6250147		2026-06-14 07:47:32.413425+00	[{"url": "https://github.com/Musawer1214/Fight-Violence-detection-yolov8/raw/main/Yolo_nano_weights.pt", "type": "pt", "size_mb": 6, "prebuilt": true}]		available	0	2026-06-14 07:42:12.438814+00	2026-06-14 07:47:32.440959+00
fd325e96-e9f0-4cc9-aaf0-0685be46ff1c	yolo_crowd	YOLO-CROWD — إحصاء الحشود	zaki1003/YOLO-CROWD	behavior	حج، عمرة، مساجد، ملاعب	إحصاء الأشخاص في الحشود الكثيفة — YOLO قابل للتشغيل على Frigate	zaki1003	https://github.com/zaki1003/YOLO-CROWD	yolov8-detect	["person"]	{"person": "person"}	MIT	t	{cuda,cpu}	\N	2024-01-01	\N	primary	مهم: مكة والمدينة (الحج/العمرة) — راقب الـ object count threshold.	\N	0	\N	2026-06-14 07:47:32.448333+00	[{"url": "https://huggingface.co/AmineSam/irail-crowd-counting-yolov8n/resolve/main/best.pt", "type": "pt", "size_mb": 6, "prebuilt": true}]		error	0	2026-06-14 07:42:13.132258+00	2026-06-14 07:47:32.479062+00
ccb3272f-a82b-4ac0-b17d-ca8431f26f56	keremberke_forklift	Forklift Detection YOLOv8s	keremberke/yolov8s-forklift-detection	industrial	مستودعات، مصانع، لوجستيات	كشف الرافعات الشوكية + الأشخاص — YOLOv8s مدرب مسبقاً	keremberke	https://huggingface.co/keremberke/yolov8s-forklift-detection	yolov8-detect	["forklift", "person"]	{"person": "person", "forklift": "forklift"}	CC-BY-4.0	t	{cuda,cpu}	\N	2024-01-01	\N	primary	\N	models/keremberke_forklift/best.pt	22485752		2026-06-14 07:42:15.684462+00	[{"url": "https://huggingface.co/keremberke/yolov8s-forklift-detection/resolve/main/best.pt", "type": "pt", "size_mb": 22, "prebuilt": true}]	# ─────────────────────────────────────────────────────────\n# Beyond Senses auto-generated config for:\n#   keremberke/yolov8s-forklift-detection  (keremberke_forklift)\n# Frigate instance: keremberke_forklift\n# ─────────────────────────────────────────────────────────\ndetectors:\n  keremberke_forklift_keremberke_forklift:\n    type: onnx\n    device: cuda\n    provider: cuda\n    num_threads: 3\n\nmodel:\n  custom_recognizer: keremberke_forklift\n  # النماذج المُحمَّلة من الكتالوج تُسجَّل في DB\n  # frigate يفحص /config/model_cache/keremberke_forklift_keremberke_forklift.onnx تلقائياً\n\n# zones & labels جاهزة (يمكن تخصيصها)\nlabels:\n  forklift:\n  person:\n\n# مثال: كيف يُطبَّق النموذج على كاميرا معيّنة\n# cameras:\n#   cam_01:\n#     detect:\n#       enabled: true\n#     model:\n#       type: keremberke_forklift\n#     zones:\n#       - name: work_zone\n#         coordinates: "0,0,1000,0,1000,1000,0,1000"\n#         filters:\n#           forklift_threshold: 0.6\n# ─────────────────────────────────────────────────────────\n	available	0	2026-06-14 07:42:15.708974+00	2026-06-14 07:42:15.708974+00
66c9804d-8768-4fce-baaf-a3597f97c0e0	saudi_plates_dt	Saudi License Plates (Roboflow)	saudi-plates-dt (Roboflow Universe)	saudi	بوابات، مواقف، نقاط تفتيش	نموذج مدرَّب مسبقاً على لوحات سعودية — 867 صورة	Roboflow Community	https://universe.roboflow.com/saudi-licence-plate/saudi-plates-dt	yolov8-detect	["saudi_plate", "plate_char", "number", "letter"]	{"saudi_plate": "saudi_license_plate"}	CC-BY-4.0	t	{cuda,cpu}	\N	2024-01-01	\N	primary	⚠️ يتطلب API key من Roboflow. لاحترام خصوصية المواطنين (PDPL).	\N	0	\N	2026-06-14 07:47:32.567228+00	[{"url": "https://universe.roboflow.com/saudi-licence-plate/saudi-plates-dt/model/1/download", "type": "pt", "size_mb": 6, "prebuilt": true}]		error	0	2026-06-14 07:42:16.376222+00	2026-06-14 07:47:32.590438+00
243916b8-58c0-4a10-a6aa-f62783be2cbe	qari_ocr	Qari-OCR — OCR عربي متقدم	NAMAA-Space/Qari-OCR-0.4.0-VL-4B-Instruct	saudi	قراءة لوحات إعلانية، وثائق	أفضل OCR عربي حالياً (BLEU 68.4) — Qwen3-VL-4B	NAMAA Space	https://huggingface.co/NAMAA-Space/Qari-OCR-0.4.0-VL-4B-Instruct	rfdetr-detect	["arabic_text"]	{"arabic_text": "ocr_text"}	Apache-2.0	t	{cuda}	{"value": 68.4, "metric": "BLEU"}	2025-01-01	\N	alternate	⚠️ نموذج كبير (8GB VRAM) — يحتاج GPU منفصل. لا يعمل مباشرة على Frigate، يحتاج API.	\N	0	\N	2026-06-14 07:47:32.596169+00	[{"url": "https://huggingface.co/NAMAA-Space/Qari-OCR-0.4.0-VL-4B-Instruct", "type": "pt", "size_mb": 8000, "prebuilt": true}]		error	0	2026-06-14 07:42:16.412014+00	2026-06-14 07:47:32.605588+00
5ebaf67e-e603-4746-8765-cad1a7a653bd	hijab_detection	Hijab Detection	dalabdgw/Hijab_Detection	saudi	مراكز نسائية، مدارس، مساجد	كشف الحجاب (Hijab / No-Hijab) — للإحصاء والامتثال في الأماكن المخصصة	dalabdgw	https://github.com/dalabdgw/Hijab_Detection	yolov8-detect	["hijab", "no_hijab", "person"]	{"hijab": "hijab", "person": "person", "no_hijab": "no_hijab"}	MIT	t	{cpu,cuda}	\N	2024-01-01	\N	alternate	⚠️ استخدام حساس ثقافياً — يجب احترام خصوصية المرأة (PDPL).	\N	0	\N	2026-06-14 07:47:32.612021+00	[{"url": "https://github.com/dalabdgw/Hijab_Detection/raw/main/best.pt", "type": "pt", "size_mb": 6, "prebuilt": false}]		error	0	2026-06-14 07:42:17.125545+00	2026-06-14 07:47:32.634175+00
aa20bd13-8686-48b0-9062-5748f661ad08	firedet1280	FireDet1280 — كشف اللهب	AresGod96 FireDet-YOLOv8 1280	fire_smoke	حراسة عامة، مستودعات، محطات وقود	كشف اللهب بدقة عالية (mAP 0.86) على إطارات 1280px — مُحسَّن لكاميرات المراقبة	AresGod96	https://github.com/AresGod96/FireDet-YOLOv8	yolov8-detect	["fire"]	{"fire": "fire"}	Apache-2.0	t	{cuda,rocm,openvino,cpu}	{"value": 0.86, "metric": "mAP@0.5 (1280px)"}	2024-01-01	\N	primary	\N	\N	0	\N	2026-06-14 07:47:13.435031+00	[{"url": "https://github.com/AresGod96/FireDet-YOLOv8/releases/download/v1.0/FireDet1280.pt", "type": "pt", "size_mb": 50, "prebuilt": false}, {"url": "https://github.com/AresGod96/FireDet-YOLOv8/releases/download/v1.0/FireDet1280.onnx", "type": "onnx", "size_mb": 50, "prebuilt": false}]	# ─────────────────────────────────────────────────────────\n# Beyond Senses auto-generated config for:\n#   AresGod96 FireDet-YOLOv8 1280  (firedet1280)\n# Frigate instance: firedet1280\n# ─────────────────────────────────────────────────────────\ndetectors:\n  firedet1280_firedet1280:\n    type: onnx\n    device: cuda\n    provider: cuda\n    num_threads: 3\n\nmodel:\n  custom_recognizer: firedet1280\n  # النماذج المُحمَّلة من الكتالوج تُسجَّل في DB\n  # frigate يفحص /config/model_cache/firedet1280_firedet1280.onnx تلقائياً\n\n# zones & labels جاهزة (يمكن تخصيصها)\nlabels:\n  fire:\n\n# مثال: كيف يُطبَّق النموذج على كاميرا معيّنة\n# cameras:\n#   cam_01:\n#     detect:\n#       enabled: true\n#     model:\n#       type: firedet1280\n#     zones:\n#       - name: work_zone\n#         coordinates: "0,0,1000,0,1000,1000,0,1000"\n#         filters:\n#           fire_threshold: 0.6\n# ─────────────────────────────────────────────────────────\n	error	0	2026-06-14 07:41:49.846479+00	2026-06-14 07:47:13.496898+00
1829da52-0a5d-411b-a32f-9268335a2302	illia_industrial_safety	Industrial Safety Vision — منصة شاملة	IlliaSator/industrial-safety-vision	industrial	صناعات نفط وغاز، مصانع	منصة FastAPI + YOLO كاملة: PPE + zones + tracking + alerts	IlliaSator	https://github.com/IlliaSator/industrial-safety-vision	yolov8-detect	["person", "hardhat", "vest", "no_hardhat", "no_vest", "forklift"]	{"vest": "vest", "person": "person", "hardhat": "hardhat", "no_vest": "no_vest", "forklift": "forklift", "no_hardhat": "no_hardhat"}	MIT	t	{cuda,cpu}	\N	2025-01-01	\N	alternate	يُفضل تشغيله كخدمة منفصلة مدمجة مع Frigate عبر API.	\N	0	\N	2026-06-14 07:47:32.519921+00	[{"url": "https://github.com/IlliaSator/industrial-safety-vision/raw/main/best.pt", "type": "pt", "size_mb": 22, "prebuilt": false}]		error	0	2026-06-14 07:42:16.362295+00	2026-06-14 07:47:32.543784+00
\.


--
-- Data for Name: frigate_model_sync_log; Type: TABLE DATA; Schema: public; Owner: postgres
--

COPY public.frigate_model_sync_log (id, sync_type, model_id, frigate_instance_id, status, bytes_transferred, duration_ms, error_message, metadata, started_at, completed_at) FROM stdin;
\.


--
-- Data for Name: frigate_previews; Type: TABLE DATA; Schema: public; Owner: postgres
--

COPY public.frigate_previews (id, preview_id, frigate_instance_id, camera, start_time, end_time, path, url, metadata, created_at, updated_at) FROM stdin;
\.


--
-- Data for Name: frigate_recordings; Type: TABLE DATA; Schema: public; Owner: postgres
--

COPY public.frigate_recordings (id, recording_id, frigate_instance_id, camera, start_time, end_time, duration, size, path, url, metadata, created_at, updated_at) FROM stdin;
\.


--
-- Data for Name: frigate_reviews; Type: TABLE DATA; Schema: public; Owner: postgres
--

COPY public.frigate_reviews (id, review_id, frigate_instance_id, camera, start_time, end_time, severity, has_been_reviewed, data, metadata, created_at, updated_at, frigate_review_id, reviewed, reviewed_by, reviewed_at, thumb_path) FROM stdin;
c432a4ec-6fce-4557-b99c-9cba013f936d	1781240799.799822-kfc3zw	48c9e5dc-6641-4331-91a0-44a1cede5152	cam_01	2026-06-12 05:06:39.799+00	2026-06-12 05:06:40.645+00	alert	f	{"audio": [], "zones": [], "objects": ["person"], "metadata": null, "detections": ["1781240799.039065-2jttwc"], "sub_labels": [], "thumb_time": 1781240800.896007, "verified_objects": []}	{"frigate_instance_name": "البيت"}	2026-06-12 13:47:49.282979+00	2026-06-12 22:58:52.950885+00	1781240799.799822-kfc3zw	f	\N	\N	\N
737dbe7d-0e4c-42ea-b258-f84ee64189bf	1781240400.714291-8f97eg	48c9e5dc-6641-4331-91a0-44a1cede5152	cam_01	2026-06-12 05:00:00.714+00	2026-06-12 05:00:01.414+00	alert	f	{"audio": [], "zones": [], "objects": ["person"], "metadata": null, "detections": ["1781240398.592141-w254na"], "sub_labels": [], "thumb_time": 1781240401.702749, "verified_objects": []}	{"frigate_instance_name": "البيت"}	2026-06-12 13:47:49.297112+00	2026-06-12 22:58:52.950885+00	1781240400.714291-8f97eg	f	\N	\N	\N
d46ff1f1-1459-4a42-b939-49abf70cef3e	1781239869.607318-ecjbbt	48c9e5dc-6641-4331-91a0-44a1cede5152	cam_01	2026-06-12 04:51:09.607+00	2026-06-12 04:51:30.684+00	alert	f	{"audio": [], "zones": [], "objects": ["person"], "metadata": null, "detections": ["1781239881.625026-ehdj6i", "1781239868.811462-rjcybz"], "sub_labels": [], "thumb_time": 1781239870.609555, "verified_objects": []}	{"frigate_instance_name": "البيت"}	2026-06-12 13:47:49.30921+00	2026-06-12 22:58:52.950885+00	1781239869.607318-ecjbbt	f	\N	\N	\N
a112f1dd-c3d9-43a3-bca0-81d8fa1ccc7b	1781239144.852584-w1tnk0	48c9e5dc-6641-4331-91a0-44a1cede5152	cam_01	2026-06-12 04:39:04.852+00	2026-06-12 04:39:06.394+00	alert	f	{"audio": [], "zones": [], "objects": ["person"], "metadata": null, "detections": ["1781239144.024975-jsfv90"], "sub_labels": [], "thumb_time": 1781239145.898496, "verified_objects": []}	{"frigate_instance_name": "البيت"}	2026-06-12 13:47:49.321899+00	2026-06-12 22:58:52.950885+00	1781239144.852584-w1tnk0	f	\N	\N	\N
8a88d30d-982d-4fdb-9ea5-0cbc67575fb2	1781238796.428922-uw7mej	48c9e5dc-6641-4331-91a0-44a1cede5152	cam_01	2026-06-12 04:33:16.428+00	2026-06-12 04:33:59.838+00	alert	f	{"audio": [], "zones": [], "objects": ["person"], "metadata": null, "detections": ["1781238794.681665-6vw223", "1781238814.51098-nglpq3", "1781238834.377616-muxu60"], "sub_labels": [], "thumb_time": 1781238797.420536, "verified_objects": []}	{"frigate_instance_name": "البيت"}	2026-06-12 13:47:49.335524+00	2026-06-12 22:58:52.950885+00	1781238796.428922-uw7mej	f	\N	\N	\N
23d2c850-d819-4c9c-ac4b-6358998c3044	1781238361.573625-jtvgk7	48c9e5dc-6641-4331-91a0-44a1cede5152	cam_01	2026-06-12 04:26:01.573+00	2026-06-12 04:26:27.964+00	alert	f	{"audio": [], "zones": [], "objects": ["person"], "metadata": null, "detections": ["1781238360.711682-hevx5v", "1781238386.00809-kfsrm3"], "sub_labels": [], "thumb_time": 1781238362.34052, "verified_objects": []}	{"frigate_instance_name": "البيت"}	2026-06-12 13:47:49.346953+00	2026-06-12 22:58:52.950885+00	1781238361.573625-jtvgk7	f	\N	\N	\N
0bf78c1e-7991-4f5d-a961-6c8b9974c5bf	1781237357.933508-wvps2z	48c9e5dc-6641-4331-91a0-44a1cede5152	cam_01	2026-06-12 04:09:17.933+00	2026-06-12 04:09:18.765+00	alert	f	{"audio": [], "zones": [], "objects": ["person"], "metadata": null, "detections": ["1781237357.161254-xn3idy"], "sub_labels": [], "thumb_time": 1781237358.88244, "verified_objects": []}	{"frigate_instance_name": "البيت"}	2026-06-12 13:47:49.360797+00	2026-06-12 22:58:52.950885+00	1781237357.933508-wvps2z	f	\N	\N	\N
6e2d501e-e454-4ead-b23f-d001cb7a0fca	1781234666.963529-5aybm1	48c9e5dc-6641-4331-91a0-44a1cede5152	cam_01	2026-06-12 03:24:26.963+00	2026-06-12 03:24:34.826+00	alert	f	{"audio": [], "zones": [], "objects": ["person"], "metadata": null, "detections": ["1781234665.291284-59kxwf"], "sub_labels": [], "thumb_time": 1781234667.916415, "verified_objects": []}	{"frigate_instance_name": "البيت"}	2026-06-12 13:47:49.375605+00	2026-06-12 22:58:52.950885+00	1781234666.963529-5aybm1	f	\N	\N	\N
7e7edaa7-2fd0-4fa3-8ed5-ba7b1a7c4b92	1781240629.572599-1q4npt	48c9e5dc-6641-4331-91a0-44a1cede5152	cam_01	2026-06-12 05:03:49.572+00	2026-06-12 05:03:55.731+00	alert	f	{"audio": [], "zones": [], "objects": ["person"], "metadata": null, "detections": ["1781240628.796437-ldrb6s"], "sub_labels": [], "thumb_time": 1781240630.76138, "verified_objects": []}	{"frigate_instance_name": "البيت"}	2026-06-12 13:47:49.288156+00	2026-06-12 22:58:52.950885+00	1781240629.572599-1q4npt	f	\N	\N	\N
e4aca7f7-36d4-4a09-8553-44692d316684	1781240119.260273-ia3nh6	48c9e5dc-6641-4331-91a0-44a1cede5152	cam_01	2026-06-12 04:55:19.26+00	2026-06-12 04:55:20.755+00	alert	f	{"audio": [], "zones": [], "objects": ["person"], "metadata": null, "detections": ["1781240117.083836-qg3fny"], "sub_labels": [], "thumb_time": 1781240120.183913, "verified_objects": []}	{"frigate_instance_name": "البيت"}	2026-06-12 13:47:49.301949+00	2026-06-12 22:58:52.950885+00	1781240119.260273-ia3nh6	f	\N	\N	\N
fb899a2a-5df7-4814-87eb-79b231014fb0	1781239759.885283-5kmphe	48c9e5dc-6641-4331-91a0-44a1cede5152	cam_01	2026-06-12 04:49:19.885+00	2026-06-12 04:49:23.017+00	alert	f	{"audio": [], "zones": [], "objects": ["person"], "metadata": null, "detections": ["1781239759.092644-dbf9um"], "sub_labels": [], "thumb_time": 1781239760.853935, "verified_objects": []}	{"frigate_instance_name": "البيت"}	2026-06-12 13:47:49.313145+00	2026-06-12 22:58:52.950885+00	1781239759.885283-5kmphe	f	\N	\N	\N
f5572fc7-a5dd-4982-8c53-3ff3b625e432	1781239007.666238-tek2jr	48c9e5dc-6641-4331-91a0-44a1cede5152	cam_01	2026-06-12 04:36:47.666+00	2026-06-12 04:36:51.13+00	alert	f	{"audio": [], "zones": [], "objects": ["person"], "metadata": null, "detections": ["1781239005.101794-2oer43"], "sub_labels": [], "thumb_time": 1781239008.823797, "verified_objects": []}	{"frigate_instance_name": "البيت"}	2026-06-12 13:47:49.325968+00	2026-06-12 22:58:52.950885+00	1781239007.666238-tek2jr	f	\N	\N	\N
d7e0c9db-db48-43ef-98c3-8442fb3a653d	1781238680.570951-x5a1kq	48c9e5dc-6641-4331-91a0-44a1cede5152	cam_01	2026-06-12 04:31:20.57+00	2026-06-12 04:31:22.337+00	alert	f	{"audio": [], "zones": [], "objects": ["person"], "metadata": null, "detections": ["1781238678.74539-nuzjq8"], "sub_labels": [], "thumb_time": 1781238681.636394, "verified_objects": []}	{"frigate_instance_name": "البيت"}	2026-06-12 13:47:49.339172+00	2026-06-12 22:58:52.950885+00	1781238680.570951-x5a1kq	f	\N	\N	\N
582a2605-4b3f-4e1d-9137-dbb702517ab9	1781238164.08232-vpqcso	48c9e5dc-6641-4331-91a0-44a1cede5152	cam_01	2026-06-12 04:22:44.082+00	2026-06-12 04:23:09.487+00	alert	f	{"audio": [], "zones": [], "objects": ["person"], "metadata": null, "detections": ["1781238185.447802-gr3htp", "1781238163.227087-6kbu7w"], "sub_labels": [], "thumb_time": 1781238165.069371, "verified_objects": []}	{"frigate_instance_name": "البيت"}	2026-06-12 13:47:49.351875+00	2026-06-12 22:58:52.950885+00	1781238164.08232-vpqcso	f	\N	\N	\N
fac9738c-dca3-4ec1-852d-98ec9517f83b	1781235403.394608-6buolo	48c9e5dc-6641-4331-91a0-44a1cede5152	cam_01	2026-06-12 03:36:43.394+00	2026-06-12 03:36:56.336+00	alert	f	{"audio": [], "zones": [], "objects": ["person"], "metadata": null, "detections": ["1781235398.889411-z58rr5"], "sub_labels": [], "thumb_time": 1781235404.551273, "verified_objects": []}	{"frigate_instance_name": "البيت"}	2026-06-12 13:47:49.365933+00	2026-06-12 22:58:52.950885+00	1781235403.394608-6buolo	f	\N	\N	\N
27c0bc96-1135-461b-a163-f95f1a213af3	1781276009.089473-6p9n6c	48c9e5dc-6641-4331-91a0-44a1cede5152	cam_01	2026-06-12 14:53:29.089+00	2026-06-12 14:55:59.101+00	alert	f	{"audio": [], "zones": [], "objects": ["person"], "metadata": null, "detections": ["1781276057.453407-kfxyov", "1781275989.666883-8l1yjl", "1781276057.453407-wcia6z", "1781276025.151148-ykai8c", "1781276039.791717-ahyqwf"], "sub_labels": [], "thumb_time": 1781276109.738786, "verified_objects": []}	{"frigate_instance_name": "البيت"}	2026-06-12 15:55:40.407105+00	2026-06-12 22:58:52.950885+00	1781276009.089473-6p9n6c	f	\N	\N	\N
6029c52e-8fca-4705-b2b2-6f1899307f96	1781275726.229613-d4ao6f	48c9e5dc-6641-4331-91a0-44a1cede5152	cam_01	2026-06-12 14:48:46.229+00	2026-06-12 14:49:20.914+00	alert	f	{"audio": [], "zones": [], "objects": ["person"], "metadata": null, "detections": ["1781275708.02731-pidtxe"], "sub_labels": [], "thumb_time": 1781275742.494788, "verified_objects": []}	{"frigate_instance_name": "البيت"}	2026-06-12 15:55:40.422843+00	2026-06-12 22:58:52.950885+00	1781275726.229613-d4ao6f	f	\N	\N	\N
de9825cb-2d93-43f0-a483-e42e1747d7a5	1781274756.246632-eowppe	48c9e5dc-6641-4331-91a0-44a1cede5152	cam_01	2026-06-12 14:32:36.246+00	2026-06-12 14:33:23.944+00	alert	f	{"audio": [], "zones": [], "objects": ["person"], "metadata": null, "detections": ["1781274126.076266-yvj7uj"], "sub_labels": [], "thumb_time": 1781274773.820752, "verified_objects": []}	{"frigate_instance_name": "البيت"}	2026-06-12 15:55:40.436827+00	2026-06-12 22:58:52.950885+00	1781274756.246632-eowppe	f	\N	\N	\N
2c061f37-15a9-47fc-9776-3b9133a05e1f	1781274091.2977-hcif1x	48c9e5dc-6641-4331-91a0-44a1cede5152	cam_01	2026-06-12 14:21:31.297+00	2026-06-12 14:30:56.853+00	alert	f	{"audio": [], "zones": [], "objects": ["person"], "metadata": null, "detections": ["1781274126.076266-5hab8g", "1781274499.035453-i4gcpj", "1781274108.570438-xzdfau", "1781274075.295205-jbe07x", "1781274289.893263-13ivmv", "1781274176.400744-6xqy4h", "1781274126.076266-yvj7uj", "1781274401.080747-gbz064", "1781274191.605225-t0no3k"], "sub_labels": [], "thumb_time": 1781274306.818986, "verified_objects": []}	{"frigate_instance_name": "البيت"}	2026-06-12 15:55:40.45017+00	2026-06-12 22:58:52.950885+00	1781274091.2977-hcif1x	f	\N	\N	\N
49d4d624-9ae8-4f89-8875-44b820ca752d	1781273319.350807-0x2ddy	48c9e5dc-6641-4331-91a0-44a1cede5152	cam_01	2026-06-12 14:08:39.35+00	2026-06-12 14:10:34.405+00	alert	f	{"audio": [], "zones": [], "objects": ["person"], "metadata": null, "detections": ["1781273379.633644-vskv1e", "1781273303.873831-7mrzva", "1781273379.633644-nytcj7"], "sub_labels": [], "thumb_time": 1781273436.671151, "verified_objects": []}	{"frigate_instance_name": "البيت"}	2026-06-12 15:55:40.462705+00	2026-06-12 22:58:52.950885+00	1781273319.350807-0x2ddy	f	\N	\N	\N
a5d3fc0b-22b1-499d-9068-395212032e66	1781272689.595652-09vrco	48c9e5dc-6641-4331-91a0-44a1cede5152	cam_01	2026-06-12 13:58:09.595+00	2026-06-12 14:00:41.493+00	alert	f	{"audio": [], "zones": [], "objects": ["person"], "metadata": null, "detections": ["1781272710.541792-k1dt61", "1781272676.181299-31qev8", "1781272776.679472-9szsmj", "1781272776.679472-g9kbjn"], "sub_labels": [], "thumb_time": 1781272824.882115, "verified_objects": []}	{"frigate_instance_name": "البيت"}	2026-06-12 15:55:40.476214+00	2026-06-12 22:58:52.950885+00	1781272689.595652-09vrco	f	\N	\N	\N
4349ff4a-d622-490c-895d-e739082e1897	1781272233.56226-dam00j	48c9e5dc-6641-4331-91a0-44a1cede5152	cam_01	2026-06-12 13:50:33.562+00	2026-06-12 13:50:33.562+00	alert	t	{"audio": [], "zones": [], "objects": ["person"], "metadata": null, "detections": ["1781272213.174633-6jb3fn"], "sub_labels": [], "thumb_time": 1781272251.957271, "verified_objects": []}	{"frigate_instance_name": "البيت"}	2026-06-12 15:55:40.487785+00	2026-06-12 22:58:52.950885+00	1781272233.56226-dam00j	f	\N	\N	\N
63bb558a-0466-4b90-90e5-dd2a6dd1f8df	1781275977.061705-0rjt3d	48c9e5dc-6641-4331-91a0-44a1cede5152	cam_03	2026-06-12 14:52:57.061+00	2026-06-12 14:56:06.132+00	alert	f	{"audio": [], "zones": [], "objects": ["car"], "metadata": null, "detections": ["1781274362.932263-n2zdb6"], "sub_labels": [], "thumb_time": 1781275991.978709, "verified_objects": []}	{"frigate_instance_name": "البيت"}	2026-06-12 15:55:40.412469+00	2026-06-12 22:58:52.950885+00	1781275977.061705-0rjt3d	f	\N	\N	\N
632806cf-4dff-4933-8d36-c78fe0c13aca	1781275311.340154-t33z7v	48c9e5dc-6641-4331-91a0-44a1cede5152	cam_01	2026-06-12 14:41:51.34+00	2026-06-12 14:41:51.34+00	alert	f	{"audio": [], "zones": [], "objects": ["person"], "metadata": null, "detections": ["1781275296.553436-5eamuu"], "sub_labels": [], "thumb_time": 1781275326.801399, "verified_objects": []}	{"frigate_instance_name": "البيت"}	2026-06-12 15:55:40.427706+00	2026-06-12 22:58:52.950885+00	1781275311.340154-t33z7v	f	\N	\N	\N
3cc9c9d6-d2c8-47e2-804b-72e73741653a	1781274225.506631-2ecb4w	48c9e5dc-6641-4331-91a0-44a1cede5152	cam_03	2026-06-12 14:23:45.506+00	2026-06-12 14:23:45.506+00	alert	f	{"audio": [], "zones": [], "objects": ["car"], "metadata": null, "detections": ["1781273642.547439-4aonow"], "sub_labels": [], "thumb_time": 1781274239.989805, "verified_objects": []}	{"frigate_instance_name": "البيت"}	2026-06-12 15:55:40.442089+00	2026-06-12 22:58:52.950885+00	1781274225.506631-2ecb4w	f	\N	\N	\N
b50ed65c-2fa8-4716-9a48-1e092123cb7c	1781273539.611293-m9iw3e	48c9e5dc-6641-4331-91a0-44a1cede5152	cam_01	2026-06-12 14:12:19.611+00	2026-06-12 14:12:53.12+00	alert	f	{"audio": [], "zones": [], "objects": ["person"], "metadata": null, "detections": ["1781273524.192637-719ojj"], "sub_labels": [], "thumb_time": 1781273556.93119, "verified_objects": []}	{"frigate_instance_name": "البيت"}	2026-06-12 15:55:40.453573+00	2026-06-12 22:58:52.950885+00	1781273539.611293-m9iw3e	f	\N	\N	\N
9cc4f02d-750e-48f5-8e9b-415f29c6b38b	1781272931.484596-e5dx63	48c9e5dc-6641-4331-91a0-44a1cede5152	cam_01	2026-06-12 14:02:11.484+00	2026-06-12 14:02:11.484+00	alert	f	{"audio": [], "zones": [], "objects": ["person"], "metadata": null, "detections": ["1781272916.014373-bb44co"], "sub_labels": [], "thumb_time": 1781272950.904568, "verified_objects": []}	{"frigate_instance_name": "البيت"}	2026-06-12 15:55:40.466407+00	2026-06-12 22:58:52.950885+00	1781272931.484596-e5dx63	f	\N	\N	\N
3443b84f-5df2-4f65-8390-e72d14915d32	1781272585.312307-be612o	48c9e5dc-6641-4331-91a0-44a1cede5152	cam_01	2026-06-12 13:56:25.312+00	2026-06-12 13:56:25.312+00	alert	t	{"audio": [], "zones": [], "objects": ["person"], "metadata": null, "detections": ["1781272566.824176-kawe54"], "sub_labels": [], "thumb_time": 1781272607.232092, "verified_objects": []}	{"frigate_instance_name": "البيت"}	2026-06-12 15:55:40.480262+00	2026-06-12 22:58:52.950885+00	1781272585.312307-be612o	f	\N	\N	\N
7eff0eaf-3bad-40c9-9844-a96c191ad007	1781272164.617912-9b4fhz	48c9e5dc-6641-4331-91a0-44a1cede5152	cam_01	2026-06-12 13:49:24.617+00	2026-06-12 13:49:24.617+00	alert	f	{"audio": [], "zones": [], "objects": ["person"], "metadata": null, "detections": ["1781272146.029655-r5ivor"], "sub_labels": [], "thumb_time": 1781272180.024774, "verified_objects": []}	{"frigate_instance_name": "البيت"}	2026-06-12 15:55:40.493557+00	2026-06-12 22:58:52.950885+00	1781272164.617912-9b4fhz	f	\N	\N	\N
353ad0e2-a514-4773-9e34-65747a01eaed	1781280079.78228-isi3e7	48c9e5dc-6641-4331-91a0-44a1cede5152	cam_01	2026-06-12 16:01:19.782+00	2026-06-12 16:01:50.086+00	alert	f	{"audio": [], "zones": [], "objects": ["person"], "metadata": null, "detections": ["1781280063.851212-uenj61"], "sub_labels": [], "thumb_time": 1781280093.461073, "verified_objects": []}	{"frigate_instance_name": "البيت"}	2026-06-12 22:39:35.104095+00	2026-06-12 22:58:52.950885+00	1781280079.78228-isi3e7	f	\N	\N	\N
dbfdc750-0cd4-4fc9-a7ad-6868447db108	1781279923.195801-ue3ewj	48c9e5dc-6641-4331-91a0-44a1cede5152	cam_01	2026-06-12 15:58:43.195+00	2026-06-12 15:58:43.195+00	alert	f	{"audio": [], "zones": [], "objects": ["person"], "metadata": null, "detections": ["1781279909.992091-n0k4lm"], "sub_labels": [], "thumb_time": 1781279936.946834, "verified_objects": []}	{"frigate_instance_name": "البيت"}	2026-06-12 22:39:35.210603+00	2026-06-12 22:58:52.950885+00	1781279923.195801-ue3ewj	f	\N	\N	\N
bc7bc1b6-3e0e-493d-8ebe-7dbb9844dd5c	1781272017.444417-cfk6ky	48c9e5dc-6641-4331-91a0-44a1cede5152	cam_02	2026-06-12 13:46:57.444+00	1970-01-01 00:00:00+00	alert	f	{"audio": [], "zones": [], "objects": ["person"], "metadata": null, "detections": ["1781272010.251485-x8afqb"], "sub_labels": [], "thumb_time": 1781272023.406902, "verified_objects": []}	{"frigate_instance_name": "البيت"}	2026-06-12 13:47:48.502245+00	2026-06-12 22:58:52.950885+00	1781272017.444417-cfk6ky	f	\N	\N	\N
5abdaee4-dc8c-47c3-83b5-38249200643f	1781272005.003622-n7cj9l	48c9e5dc-6641-4331-91a0-44a1cede5152	cam_03	2026-06-12 13:46:45.003+00	1970-01-01 00:00:00+00	alert	f	{"audio": [], "zones": [], "objects": ["car"], "metadata": null, "detections": ["1781269841.005283-yf5nxb"], "sub_labels": [], "thumb_time": 1781272014.316641, "verified_objects": []}	{"frigate_instance_name": "البيت"}	2026-06-12 13:47:48.510006+00	2026-06-12 22:58:52.950885+00	1781272005.003622-n7cj9l	f	\N	\N	\N
2284b0b9-1049-4ded-bf7a-6feac6c18fcf	1781271939.86657-9eqoma	48c9e5dc-6641-4331-91a0-44a1cede5152	cam_02	2026-06-12 13:45:39.866+00	2026-06-12 13:45:39.866+00	alert	f	{"audio": [], "zones": [], "objects": ["person"], "metadata": null, "detections": ["1781271934.850292-34w574"], "sub_labels": [], "thumb_time": 1781271946.132539, "verified_objects": []}	{"frigate_instance_name": "البيت"}	2026-06-12 13:47:48.517008+00	2026-06-12 22:58:52.950885+00	1781271939.86657-9eqoma	f	\N	\N	\N
a41e41d8-72fd-40d2-b1f3-11171d0edf37	1781271917.910712-dx5cks	48c9e5dc-6641-4331-91a0-44a1cede5152	cam_01	2026-06-12 13:45:17.91+00	1970-01-01 00:00:00+00	alert	f	{"audio": [], "zones": [], "objects": ["person"], "metadata": null, "detections": ["1781271849.537276-eaid6o"], "sub_labels": [], "thumb_time": 1781271938.304749, "verified_objects": []}	{"frigate_instance_name": "البيت"}	2026-06-12 13:47:48.524029+00	2026-06-12 22:58:52.950885+00	1781271917.910712-dx5cks	f	\N	\N	\N
c9c26b98-883b-428e-8c96-9e9e4534c3a7	1781271660.13578-qjtwbm	48c9e5dc-6641-4331-91a0-44a1cede5152	cam_02	2026-06-12 13:41:00.135+00	2026-06-12 13:44:42.448+00	alert	f	{"audio": [], "zones": [], "objects": ["person"], "metadata": null, "detections": ["1781271654.635747-mjrhbx", "1781271642.07746-cfnec7"], "sub_labels": [], "thumb_time": 1781271755.711341, "verified_objects": []}	{"frigate_instance_name": "البيت"}	2026-06-12 13:47:48.531314+00	2026-06-12 22:58:52.950885+00	1781271660.13578-qjtwbm	f	\N	\N	\N
03e0abaf-2b4a-4faa-9f3d-24dcec725a6d	1781271304.927782-q9m06j	48c9e5dc-6641-4331-91a0-44a1cede5152	cam_01	2026-06-12 13:35:04.927+00	2026-06-12 13:37:23.347+00	alert	f	{"audio": [], "zones": [], "objects": ["person"], "metadata": null, "detections": ["1781271288.026642-zpt89i"], "sub_labels": [], "thumb_time": 1781271327.787664, "verified_objects": []}	{"frigate_instance_name": "البيت"}	2026-06-12 13:47:48.537081+00	2026-06-12 22:58:52.950885+00	1781271304.927782-q9m06j	f	\N	\N	\N
b8fc24d6-b6d9-4db7-91b7-c4bc05540eec	1781271271.205285-odc8bu	48c9e5dc-6641-4331-91a0-44a1cede5152	cam_02	2026-06-12 13:34:31.205+00	2026-06-12 13:39:58.069+00	alert	f	{"audio": [], "zones": [], "objects": ["car", "person"], "metadata": null, "detections": ["1781271260.680384-56baza", "1781271307.712221-yoh6qz", "1781271454.341685-8yfp8c", "1781271375.729684-olazm7", "1781271464.968753-e52ksd"], "sub_labels": [], "thumb_time": 1781271487.782338, "verified_objects": []}	{"frigate_instance_name": "البيت"}	2026-06-12 13:47:48.54389+00	2026-06-12 22:58:52.950885+00	1781271271.205285-odc8bu	f	\N	\N	\N
ccbf1293-d79a-4fc3-b7dc-98bcad479aea	1781271133.720057-4chcwd	48c9e5dc-6641-4331-91a0-44a1cede5152	cam_01	2026-06-12 13:32:13.72+00	2026-06-12 13:32:48.044+00	alert	f	{"audio": [], "zones": [], "objects": ["person"], "metadata": null, "detections": ["1781271115.889339-sfg7ba", "1781271153.313309-dnbfks"], "sub_labels": [], "thumb_time": 1781271155.617863, "verified_objects": []}	{"frigate_instance_name": "البيت"}	2026-06-12 13:47:48.550738+00	2026-06-12 22:58:52.950885+00	1781271133.720057-4chcwd	f	\N	\N	\N
988ed8fc-8d0a-46c3-9e04-3366a85aac24	1781270709.724329-r3hg8v	48c9e5dc-6641-4331-91a0-44a1cede5152	cam_02	2026-06-12 13:25:09.724+00	2026-06-12 13:33:03.871+00	alert	f	{"audio": [], "zones": [], "objects": ["person"], "metadata": null, "detections": ["1781271094.053304-3xyxep", "1781270357.432635-z37zrm", "1781270703.801173-ydxvhy", "1781270955.565486-hxwv39", "1781270709.724329-c36mux", "1781271094.053304-o6mcj3"], "sub_labels": [], "thumb_time": 1781270993.80821, "verified_objects": []}	{"frigate_instance_name": "البيت"}	2026-06-12 13:47:48.557885+00	2026-06-12 22:58:52.950885+00	1781270709.724329-r3hg8v	f	\N	\N	\N
efbb40af-a048-4559-85eb-e454193aae65	1781270362.552445-zzyt5c	48c9e5dc-6641-4331-91a0-44a1cede5152	cam_02	2026-06-12 13:19:22.552+00	2026-06-12 13:24:20.875+00	alert	f	{"audio": [], "zones": [], "objects": ["person"], "metadata": null, "detections": ["1781270634.037619-yp175l", "1781270347.134718-4gf7pk", "1781270357.432635-z37zrm", "1781270628.492811-5qstqe", "1781270542.445749-ypwlyx"], "sub_labels": [], "thumb_time": 1781270378.107027, "verified_objects": []}	{"frigate_instance_name": "البيت"}	2026-06-12 13:47:48.564263+00	2026-06-12 22:58:52.950885+00	1781270362.552445-zzyt5c	f	\N	\N	\N
1e4886cd-8c99-4ecf-a475-4c2d8108c052	1781270330.494447-48xctv	48c9e5dc-6641-4331-91a0-44a1cede5152	cam_01	2026-06-12 13:18:50.494+00	2026-06-12 13:28:24.125+00	alert	f	{"audio": [], "zones": [], "objects": ["person"], "metadata": null, "detections": ["1781270847.780642-qmmxl0", "1781270173.983278-w456xh"], "sub_labels": [], "thumb_time": 1781270885.442827, "verified_objects": []}	{"frigate_instance_name": "البيت"}	2026-06-12 13:47:48.569598+00	2026-06-12 22:58:52.950885+00	1781270330.494447-48xctv	f	\N	\N	\N
e5f6eca7-c28b-40bb-a0aa-bb52bb2cd6b9	1781270050.153321-6er9mb	48c9e5dc-6641-4331-91a0-44a1cede5152	cam_01	2026-06-12 13:14:10.153+00	2026-06-12 13:14:10.153+00	alert	f	{"audio": [], "zones": [], "objects": ["person"], "metadata": null, "detections": ["1781270032.376323-sn7oy0"], "sub_labels": [], "thumb_time": 1781270072.23976, "verified_objects": []}	{"frigate_instance_name": "البيت"}	2026-06-12 13:47:48.574258+00	2026-06-12 22:58:52.950885+00	1781270050.153321-6er9mb	f	\N	\N	\N
a6327703-0828-45c1-ae03-955000a5ccc5	1781269899.663957-udvch3	48c9e5dc-6641-4331-91a0-44a1cede5152	cam_01	2026-06-12 13:11:39.663+00	2026-06-12 13:11:39.663+00	alert	t	{"audio": [], "zones": [], "objects": ["person"], "metadata": null, "detections": ["1781269864.119189-e2ihoo"], "sub_labels": [], "thumb_time": 1781269920.978746, "verified_objects": []}	{"frigate_instance_name": "البيت"}	2026-06-12 13:47:48.581421+00	2026-06-12 22:58:52.950885+00	1781269899.663957-udvch3	f	\N	\N	\N
d0882f3b-0860-44dc-87be-da4cfe1e4667	1781269650.866164-jtshij	48c9e5dc-6641-4331-91a0-44a1cede5152	cam_01	2026-06-12 13:07:30.866+00	2026-06-12 13:07:44.306+00	alert	f	{"audio": [], "zones": [], "objects": ["person"], "metadata": null, "detections": ["1781268746.06574-oet1f4"], "sub_labels": [], "thumb_time": 1781269665.928806, "verified_objects": []}	{"frigate_instance_name": "البيت"}	2026-06-12 13:47:48.599444+00	2026-06-12 22:58:52.950885+00	1781269650.866164-jtshij	f	\N	\N	\N
f213ef47-03ea-4bda-bf01-04ea461c1abe	1781269572.313395-sppegh	48c9e5dc-6641-4331-91a0-44a1cede5152	cam_01	2026-06-12 13:06:12.313+00	2026-06-12 13:06:28.169+00	alert	f	{"audio": [], "zones": [], "objects": ["person"], "metadata": null, "detections": ["1781268746.06574-oet1f4"], "sub_labels": [], "thumb_time": 1781269589.757762, "verified_objects": []}	{"frigate_instance_name": "البيت"}	2026-06-12 13:47:48.604681+00	2026-06-12 22:58:52.950885+00	1781269572.313395-sppegh	f	\N	\N	\N
e7385c4e-d235-4dbe-a13f-1d50d97ae060	1781269271.177054-af77o9	48c9e5dc-6641-4331-91a0-44a1cede5152	cam_01	2026-06-12 13:01:11.177+00	2026-06-12 13:01:44.35+00	alert	f	{"audio": [], "zones": [], "objects": ["person"], "metadata": null, "detections": ["1781267928.004736-mczeht"], "sub_labels": [], "thumb_time": 1781269291.871417, "verified_objects": []}	{"frigate_instance_name": "البيت"}	2026-06-12 13:47:48.610993+00	2026-06-12 22:58:52.950885+00	1781269271.177054-af77o9	f	\N	\N	\N
fef963d6-12d7-407a-84a6-32021920df36	1781269119.908789-ue9p6w	48c9e5dc-6641-4331-91a0-44a1cede5152	cam_02	2026-06-12 12:58:39.908+00	2026-06-12 13:04:23.605+00	alert	f	{"audio": [], "zones": [], "objects": ["person"], "metadata": null, "detections": ["1781269291.588316-j4pidd", "1781269108.056073-tubrlm", "1781269139.906306-c88jg4"], "sub_labels": [], "thumb_time": 1781269301.90076, "verified_objects": []}	{"frigate_instance_name": "البيت"}	2026-06-12 13:47:48.618931+00	2026-06-12 22:58:52.950885+00	1781269119.908789-ue9p6w	f	\N	\N	\N
c5560853-ce38-4211-ad1c-03aafc8f4e41	1781268886.056416-jra55d	48c9e5dc-6641-4331-91a0-44a1cede5152	cam_02	2026-06-12 12:54:46.056+00	2026-06-12 12:54:46.056+00	alert	f	{"audio": [], "zones": [], "objects": ["person"], "metadata": null, "detections": ["1781267784.714147-1vdijb"], "sub_labels": [], "thumb_time": 1781268907.079331, "verified_objects": []}	{"frigate_instance_name": "البيت"}	2026-06-12 13:47:48.625281+00	2026-06-12 22:58:52.950885+00	1781268886.056416-jra55d	f	\N	\N	\N
1c2fa71a-3ad6-4074-9b45-b8e80b5057c6	1781268299.637537-v8blue	48c9e5dc-6641-4331-91a0-44a1cede5152	cam_03	2026-06-12 12:44:59.637+00	2026-06-12 12:45:55.47+00	alert	f	{"audio": [], "zones": [], "objects": ["car"], "metadata": null, "detections": ["1781268275.932542-q5o9xs"], "sub_labels": [], "thumb_time": 1781268331.175349, "verified_objects": []}	{"frigate_instance_name": "البيت"}	2026-06-12 13:47:48.631271+00	2026-06-12 22:58:52.950885+00	1781268299.637537-v8blue	f	\N	\N	\N
a2728391-78e1-4858-b663-8983246105a8	1781267398.996241-acwc7i	48c9e5dc-6641-4331-91a0-44a1cede5152	cam_02	2026-06-12 12:29:58.996+00	2026-06-12 12:50:33.481+00	alert	f	{"audio": [], "zones": [], "objects": ["person"], "metadata": null, "detections": ["1781267363.036699-pn4yvw", "1781267602.093232-9o8fks", "1781267458.917116-4uatf2", "1781267784.714147-1vdijb"], "sub_labels": [], "thumb_time": 1781267617.376348, "verified_objects": []}	{"frigate_instance_name": "البيت"}	2026-06-12 13:47:48.637186+00	2026-06-12 22:58:52.950885+00	1781267398.996241-acwc7i	f	\N	\N	\N
1404ebb0-cc07-4e27-994c-59fe71b2b379	1781266931.274444-u430k2	48c9e5dc-6641-4331-91a0-44a1cede5152	cam_02	2026-06-12 12:22:11.274+00	2026-06-12 12:23:59.306+00	alert	f	{"audio": [], "zones": [], "objects": ["person"], "metadata": null, "detections": ["1781266925.129078-s9xcv0"], "sub_labels": [], "thumb_time": 1781266938.297551, "verified_objects": []}	{"frigate_instance_name": "البيت"}	2026-06-12 13:47:48.655722+00	2026-06-12 22:58:52.950885+00	1781266931.274444-u430k2	f	\N	\N	\N
ca8750ea-78e3-4c7e-9377-8c9be08c8043	1781266280.335589-eaen3p	48c9e5dc-6641-4331-91a0-44a1cede5152	cam_02	2026-06-12 12:11:20.335+00	2026-06-12 12:12:11.755+00	alert	f	{"audio": [], "zones": [], "objects": ["person"], "metadata": null, "detections": ["1781266274.68105-vggqoe"], "sub_labels": [], "thumb_time": 1781266286.337577, "verified_objects": []}	{"frigate_instance_name": "البيت"}	2026-06-12 13:47:48.675163+00	2026-06-12 22:58:52.950885+00	1781266280.335589-eaen3p	f	\N	\N	\N
916934be-1d04-440b-835f-66098f7429c3	1781264690.377678-9fg8v4	48c9e5dc-6641-4331-91a0-44a1cede5152	cam_02	2026-06-12 11:44:50.377+00	2026-06-12 11:48:55.393+00	alert	f	{"audio": [], "zones": [], "objects": ["car", "person"], "metadata": null, "detections": ["1781264675.037557-o245a6", "1781264877.93982-5mhz7k", "1781263778.278211-wt2ibv"], "sub_labels": [], "thumb_time": 1781264913.536788, "verified_objects": []}	{"frigate_instance_name": "البيت"}	2026-06-12 13:47:48.696712+00	2026-06-12 22:58:52.950885+00	1781264690.377678-9fg8v4	f	\N	\N	\N
cc85c05d-622e-4fa7-a8dc-153b7482ab1f	1781263139.821315-bzf2sa	48c9e5dc-6641-4331-91a0-44a1cede5152	cam_01	2026-06-12 11:18:59.821+00	2026-06-12 11:57:59.367+00	alert	f	{"audio": [], "zones": [], "objects": ["person"], "metadata": null, "detections": ["1781263319.138303-ht6dj8", "1781263894.231084-ln471d", "1781261537.89834-m3ny6q", "1781263658.501477-3nqcdb", "1781263001.109251-cva21k", "1781264411.34326-pwn5v2"], "sub_labels": [], "thumb_time": 1781263932.743647, "verified_objects": []}	{"frigate_instance_name": "البيت"}	2026-06-12 13:47:48.715168+00	2026-06-12 22:58:52.950885+00	1781263139.821315-bzf2sa	f	\N	\N	\N
1451abf1-6ba4-4824-b214-21d2a974e3d6	1781261428.995725-o5pjqj	48c9e5dc-6641-4331-91a0-44a1cede5152	cam_01	2026-06-12 10:50:28.995+00	2026-06-12 10:55:41.439+00	alert	f	{"audio": [], "zones": [], "objects": ["person"], "metadata": null, "detections": ["1781261017.96685-x12du8"], "sub_labels": [], "thumb_time": 1781261444.667165, "verified_objects": []}	{"frigate_instance_name": "البيت"}	2026-06-12 13:47:48.734274+00	2026-06-12 22:58:52.950885+00	1781261428.995725-o5pjqj	f	\N	\N	\N
da909807-b77e-4219-9d85-8a8bf240ce0d	1781260605.114808-gsusta	48c9e5dc-6641-4331-91a0-44a1cede5152	cam_03	2026-06-12 10:36:45.114+00	2026-06-12 10:36:46+00	alert	f	{"audio": [], "zones": [], "objects": ["on_demand"], "metadata": null, "detections": ["1781260605.114808-w6ct60"], "sub_labels": [], "thumb_time": null, "verified_objects": []}	{"frigate_instance_name": "البيت"}	2026-06-12 13:47:48.753698+00	2026-06-12 22:58:52.950885+00	1781260605.114808-gsusta	f	\N	\N	\N
5e955490-e3fc-4ec0-b52c-f0ee4b7d1315	1781259475.344544-0qcb2t	48c9e5dc-6641-4331-91a0-44a1cede5152	cam_02	2026-06-12 10:17:55.344+00	2026-06-12 10:18:40.756+00	alert	f	{"audio": [], "zones": [], "objects": ["person"], "metadata": null, "detections": ["1781259501.893075-2apbb0", "1781259472.241894-k1qvma"], "sub_labels": [], "thumb_time": 1781259508.105358, "verified_objects": []}	{"frigate_instance_name": "البيت"}	2026-06-12 13:47:48.774344+00	2026-06-12 22:58:52.950885+00	1781259475.344544-0qcb2t	f	\N	\N	\N
7b419faa-1178-4208-9499-697d6c8b7f40	1781259249.333596-1babph	48c9e5dc-6641-4331-91a0-44a1cede5152	cam_01	2026-06-12 10:14:09.333+00	2026-06-12 10:14:37.654+00	alert	f	{"audio": [], "zones": [], "objects": ["person"], "metadata": null, "detections": ["1781259247.163816-9ayw9f"], "sub_labels": [], "thumb_time": 1781259252.057376, "verified_objects": []}	{"frigate_instance_name": "البيت"}	2026-06-12 13:47:48.791591+00	2026-06-12 22:58:52.950885+00	1781259249.333596-1babph	f	\N	\N	\N
4e7d7eac-cada-47ca-a1b6-d3ee52960864	1781257972.21118-os1ba2	48c9e5dc-6641-4331-91a0-44a1cede5152	cam_01	2026-06-12 09:52:52.211+00	2026-06-12 09:53:18.656+00	alert	f	{"audio": [], "zones": [], "objects": ["person"], "metadata": null, "detections": ["1781257966.729757-vkytvn"], "sub_labels": [], "thumb_time": 1781257975.504961, "verified_objects": []}	{"frigate_instance_name": "البيت"}	2026-06-12 13:47:48.847539+00	2026-06-12 22:58:52.950885+00	1781257972.21118-os1ba2	f	\N	\N	\N
e49cdd57-d19b-4cee-b506-82913676a992	1781256989.858881-vsc6ki	48c9e5dc-6641-4331-91a0-44a1cede5152	cam_01	2026-06-12 09:36:29.858+00	2026-06-12 09:37:21.345+00	alert	f	{"audio": [], "zones": [], "objects": ["person"], "metadata": null, "detections": ["1781256943.410715-5s4tfa"], "sub_labels": [], "thumb_time": 1781256992.365706, "verified_objects": []}	{"frigate_instance_name": "البيت"}	2026-06-12 13:47:48.866986+00	2026-06-12 22:58:52.950885+00	1781256989.858881-vsc6ki	f	\N	\N	\N
36e31dcc-cf20-4b30-bb35-f9b484ca407e	1781256169.57086-st1uld	48c9e5dc-6641-4331-91a0-44a1cede5152	cam_01	2026-06-12 09:22:49.57+00	2026-06-12 09:24:04.58+00	alert	f	{"audio": [], "zones": [], "objects": ["person"], "metadata": null, "detections": ["1781256167.816755-a2qsx9"], "sub_labels": [], "thumb_time": 1781256171.45637, "verified_objects": []}	{"frigate_instance_name": "البيت"}	2026-06-12 13:47:48.912499+00	2026-06-12 22:58:52.950885+00	1781256169.57086-st1uld	f	\N	\N	\N
91ee3da8-4d06-48f5-a36a-ccc57efad278	1781255497.194604-5l0l7l	48c9e5dc-6641-4331-91a0-44a1cede5152	cam_02	2026-06-12 09:11:37.194+00	2026-06-12 09:14:38.866+00	alert	f	{"audio": [], "zones": [], "objects": ["person"], "metadata": null, "detections": ["1781255511.632661-3t5rei", "1781255494.164891-v7rv26"], "sub_labels": [], "thumb_time": 1781255522.173298, "verified_objects": []}	{"frigate_instance_name": "البيت"}	2026-06-12 13:47:48.929041+00	2026-06-12 22:58:52.950885+00	1781255497.194604-5l0l7l	f	\N	\N	\N
d6d7f670-2a0a-4997-9a3c-a1cd83f37124	1781254916.003842-dj28yf	48c9e5dc-6641-4331-91a0-44a1cede5152	cam_02	2026-06-12 09:01:56.003+00	2026-06-12 09:08:34.124+00	alert	f	{"audio": [], "zones": [], "objects": ["car", "person"], "metadata": null, "detections": ["1781255047.741745-2cb53d", "1781255266.699519-nlulsv", "1781255053.937083-hct0en", "1781255073.287584-o97yco", "1781254768.147506-7ospyx", "1781255157.693732-8iqtbl", "1781254913.349371-ctg5k4"], "sub_labels": [], "thumb_time": 1781255078.697877, "verified_objects": []}	{"frigate_instance_name": "البيت"}	2026-06-12 13:47:48.959731+00	2026-06-12 22:58:52.950885+00	1781254916.003842-dj28yf	f	\N	\N	\N
d53e673c-8acb-426c-ad90-fd1222a75c28	1781254608.879964-5r8g3b	48c9e5dc-6641-4331-91a0-44a1cede5152	cam_02	2026-06-12 08:56:48.879+00	2026-06-12 08:58:47.294+00	alert	f	{"audio": [], "zones": [], "objects": ["car", "person"], "metadata": null, "detections": ["1781254662.264815-rbfsmf", "1781254700.046212-raj1ls", "1781253843.518396-9q2mqi", "1781254581.347729-blcw9y"], "sub_labels": [], "thumb_time": 1781254612.145019, "verified_objects": []}	{"frigate_instance_name": "البيت"}	2026-06-12 13:47:48.974031+00	2026-06-12 22:58:52.950885+00	1781254608.879964-5r8g3b	f	\N	\N	\N
51cd6165-042e-4e08-8e6c-f5785d690778	1781254127.924625-90ppcb	48c9e5dc-6641-4331-91a0-44a1cede5152	cam_01	2026-06-12 08:48:47.924+00	2026-06-12 08:49:12.058+00	alert	f	{"audio": [], "zones": [], "objects": ["person"], "metadata": null, "detections": ["1781253925.651187-um1vpc"], "sub_labels": [], "thumb_time": 1781254130.159276, "verified_objects": []}	{"frigate_instance_name": "البيت"}	2026-06-12 13:47:48.988029+00	2026-06-12 22:58:52.950885+00	1781254127.924625-90ppcb	f	\N	\N	\N
31520baa-18cc-4fa6-9748-e87897f0f2d6	1781253207.728173-dm7vjg	48c9e5dc-6641-4331-91a0-44a1cede5152	cam_02	2026-06-12 08:33:27.728+00	2026-06-12 08:35:52.686+00	alert	f	{"audio": [], "zones": [], "objects": ["person"], "metadata": null, "detections": ["1781253201.000509-ahymjx"], "sub_labels": [], "thumb_time": 1781253211.073675, "verified_objects": []}	{"frigate_instance_name": "البيت"}	2026-06-12 13:47:49.001913+00	2026-06-12 22:58:52.950885+00	1781253207.728173-dm7vjg	f	\N	\N	\N
8aaef514-240b-4f01-bbee-a19ceb708a31	1781252536.124957-kaks6p	48c9e5dc-6641-4331-91a0-44a1cede5152	cam_01	2026-06-12 08:22:16.124+00	2026-06-12 08:25:48.819+00	alert	t	{"audio": [], "zones": [], "objects": ["person"], "metadata": null, "detections": ["1781252538.257328-pc36dl", "1781252430.875348-3qa7f3"], "sub_labels": [], "thumb_time": 1781252584.471684, "verified_objects": []}	{"frigate_instance_name": "البيت"}	2026-06-12 13:47:49.016717+00	2026-06-12 22:58:52.950885+00	1781252536.124957-kaks6p	f	\N	\N	\N
d26bfa62-45ec-4a68-b0b3-9842333613ef	1781267260.682754-dexn4c	48c9e5dc-6641-4331-91a0-44a1cede5152	cam_02	2026-06-12 12:27:40.682+00	2026-06-12 12:28:28.526+00	alert	f	{"audio": [], "zones": [], "objects": ["person"], "metadata": null, "detections": ["1781267255.141095-1j5z4x"], "sub_labels": [], "thumb_time": 1781267267.863914, "verified_objects": []}	{"frigate_instance_name": "البيت"}	2026-06-12 13:47:48.644695+00	2026-06-12 22:58:52.950885+00	1781267260.682754-dexn4c	f	\N	\N	\N
22b11a77-b5ea-4358-a49b-adf5b1c0f857	1781266667.125697-bfm0cx	48c9e5dc-6641-4331-91a0-44a1cede5152	cam_02	2026-06-12 12:17:47.125+00	2026-06-12 12:21:24.002+00	alert	f	{"audio": [], "zones": [], "objects": ["person"], "metadata": null, "detections": ["1781266826.883735-0y8434", "1781266660.664576-7fbgoo", "1781266728.876052-1bheyc", "1781266795.487627-3mktpy", "1781266728.876052-094ivi"], "sub_labels": [], "thumb_time": 1781266750.839793, "verified_objects": []}	{"frigate_instance_name": "البيت"}	2026-06-12 13:47:48.660841+00	2026-06-12 22:58:52.950885+00	1781266667.125697-bfm0cx	f	\N	\N	\N
6efda3b9-a4f9-489d-a9e6-c9e89f9a2bea	1781266184.375739-o9u3ct	48c9e5dc-6641-4331-91a0-44a1cede5152	cam_02	2026-06-12 12:09:44.375+00	2026-06-12 12:09:44.375+00	alert	f	{"audio": [], "zones": [], "objects": ["person"], "metadata": null, "detections": ["1781266177.797368-6xtfc8"], "sub_labels": [], "thumb_time": 1781266191.83092, "verified_objects": []}	{"frigate_instance_name": "البيت"}	2026-06-12 13:47:48.682218+00	2026-06-12 22:58:52.950885+00	1781266184.375739-o9u3ct	f	\N	\N	\N
022b74c1-09e7-43a4-8f0a-c27ca28f53ca	1781263963.537254-jxvemn	48c9e5dc-6641-4331-91a0-44a1cede5152	cam_02	2026-06-12 11:32:43.537+00	2026-06-12 11:43:46.822+00	alert	f	{"audio": [], "zones": [], "objects": ["person"], "metadata": null, "detections": ["1781263963.537254-ie2mck", "1781263758.952179-5di9ua", "1781263771.741272-7d5ydt"], "sub_labels": [], "thumb_time": 1781263979.619699, "verified_objects": []}	{"frigate_instance_name": "البيت"}	2026-06-12 13:47:48.70215+00	2026-06-12 22:58:52.950885+00	1781263963.537254-jxvemn	f	\N	\N	\N
ca9c3dc2-3d26-45f6-8649-fc516cce282b	1781261939.41026-syoslx	48c9e5dc-6641-4331-91a0-44a1cede5152	cam_02	2026-06-12 10:58:59.41+00	2026-06-12 11:15:33.375+00	alert	f	{"audio": [], "zones": [], "objects": ["person"], "metadata": null, "detections": ["1781261933.083645-huymba", "1781262346.509556-lq11bd", "1781262641.520408-g3gvw9", "1781262197.413401-p04njr", "1781262077.5205-gaqb44", "1781262005.470827-0fewcx", "1781261960.350314-4bqtyv"], "sub_labels": [], "thumb_time": 1781262271.305656, "verified_objects": []}	{"frigate_instance_name": "البيت"}	2026-06-12 13:47:48.722827+00	2026-06-12 22:58:52.950885+00	1781261939.41026-syoslx	f	\N	\N	\N
1885f8a4-fac5-4215-9534-701f00af9b7b	1781261188.26032-1rpq2i	48c9e5dc-6641-4331-91a0-44a1cede5152	cam_02	2026-06-12 10:46:28.26+00	2026-06-12 10:47:25.04+00	alert	f	{"audio": [], "zones": [], "objects": ["person"], "metadata": null, "detections": ["1781261181.276464-f8x501", "1781261201.158206-eswp11", "1781261188.26032-zx9mv9"], "sub_labels": [], "thumb_time": 1781261214.287723, "verified_objects": []}	{"frigate_instance_name": "البيت"}	2026-06-12 13:47:48.740323+00	2026-06-12 22:58:52.950885+00	1781261188.26032-1rpq2i	f	\N	\N	\N
8ce911aa-ce0d-4b1c-a0ef-a08918775752	1781260600.028358-3zqn6m	48c9e5dc-6641-4331-91a0-44a1cede5152	cam_02	2026-06-12 10:36:40.028+00	2026-06-12 10:40:21.943+00	alert	f	{"audio": [], "zones": [], "objects": ["on_demand"], "metadata": null, "detections": ["1781260600.028358-qoy5td"], "sub_labels": [], "thumb_time": null, "verified_objects": []}	{"frigate_instance_name": "البيت"}	2026-06-12 13:47:48.759743+00	2026-06-12 22:58:52.950885+00	1781260600.028358-3zqn6m	f	\N	\N	\N
b322311d-3651-439d-aca0-82418a2bcf12	1781259334.727607-7qiv4f	48c9e5dc-6641-4331-91a0-44a1cede5152	cam_01	2026-06-12 10:15:34.727+00	2026-06-12 10:24:44.931+00	alert	f	{"audio": [], "zones": [], "objects": ["person"], "metadata": null, "detections": ["1781259282.025006-ec2lmp"], "sub_labels": [], "thumb_time": 1781259336.913852, "verified_objects": []}	{"frigate_instance_name": "البيت"}	2026-06-12 13:47:48.780371+00	2026-06-12 22:58:52.950885+00	1781259334.727607-7qiv4f	f	\N	\N	\N
ece0e398-fcae-4af7-bdc3-5370085e5b49	1781259225.625009-lq287x	48c9e5dc-6641-4331-91a0-44a1cede5152	cam_02	2026-06-12 10:13:45.625+00	2026-06-12 10:13:54.515+00	alert	f	{"audio": [], "zones": [], "objects": ["person"], "metadata": null, "detections": ["1781259222.566959-bdv96l"], "sub_labels": [], "thumb_time": 1781259228.711809, "verified_objects": []}	{"frigate_instance_name": "البيت"}	2026-06-12 13:47:48.825095+00	2026-06-12 22:58:52.950885+00	1781259225.625009-lq287x	f	\N	\N	\N
83c48ea0-c854-4beb-98a9-727aece00828	1781257723.81729-s1bjsb	48c9e5dc-6641-4331-91a0-44a1cede5152	cam_02	2026-06-12 09:48:43.817+00	2026-06-12 09:48:46.88+00	alert	f	{"audio": [], "zones": [], "objects": ["person"], "metadata": null, "detections": ["1781257720.58663-dxbj4u"], "sub_labels": [], "thumb_time": 1781257727.016555, "verified_objects": []}	{"frigate_instance_name": "البيت"}	2026-06-12 13:47:48.853343+00	2026-06-12 22:58:52.950885+00	1781257723.81729-s1bjsb	f	\N	\N	\N
055a3404-a9c9-44ee-89d1-0eb1955ae926	1781256629.130647-9qvphi	48c9e5dc-6641-4331-91a0-44a1cede5152	cam_01	2026-06-12 09:30:29.13+00	2026-06-12 09:31:46.021+00	alert	f	{"audio": [], "zones": [], "objects": ["person"], "metadata": null, "detections": ["1781256627.131877-6ol028", "1781256663.316119-c7fatb"], "sub_labels": [], "thumb_time": 1781256631.540991, "verified_objects": []}	{"frigate_instance_name": "البيت"}	2026-06-12 13:47:48.902532+00	2026-06-12 22:58:52.950885+00	1781256629.130647-9qvphi	f	\N	\N	\N
b245374c-922b-4e07-b18a-0eda554bcfee	1781255906.864605-nb63ws	48c9e5dc-6641-4331-91a0-44a1cede5152	cam_01	2026-06-12 09:18:26.864+00	2026-06-12 09:20:18.826+00	alert	f	{"audio": [], "zones": [], "objects": ["person"], "metadata": null, "detections": ["1781255901.468023-tmiahw"], "sub_labels": [], "thumb_time": 1781255908.740361, "verified_objects": []}	{"frigate_instance_name": "البيت"}	2026-06-12 13:47:48.91769+00	2026-06-12 22:58:52.950885+00	1781255906.864605-nb63ws	f	\N	\N	\N
122c11e6-203f-4b0b-964a-1e37c1058875	1781255477.404682-p0erla	48c9e5dc-6641-4331-91a0-44a1cede5152	cam_01	2026-06-12 09:11:17.404+00	2026-06-12 09:11:46.144+00	alert	f	{"audio": [], "zones": [], "objects": ["person"], "metadata": null, "detections": ["1781254990.58065-b24sn8"], "sub_labels": [], "thumb_time": 1781255479.655698, "verified_objects": []}	{"frigate_instance_name": "البيت"}	2026-06-12 13:47:48.949332+00	2026-06-12 22:58:52.950885+00	1781255477.404682-p0erla	f	\N	\N	\N
3e801af4-25ab-48b1-96aa-01b27060d2d6	1781254770.97279-ddvjsh	48c9e5dc-6641-4331-91a0-44a1cede5152	cam_02	2026-06-12 08:59:30.972+00	2026-06-12 09:00:30.684+00	alert	f	{"audio": [], "zones": [], "objects": ["person"], "metadata": null, "detections": ["1781254768.147506-7dkzam"], "sub_labels": [], "thumb_time": 1781254774.75073, "verified_objects": []}	{"frigate_instance_name": "البيت"}	2026-06-12 13:47:48.964247+00	2026-06-12 22:58:52.950885+00	1781254770.97279-ddvjsh	f	\N	\N	\N
06786868-e7c0-42ce-ac95-c799d128a8a4	1781254513.134396-khcwkg	48c9e5dc-6641-4331-91a0-44a1cede5152	cam_02	2026-06-12 08:55:13.134+00	2026-06-12 08:55:24.15+00	alert	f	{"audio": [], "zones": [], "objects": ["person"], "metadata": null, "detections": ["1781254509.525613-2l2ha3"], "sub_labels": [], "thumb_time": 1781254517.007692, "verified_objects": []}	{"frigate_instance_name": "البيت"}	2026-06-12 13:47:48.978139+00	2026-06-12 22:58:52.950885+00	1781254513.134396-khcwkg	f	\N	\N	\N
316fc5f6-8ee4-43e6-8c7c-eb047b5fbd78	1781253891.490251-1n0hh8	48c9e5dc-6641-4331-91a0-44a1cede5152	cam_02	2026-06-12 08:44:51.49+00	2026-06-12 08:45:51.919+00	alert	f	{"audio": [], "zones": [], "objects": ["person"], "metadata": null, "detections": ["1781253878.937472-o4hy33"], "sub_labels": [], "thumb_time": 1781253894.717721, "verified_objects": []}	{"frigate_instance_name": "البيت"}	2026-06-12 13:47:48.992481+00	2026-06-12 22:58:52.950885+00	1781253891.490251-1n0hh8	f	\N	\N	\N
befd1412-db99-404d-b67a-d7fff70682f9	1781252881.416414-6n4e4x	48c9e5dc-6641-4331-91a0-44a1cede5152	cam_02	2026-06-12 08:28:01.416+00	2026-06-12 08:28:08.535+00	alert	f	{"audio": [], "zones": [], "objects": ["person"], "metadata": null, "detections": ["1781252575.860923-4f8c4p"], "sub_labels": [], "thumb_time": 1781252885.010814, "verified_objects": []}	{"frigate_instance_name": "البيت"}	2026-06-12 13:47:49.00706+00	2026-06-12 22:58:52.950885+00	1781252881.416414-6n4e4x	f	\N	\N	\N
bac17997-0ab1-49d6-9124-5ceeff3d5d0e	1781252242.294119-x0qunu	48c9e5dc-6641-4331-91a0-44a1cede5152	cam_02	2026-06-12 08:17:22.294+00	2026-06-12 08:25:05.553+00	alert	f	{"audio": [], "zones": [], "objects": ["person"], "metadata": null, "detections": ["1781252575.860923-4f8c4p", "1781252238.94568-kfr0gb", "1781252276.189091-v14reb"], "sub_labels": [], "thumb_time": 1781252282.063277, "verified_objects": []}	{"frigate_instance_name": "البيت"}	2026-06-12 13:47:49.02074+00	2026-06-12 22:58:52.950885+00	1781252242.294119-x0qunu	f	\N	\N	\N
82ca9485-40cf-42a5-96fb-2587c6d88e24	1781251494.464673-pps8c9	48c9e5dc-6641-4331-91a0-44a1cede5152	cam_01	2026-06-12 08:04:54.464+00	2026-06-12 08:06:29.979+00	alert	f	{"audio": [], "zones": [], "objects": ["person"], "metadata": null, "detections": ["1781251470.116224-x5yu5u"], "sub_labels": [], "thumb_time": 1781251495.580105, "verified_objects": []}	{"frigate_instance_name": "البيت"}	2026-06-12 13:47:49.039494+00	2026-06-12 22:58:52.950885+00	1781251494.464673-pps8c9	f	\N	\N	\N
24cce6a0-458b-4207-908b-c8b5346e2b8c	1781267113.397241-1eluqn	48c9e5dc-6641-4331-91a0-44a1cede5152	cam_02	2026-06-12 12:25:13.397+00	2026-06-12 12:25:13.397+00	alert	f	{"audio": [], "zones": [], "objects": ["person"], "metadata": null, "detections": ["1781267107.843628-l08k0z"], "sub_labels": [], "thumb_time": 1781267119.960197, "verified_objects": []}	{"frigate_instance_name": "البيت"}	2026-06-12 13:47:48.650357+00	2026-06-12 22:58:52.950885+00	1781267113.397241-1eluqn	f	\N	\N	\N
b84e9f7a-b3f4-4f6c-b550-48f55394f972	1781266502.153332-l26ei1	48c9e5dc-6641-4331-91a0-44a1cede5152	cam_02	2026-06-12 12:15:02.153+00	2026-06-12 12:16:59.205+00	alert	f	{"audio": [], "zones": [], "objects": ["person"], "metadata": null, "detections": ["1781266607.620656-wz67gj", "1781266491.577273-xdsspg", "1781266578.845608-zfg33y", "1781266274.68105-vggqoe"], "sub_labels": [], "thumb_time": 1781266530.48004, "verified_objects": []}	{"frigate_instance_name": "البيت"}	2026-06-12 13:47:48.667824+00	2026-06-12 22:58:52.950885+00	1781266502.153332-l26ei1	f	\N	\N	\N
14f2170b-79b2-4651-850e-b136c6dac645	1781265896.858193-yczlnz	48c9e5dc-6641-4331-91a0-44a1cede5152	cam_01	2026-06-12 12:04:56.858+00	2026-06-12 12:59:52.175+00	alert	f	{"audio": [], "zones": [], "objects": ["person"], "metadata": null, "detections": ["1781267988.888674-aotqi2", "1781268989.076855-d4cnkm", "1781268746.06574-oet1f4", "1781263319.138303-ht6dj8", "1781267309.655734-m30spn", "1781267910.77623-889fse", "1781267956.57244-qon8as", "1781266610.393732-ub8ulg", "1781268673.945082-1br1il", "1781268975.203321-15l4zh", "1781266667.886297-hxl27h", "1781268080.857731-0r09xg", "1781261537.89834-m3ny6q", "1781267928.004736-mczeht", "1781267956.57244-b0jpp4"], "sub_labels": [], "thumb_time": 1781267991.831865, "verified_objects": []}	{"frigate_instance_name": "البيت"}	2026-06-12 13:47:48.68873+00	2026-06-12 22:58:52.950885+00	1781265896.858193-yczlnz	f	\N	\N	\N
4e9dd468-9399-4bfb-a4fa-4f1e7d23d080	1781263765.337191-01409o	48c9e5dc-6641-4331-91a0-44a1cede5152	cam_02	2026-06-12 11:29:25.337+00	2026-06-12 11:31:50.533+00	alert	f	{"audio": [], "zones": [], "objects": ["person"], "metadata": null, "detections": ["1781263758.952179-5di9ua", "1781263771.741272-7d5ydt"], "sub_labels": [], "thumb_time": 1781263811.006326, "verified_objects": []}	{"frigate_instance_name": "البيت"}	2026-06-12 13:47:48.708299+00	2026-06-12 22:58:52.950885+00	1781263765.337191-01409o	f	\N	\N	\N
edf85011-1334-4a27-b62a-6165d332eff2	1781261844.951237-1anpx0	48c9e5dc-6641-4331-91a0-44a1cede5152	cam_01	2026-06-12 10:57:24.951+00	2026-06-12 11:14:42.988+00	alert	f	{"audio": [], "zones": [], "objects": ["person"], "metadata": null, "detections": ["1781261537.89834-m3ny6q"], "sub_labels": [], "thumb_time": 1781261860.35861, "verified_objects": []}	{"frigate_instance_name": "البيت"}	2026-06-12 13:47:48.728478+00	2026-06-12 22:58:52.950885+00	1781261844.951237-1anpx0	f	\N	\N	\N
fc2c4146-8f39-4ccc-9fbc-7641066421df	1781260742.885268-3vscof	48c9e5dc-6641-4331-91a0-44a1cede5152	cam_01	2026-06-12 10:39:02.885+00	2026-06-12 10:40:21.943+00	alert	f	{"audio": [], "zones": [], "objects": ["person"], "metadata": null, "detections": ["1781260534.198506-8ohz1p"], "sub_labels": [], "thumb_time": 1781260750.78995, "verified_objects": []}	{"frigate_instance_name": "البيت"}	2026-06-12 13:47:48.747559+00	2026-06-12 22:58:52.950885+00	1781260742.885268-3vscof	f	\N	\N	\N
e416733e-1a7c-4bdd-8c58-c716bdc94091	1781260587.811524-6j90km	48c9e5dc-6641-4331-91a0-44a1cede5152	cam_01	2026-06-12 10:36:27.811+00	2026-06-12 10:36:31+00	alert	f	{"audio": [], "zones": [], "objects": ["on_demand"], "metadata": null, "detections": ["1781260587.811524-wz7chl"], "sub_labels": [], "thumb_time": null, "verified_objects": []}	{"frigate_instance_name": "البيت"}	2026-06-12 13:47:48.767333+00	2026-06-12 22:58:52.950885+00	1781260587.811524-6j90km	f	\N	\N	\N
a01a7716-3787-426d-ab24-83fe41ba9cad	1781259284.112488-i42iq0	48c9e5dc-6641-4331-91a0-44a1cede5152	cam_02	2026-06-12 10:14:44.112+00	2026-06-12 10:15:19.725+00	alert	f	{"audio": [], "zones": [], "objects": ["car"], "metadata": null, "detections": ["1781257871.342286-e18i7e"], "sub_labels": [], "thumb_time": 1781259287.263859, "verified_objects": []}	{"frigate_instance_name": "البيت"}	2026-06-12 13:47:48.786056+00	2026-06-12 22:58:52.950885+00	1781259284.112488-i42iq0	f	\N	\N	\N
806fd998-7111-4a17-9d19-16528b3f40be	1781258620.453481-eu81ru	48c9e5dc-6641-4331-91a0-44a1cede5152	cam_01	2026-06-12 10:03:40.453+00	2026-06-12 10:06:00.892+00	alert	f	{"audio": [], "zones": [], "objects": ["person"], "metadata": null, "detections": ["1781258556.639104-x2ios6"], "sub_labels": [], "thumb_time": 1781258623.172118, "verified_objects": []}	{"frigate_instance_name": "البيت"}	2026-06-12 13:47:48.842107+00	2026-06-12 22:58:52.950885+00	1781258620.453481-eu81ru	f	\N	\N	\N
83045040-bca8-4763-b8f9-c1142f27e47d	1781257129.84377-bpuzal	48c9e5dc-6641-4331-91a0-44a1cede5152	cam_02	2026-06-12 09:38:49.843+00	2026-06-12 09:39:13+00	alert	f	{"audio": [], "zones": [], "objects": ["person"], "metadata": null, "detections": ["1781257125.576522-hi734y"], "sub_labels": [], "thumb_time": 1781257133.797663, "verified_objects": []}	{"frigate_instance_name": "البيت"}	2026-06-12 13:47:48.860493+00	2026-06-12 22:58:52.950885+00	1781257129.84377-bpuzal	f	\N	\N	\N
64144401-6d00-4d34-b2a2-bb64ab3ad495	1781256344.306883-g6s8pz	48c9e5dc-6641-4331-91a0-44a1cede5152	cam_02	2026-06-12 09:25:44.306+00	2026-06-12 09:35:31.352+00	alert	f	{"audio": [], "zones": [], "objects": ["person"], "metadata": null, "detections": ["1781256697.370586-6ggwh7", "1781256340.28667-54arkj", "1781256502.993618-i0gca8"], "sub_labels": [], "thumb_time": 1781256571.860831, "verified_objects": []}	{"frigate_instance_name": "البيت"}	2026-06-12 13:47:48.90735+00	2026-06-12 22:58:52.950885+00	1781256344.306883-g6s8pz	f	\N	\N	\N
6f3c30d8-18ec-423a-b82f-8d4485aafd55	1781255767.771551-ydkxcs	48c9e5dc-6641-4331-91a0-44a1cede5152	cam_02	2026-06-12 09:16:07.771+00	2026-06-12 09:21:17.727+00	alert	f	{"audio": [], "zones": [], "objects": ["person"], "metadata": null, "detections": ["1781255775.339284-6357h0", "1781255764.206056-ykhqlg"], "sub_labels": [], "thumb_time": 1781255783.122431, "verified_objects": []}	{"frigate_instance_name": "البيت"}	2026-06-12 13:47:48.92424+00	2026-06-12 22:58:52.950885+00	1781255767.771551-ydkxcs	f	\N	\N	\N
cfacfb19-ae8d-407f-b4f8-46bd421f31a9	1781255233.649517-mkqhc4	48c9e5dc-6641-4331-91a0-44a1cede5152	cam_01	2026-06-12 09:07:13.649+00	2026-06-12 09:08:54.604+00	alert	f	{"audio": [], "zones": [], "objects": ["person"], "metadata": null, "detections": ["1781255231.780901-8k5g8i", "1781255118.012715-djcx2q"], "sub_labels": [], "thumb_time": 1781255235.774321, "verified_objects": []}	{"frigate_instance_name": "البيت"}	2026-06-12 13:47:48.955004+00	2026-06-12 22:58:52.950885+00	1781255233.649517-mkqhc4	f	\N	\N	\N
5b541b03-02cd-4a29-b8fe-918af4046951	1781254741.669069-fe2zlk	48c9e5dc-6641-4331-91a0-44a1cede5152	cam_01	2026-06-12 08:59:01.669+00	2026-06-12 09:01:31.339+00	alert	f	{"audio": [], "zones": [], "objects": ["person"], "metadata": null, "detections": ["1781254557.56244-8yb6qt"], "sub_labels": [], "thumb_time": 1781254743.86032, "verified_objects": []}	{"frigate_instance_name": "البيت"}	2026-06-12 13:47:48.969916+00	2026-06-12 22:58:52.950885+00	1781254741.669069-fe2zlk	f	\N	\N	\N
b610a9d0-7489-4c9a-9bad-0d81090b7c39	1781254368.167533-a8wri3	48c9e5dc-6641-4331-91a0-44a1cede5152	cam_02	2026-06-12 08:52:48.167+00	2026-06-12 08:53:08.387+00	alert	f	{"audio": [], "zones": [], "objects": ["person"], "metadata": null, "detections": ["1781254364.343207-yeoaz8"], "sub_labels": [], "thumb_time": 1781254371.912927, "verified_objects": []}	{"frigate_instance_name": "البيت"}	2026-06-12 13:47:48.982822+00	2026-06-12 22:58:52.950885+00	1781254368.167533-a8wri3	f	\N	\N	\N
5d6b3821-19a3-4b1c-bb78-564124156609	1781253690.398664-fkih8o	48c9e5dc-6641-4331-91a0-44a1cede5152	cam_02	2026-06-12 08:41:30.398+00	2026-06-12 08:42:16.706+00	alert	f	{"audio": [], "zones": [], "objects": ["person"], "metadata": null, "detections": ["1781253687.031726-r6pu6r"], "sub_labels": [], "thumb_time": 1781253693.95154, "verified_objects": []}	{"frigate_instance_name": "البيت"}	2026-06-12 13:47:48.997134+00	2026-06-12 22:58:52.950885+00	1781253690.398664-fkih8o	f	\N	\N	\N
67d55bdf-2ffd-44bb-b19b-a673cb584be9	1781252799.934053-hv4434	48c9e5dc-6641-4331-91a0-44a1cede5152	cam_01	2026-06-12 08:26:39.934+00	2026-06-12 08:30:54.094+00	alert	t	{"audio": [], "zones": [], "objects": ["person"], "metadata": null, "detections": ["1781252973.425916-r1p47r", "1781252907.39735-qzzapv", "1781252714.251104-anv77y"], "sub_labels": [], "thumb_time": 1781252801.958492, "verified_objects": []}	{"frigate_instance_name": "البيت"}	2026-06-12 13:47:49.012148+00	2026-06-12 22:58:52.950885+00	1781252799.934053-hv4434	f	\N	\N	\N
4ab2d40e-89a9-45c7-844a-264c7c39e01d	1781252138.218932-g28v9h	48c9e5dc-6641-4331-91a0-44a1cede5152	cam_02	2026-06-12 08:15:38.218+00	2026-06-12 08:16:40.369+00	alert	f	{"audio": [], "zones": [], "objects": ["person"], "metadata": null, "detections": ["1781252135.134295-ddj7d1"], "sub_labels": [], "thumb_time": 1781252141.816806, "verified_objects": []}	{"frigate_instance_name": "البيت"}	2026-06-12 13:47:49.025808+00	2026-06-12 22:58:52.950885+00	1781252138.218932-g28v9h	f	\N	\N	\N
f169d15f-a156-485e-92cc-dc2b6c6b31d7	1781251958.489749-9yz4dh	48c9e5dc-6641-4331-91a0-44a1cede5152	cam_02	2026-06-12 08:12:38.489+00	2026-06-12 08:13:26.103+00	alert	f	{"audio": [], "zones": [], "objects": ["person"], "metadata": null, "detections": ["1781251952.002951-uwoe0n"], "sub_labels": [], "thumb_time": 1781251961.872634, "verified_objects": []}	{"frigate_instance_name": "البيت"}	2026-06-12 13:47:49.030737+00	2026-06-12 22:58:52.950885+00	1781251958.489749-9yz4dh	f	\N	\N	\N
f65b2379-158f-45ab-8bcc-400c23ad7953	1781251292.009714-1yk92m	48c9e5dc-6641-4331-91a0-44a1cede5152	cam_02	2026-06-12 08:01:32.009+00	2026-06-12 08:06:29.979+00	alert	t	{"audio": [], "zones": [], "objects": ["person"], "metadata": null, "detections": ["1781251292.009714-zoat9b", "1781251403.316015-wcv8zb", "1781251430.840235-4kwj9u", "1781251318.931696-573sc3", "1781251434.919557-wu8e97", "1781251290.725642-qtm438"], "sub_labels": [], "thumb_time": 1781251458.723822, "verified_objects": []}	{"frigate_instance_name": "البيت"}	2026-06-12 13:47:49.045595+00	2026-06-12 22:58:52.950885+00	1781251292.009714-1yk92m	f	\N	\N	\N
9b9c0dea-b8bb-418d-8ff6-a739fe55070f	1781251025.021684-d3rqi2	48c9e5dc-6641-4331-91a0-44a1cede5152	cam_02	2026-06-12 07:57:05.021+00	2026-06-12 08:00:14.442+00	alert	f	{"audio": [], "zones": [], "objects": ["person"], "metadata": null, "detections": ["1781251029.955759-yjkcrv", "1781251133.127638-7k1s3e", "1781251023.243745-bquaul"], "sub_labels": [], "thumb_time": 1781251136.35795, "verified_objects": []}	{"frigate_instance_name": "البيت"}	2026-06-12 13:47:49.057687+00	2026-06-12 22:58:52.950885+00	1781251025.021684-d3rqi2	f	\N	\N	\N
a377a597-f61f-4dc0-8c68-fcd3af131852	1781250339.028458-097eqr	48c9e5dc-6641-4331-91a0-44a1cede5152	cam_01	2026-06-12 07:45:39.028+00	2026-06-12 07:49:16.756+00	alert	f	{"audio": [], "zones": [], "objects": ["person"], "metadata": null, "detections": ["1781250280.650741-i2nlmj", "1781250344.911447-2rj9hl", "1781250475.214317-8adyj7"], "sub_labels": [], "thumb_time": 1781250347.817369, "verified_objects": []}	{"frigate_instance_name": "البيت"}	2026-06-12 13:47:49.071106+00	2026-06-12 22:58:52.950885+00	1781250339.028458-097eqr	f	\N	\N	\N
50f41574-8bf2-45b4-9bdd-e7bbe04277bc	1781249535.439963-4giyfr	48c9e5dc-6641-4331-91a0-44a1cede5152	cam_01	2026-06-12 07:32:15.439+00	2026-06-12 07:33:01.712+00	alert	f	{"audio": [], "zones": [], "objects": ["person"], "metadata": null, "detections": ["1781249308.738841-limhgv"], "sub_labels": [], "thumb_time": 1781249537.149945, "verified_objects": []}	{"frigate_instance_name": "البيت"}	2026-06-12 13:47:49.085322+00	2026-06-12 22:58:52.950885+00	1781249535.439963-4giyfr	f	\N	\N	\N
72f1215e-3298-43e2-b9cc-361a9159ba4a	1781249129.39624-0b3gg3	48c9e5dc-6641-4331-91a0-44a1cede5152	cam_02	2026-06-12 07:25:29.396+00	2026-06-12 07:25:31.051+00	alert	f	{"audio": [], "zones": [], "objects": ["person"], "metadata": null, "detections": ["1781249127.664268-yrvkie"], "sub_labels": [], "thumb_time": 1781249131.479733, "verified_objects": []}	{"frigate_instance_name": "البيت"}	2026-06-12 13:47:49.099512+00	2026-06-12 22:58:52.950885+00	1781249129.39624-0b3gg3	f	\N	\N	\N
c16154e5-456c-43a4-adc2-8fdb361412ad	1781247986.099338-f5owx6	48c9e5dc-6641-4331-91a0-44a1cede5152	cam_01	2026-06-12 07:06:26.099+00	2026-06-12 07:08:07.736+00	alert	f	{"audio": [], "zones": [], "objects": ["person"], "metadata": null, "detections": ["1781248017.350312-xpgiy7", "1781248023.837168-bfte9k", "1781247984.856985-2koaqy"], "sub_labels": [], "thumb_time": 1781247987.600758, "verified_objects": []}	{"frigate_instance_name": "البيت"}	2026-06-12 13:47:49.112564+00	2026-06-12 22:58:52.950885+00	1781247986.099338-f5owx6	f	\N	\N	\N
eff2232b-af02-48c6-bc72-39c7a13810f3	1781247359.154338-txml93	48c9e5dc-6641-4331-91a0-44a1cede5152	cam_01	2026-06-12 06:55:59.154+00	2026-06-12 06:56:06.443+00	alert	f	{"audio": [], "zones": [], "objects": ["person"], "metadata": null, "detections": ["1781247358.068172-yhph83"], "sub_labels": [], "thumb_time": 1781247360.469776, "verified_objects": []}	{"frigate_instance_name": "البيت"}	2026-06-12 13:47:49.126409+00	2026-06-12 22:58:52.950885+00	1781247359.154338-txml93	f	\N	\N	\N
acd0a620-4b38-4696-a31d-4008632b92a2	1781247062.248623-yrad7d	48c9e5dc-6641-4331-91a0-44a1cede5152	cam_01	2026-06-12 06:51:02.248+00	2026-06-12 06:53:23.386+00	alert	f	{"audio": [], "zones": [], "objects": ["person"], "metadata": null, "detections": ["1781247035.043372-hthlcx", "1781247178.111897-hmxuuf"], "sub_labels": [], "thumb_time": 1781247063.971923, "verified_objects": []}	{"frigate_instance_name": "البيت"}	2026-06-12 13:47:49.140761+00	2026-06-12 22:58:52.950885+00	1781247062.248623-yrad7d	f	\N	\N	\N
485d23e1-db56-4ff6-85b7-00e67aea8f1a	1781246521.862708-l07iux	48c9e5dc-6641-4331-91a0-44a1cede5152	cam_01	2026-06-12 06:42:01.862+00	2026-06-12 06:42:32.185+00	alert	f	{"audio": [], "zones": [], "objects": ["person"], "metadata": null, "detections": ["1781246408.67674-fvh2kf"], "sub_labels": [], "thumb_time": 1781246523.777102, "verified_objects": []}	{"frigate_instance_name": "البيت"}	2026-06-12 13:47:49.155173+00	2026-06-12 22:58:52.950885+00	1781246521.862708-l07iux	f	\N	\N	\N
a44368e7-76f6-4493-b3d2-6a3afe7a6442	1781246289.781267-3ehyp1	48c9e5dc-6641-4331-91a0-44a1cede5152	cam_01	2026-06-12 06:38:09.781+00	2026-06-12 06:39:40.883+00	alert	f	{"audio": [], "zones": [], "objects": ["person"], "metadata": null, "detections": ["1781246313.548894-3hpdqa", "1781246376.881588-7zttxj", "1781246287.5887-lcjb16"], "sub_labels": [], "thumb_time": 1781246324.928453, "verified_objects": []}	{"frigate_instance_name": "البيت"}	2026-06-12 13:47:49.172546+00	2026-06-12 22:58:52.950885+00	1781246289.781267-3ehyp1	f	\N	\N	\N
d7f1f1de-bd27-47c3-94d3-d5a2c44d8c25	1781245549.589011-rfxutk	48c9e5dc-6641-4331-91a0-44a1cede5152	cam_01	2026-06-12 06:25:49.589+00	2026-06-12 06:26:24.222+00	alert	f	{"audio": [], "zones": [], "objects": ["person"], "metadata": null, "detections": ["1781245548.48474-w5qawd", "1781245580.181492-b2lkiy"], "sub_labels": [], "thumb_time": 1781245551.193409, "verified_objects": []}	{"frigate_instance_name": "البيت"}	2026-06-12 13:47:49.186457+00	2026-06-12 22:58:52.950885+00	1781245549.589011-rfxutk	f	\N	\N	\N
f8eef99e-de18-45e0-ba13-04dcef36760f	1781245045.117161-tohn5m	48c9e5dc-6641-4331-91a0-44a1cede5152	cam_01	2026-06-12 06:17:25.117+00	2026-06-12 06:19:44.665+00	alert	f	{"audio": [], "zones": [], "objects": ["person"], "metadata": null, "detections": ["1781245088.706749-60kc11", "1781245028.912255-8q14zd"], "sub_labels": [], "thumb_time": 1781245104.069336, "verified_objects": []}	{"frigate_instance_name": "البيت"}	2026-06-12 13:47:49.200306+00	2026-06-12 22:58:52.950885+00	1781245045.117161-tohn5m	f	\N	\N	\N
1893ac0d-60a1-4cdf-aff8-ed0650809e92	1781244718.386166-jiidue	48c9e5dc-6641-4331-91a0-44a1cede5152	cam_01	2026-06-12 06:11:58.386+00	2026-06-12 06:11:59.582+00	alert	f	{"audio": [], "zones": [], "objects": ["person"], "metadata": null, "detections": ["1781244717.307348-f2jqcb"], "sub_labels": [], "thumb_time": 1781244719.907949, "verified_objects": []}	{"frigate_instance_name": "البيت"}	2026-06-12 13:47:49.215436+00	2026-06-12 22:58:52.950885+00	1781244718.386166-jiidue	f	\N	\N	\N
516a0449-ffb6-4b51-a7bc-3fcc3e9df167	1781244241.041216-p8v6ua	48c9e5dc-6641-4331-91a0-44a1cede5152	cam_02	2026-06-12 06:04:01.041+00	2026-06-12 06:05:22.241+00	alert	f	{"audio": [], "zones": [], "objects": ["person"], "metadata": null, "detections": ["1781244320.996346-dor3x2", "1781244286.81942-4xzabn", "1781244253.819841-uv9e90", "1781244237.232963-rjjxro"], "sub_labels": [], "thumb_time": 1781244242.396981, "verified_objects": []}	{"frigate_instance_name": "البيت"}	2026-06-12 13:47:49.228953+00	2026-06-12 22:58:52.950885+00	1781244241.041216-p8v6ua	f	\N	\N	\N
17f0b1ad-1f3f-4ebb-913b-48da1ff18071	1781243480.558352-t8aecz	48c9e5dc-6641-4331-91a0-44a1cede5152	cam_01	2026-06-12 05:51:20.558+00	2026-06-12 05:52:03.911+00	alert	f	{"audio": [], "zones": [], "objects": ["person"], "metadata": null, "detections": ["1781243510.321527-5jgak7", "1781243479.637239-aqwxxx"], "sub_labels": [], "thumb_time": 1781243481.864797, "verified_objects": []}	{"frigate_instance_name": "البيت"}	2026-06-12 13:47:49.241588+00	2026-06-12 22:58:52.950885+00	1781243480.558352-t8aecz	f	\N	\N	\N
a62894c2-8b5a-4d36-8ea7-3a409e8689d0	1781242688.90242-as04v7	48c9e5dc-6641-4331-91a0-44a1cede5152	cam_01	2026-06-12 05:38:08.902+00	2026-06-12 05:38:27.017+00	alert	f	{"audio": [], "zones": [], "objects": ["person"], "metadata": null, "detections": ["1781242668.609826-3eg0nw"], "sub_labels": [], "thumb_time": 1781242689.902936, "verified_objects": []}	{"frigate_instance_name": "البيت"}	2026-06-12 13:47:49.254833+00	2026-06-12 22:58:52.950885+00	1781242688.90242-as04v7	f	\N	\N	\N
d214afdc-a624-4a58-b1fc-d463a5ba2d68	1781241537.259603-zvhhl7	48c9e5dc-6641-4331-91a0-44a1cede5152	cam_01	2026-06-12 05:18:57.259+00	2026-06-12 05:19:54.016+00	alert	f	{"audio": [], "zones": [], "objects": ["person"], "metadata": null, "detections": ["1781241590.078753-hbazie", "1781241536.526775-d9ai95", "1781241544.717221-28sppu"], "sub_labels": [], "thumb_time": 1781241538.192999, "verified_objects": []}	{"frigate_instance_name": "البيت"}	2026-06-12 13:47:49.268328+00	2026-06-12 22:58:52.950885+00	1781241537.259603-zvhhl7	f	\N	\N	\N
d6685ebd-e9d5-41a7-bf9c-0f6e0451d647	1781251633.06051-fyy698	48c9e5dc-6641-4331-91a0-44a1cede5152	cam_02	2026-06-12 08:07:13.06+00	2026-06-12 08:10:06.338+00	alert	f	{"audio": [], "zones": [], "objects": ["person"], "metadata": null, "detections": ["1781251629.512371-6ogdv0", "1781251629.512371-3on955", "1781251629.512371-0m6aoz"], "sub_labels": [], "thumb_time": 1781251662.859961, "verified_objects": []}	{"frigate_instance_name": "البيت"}	2026-06-12 13:47:49.035336+00	2026-06-12 22:58:52.950885+00	1781251633.06051-fyy698	f	\N	\N	\N
34b0f24f-7578-4da2-a20d-81cb194d29e4	1781251250.360478-7uk0kb	48c9e5dc-6641-4331-91a0-44a1cede5152	cam_01	2026-06-12 08:00:50.36+00	2026-06-12 08:03:06.197+00	alert	f	{"audio": [], "zones": [], "objects": ["person"], "metadata": null, "detections": ["1781251249.534985-jwta2a", "1781251250.360478-x62l98", "1781251250.360478-iit20w", "1781251366.947026-p6wtoo"], "sub_labels": [], "thumb_time": 1781251270.4477, "verified_objects": []}	{"frigate_instance_name": "البيت"}	2026-06-12 13:47:49.049947+00	2026-06-12 22:58:52.950885+00	1781251250.360478-7uk0kb	f	\N	\N	\N
83a3d14d-d127-4f56-b443-cf62fc31fa17	1781250602.37012-ca8gja	48c9e5dc-6641-4331-91a0-44a1cede5152	cam_01	2026-06-12 07:50:02.37+00	2026-06-12 07:50:22.91+00	alert	t	{"audio": [], "zones": [], "objects": ["person"], "metadata": null, "detections": ["1781250600.619506-80rz1t"], "sub_labels": [], "thumb_time": 1781250603.666733, "verified_objects": []}	{"frigate_instance_name": "البيت"}	2026-06-12 13:47:49.063115+00	2026-06-12 22:58:52.950885+00	1781250602.37012-ca8gja	f	\N	\N	\N
31460ba5-26cd-4dd3-8328-012a319fae48	1781249904.166481-jx2o4s	48c9e5dc-6641-4331-91a0-44a1cede5152	cam_01	2026-06-12 07:38:24.166+00	2026-06-12 07:38:25.329+00	alert	f	{"audio": [], "zones": [], "objects": ["person"], "metadata": null, "detections": ["1781249824.98075-2y83ox"], "sub_labels": [], "thumb_time": 1781249905.603654, "verified_objects": []}	{"frigate_instance_name": "البيت"}	2026-06-12 13:47:49.075871+00	2026-06-12 22:58:52.950885+00	1781249904.166481-jx2o4s	f	\N	\N	\N
07301929-d938-4ecd-a00e-070b5ffafc2c	1781249181.213629-lpzkcy	48c9e5dc-6641-4331-91a0-44a1cede5152	cam_02	2026-06-12 07:26:21.213+00	2026-06-12 07:30:14.303+00	alert	f	{"audio": [], "zones": [], "objects": ["person"], "metadata": null, "detections": ["1781249179.224519-ifkh3o"], "sub_labels": [], "thumb_time": 1781249184.703495, "verified_objects": []}	{"frigate_instance_name": "البيت"}	2026-06-12 13:47:49.089291+00	2026-06-12 22:58:52.950885+00	1781249181.213629-lpzkcy	f	\N	\N	\N
e84cfdf0-b95e-4469-aafb-a75bf0a07c0e	1781248822.888617-ry3ghl	48c9e5dc-6641-4331-91a0-44a1cede5152	cam_01	2026-06-12 07:20:22.888+00	2026-06-12 07:21:22.017+00	alert	f	{"audio": [], "zones": [], "objects": ["person"], "metadata": null, "detections": ["1781248855.949578-heu95h", "1781248739.841443-7gniu8"], "sub_labels": [], "thumb_time": 1781248859.144091, "verified_objects": []}	{"frigate_instance_name": "البيت"}	2026-06-12 13:47:49.103569+00	2026-06-12 22:58:52.950885+00	1781248822.888617-ry3ghl	f	\N	\N	\N
517743dd-c34a-4215-a9fd-85d857ea5fa1	1781247866.356112-ski303	48c9e5dc-6641-4331-91a0-44a1cede5152	cam_01	2026-06-12 07:04:26.356+00	2026-06-12 07:05:24.969+00	alert	f	{"audio": [], "zones": [], "objects": ["person"], "metadata": null, "detections": ["1781247812.455058-rmpud1", "1781247915.669328-d2cy3p"], "sub_labels": [], "thumb_time": 1781247867.751906, "verified_objects": []}	{"frigate_instance_name": "البيت"}	2026-06-12 13:47:49.117657+00	2026-06-12 22:58:52.950885+00	1781247866.356112-ski303	f	\N	\N	\N
c80e7267-1528-4c78-8799-2bc1b8940ecd	1781247276.918655-2j4zrx	48c9e5dc-6641-4331-91a0-44a1cede5152	cam_01	2026-06-12 06:54:36.918+00	2026-06-12 06:54:59.392+00	alert	f	{"audio": [], "zones": [], "objects": ["person"], "metadata": null, "detections": ["1781247264.812152-2s0bf6"], "sub_labels": [], "thumb_time": 1781247278.164776, "verified_objects": []}	{"frigate_instance_name": "البيت"}	2026-06-12 13:47:49.13111+00	2026-06-12 22:58:52.950885+00	1781247276.918655-2j4zrx	f	\N	\N	\N
6fa2a0a8-2137-4bf5-8db2-88a67056a24e	1781246794.98959-dcrrya	48c9e5dc-6641-4331-91a0-44a1cede5152	cam_01	2026-06-12 06:46:34.989+00	2026-06-12 06:46:46.648+00	alert	f	{"audio": [], "zones": [], "objects": ["person"], "metadata": null, "detections": ["1781246793.972205-m901ai"], "sub_labels": [], "thumb_time": 1781246796.546439, "verified_objects": []}	{"frigate_instance_name": "البيت"}	2026-06-12 13:47:49.144818+00	2026-06-12 22:58:52.950885+00	1781246794.98959-dcrrya	f	\N	\N	\N
13a63331-da37-4ecf-967e-b995de0354aa	1781246427.756846-7zilx7	48c9e5dc-6641-4331-91a0-44a1cede5152	cam_01	2026-06-12 06:40:27.756+00	2026-06-12 06:40:29.784+00	alert	f	{"audio": [], "zones": [], "objects": ["person"], "metadata": null, "detections": ["1781246426.702364-y4j8dw"], "sub_labels": [], "thumb_time": 1781246429.202729, "verified_objects": []}	{"frigate_instance_name": "البيت"}	2026-06-12 13:47:49.16027+00	2026-06-12 22:58:52.950885+00	1781246427.756846-7zilx7	f	\N	\N	\N
a8c3cc2c-5f5b-410e-be86-500099a20980	1781246203.122238-a7wfvk	48c9e5dc-6641-4331-91a0-44a1cede5152	cam_01	2026-06-12 06:36:43.122+00	2026-06-12 06:37:09.642+00	alert	f	{"audio": [], "zones": [], "objects": ["person"], "metadata": null, "detections": ["1781246202.137315-219vet"], "sub_labels": [], "thumb_time": 1781246204.393179, "verified_objects": []}	{"frigate_instance_name": "البيت"}	2026-06-12 13:47:49.177776+00	2026-06-12 22:58:52.950885+00	1781246203.122238-a7wfvk	f	\N	\N	\N
402730c8-7997-47ba-a078-4844a4f4ac36	1781245452.429556-34ainx	48c9e5dc-6641-4331-91a0-44a1cede5152	cam_02	2026-06-12 06:24:12.429+00	2026-06-12 06:38:06.09+00	alert	f	{"audio": [], "zones": [], "objects": ["person", "car"], "metadata": null, "detections": ["1781245493.129766-u4dagb", "1781246161.752741-yk5exu", "1781245927.116415-zf6kd6", "1781245550.947677-sb6owo", "1781246187.033227-vgsjfi", "1781245781.609836-x0qoix", "1781245939.59275-1f7b31", "1781245814.446774-qj6te4", "1781245577.641148-151xz4", "1781245854.400286-hoksum", "1781245451.111419-5uvfj7", "1781245821.429591-fg8dc2", "1781245717.539668-dzyrab"], "sub_labels": [], "thumb_time": 1781245723.370297, "verified_objects": []}	{"frigate_instance_name": "البيت"}	2026-06-12 13:47:49.191606+00	2026-06-12 22:58:52.950885+00	1781245452.429556-34ainx	f	\N	\N	\N
60aa7a3f-cba3-4148-a2a0-85f8bf55e2c1	1781244832.014412-o6fxid	48c9e5dc-6641-4331-91a0-44a1cede5152	cam_01	2026-06-12 06:13:52.014+00	2026-06-12 06:13:58.152+00	alert	f	{"audio": [], "zones": [], "objects": ["person"], "metadata": null, "detections": ["1781244830.84249-y6y8cm"], "sub_labels": [], "thumb_time": 1781244833.465562, "verified_objects": []}	{"frigate_instance_name": "البيت"}	2026-06-12 13:47:49.204964+00	2026-06-12 22:58:52.950885+00	1781244832.014412-o6fxid	f	\N	\N	\N
0917c4df-b8a2-44b6-b6f9-155e80be17c1	1781244604.068991-hj8n53	48c9e5dc-6641-4331-91a0-44a1cede5152	cam_01	2026-06-12 06:10:04.068+00	2026-06-12 06:10:31.691+00	alert	f	{"audio": [], "zones": [], "objects": ["person"], "metadata": null, "detections": ["1781244630.58353-3y2cov", "1781244603.066456-fle9kh"], "sub_labels": [], "thumb_time": 1781244605.349903, "verified_objects": []}	{"frigate_instance_name": "البيت"}	2026-06-12 13:47:49.219639+00	2026-06-12 22:58:52.950885+00	1781244604.068991-hj8n53	f	\N	\N	\N
31768307-f0f5-445c-8369-5ee4cbc0f31c	1781244056.389689-83ep14	48c9e5dc-6641-4331-91a0-44a1cede5152	cam_01	2026-06-12 06:00:56.389+00	2026-06-12 06:02:42.309+00	alert	f	{"audio": [], "zones": [], "objects": ["car"], "metadata": null, "detections": ["1781244044.810687-irvkzt"], "sub_labels": [], "thumb_time": 1781244057.618205, "verified_objects": []}	{"frigate_instance_name": "البيت"}	2026-06-12 13:47:49.233431+00	2026-06-12 22:58:52.950885+00	1781244056.389689-83ep14	f	\N	\N	\N
0ebbd9d1-4596-449b-af79-7527a323fca0	1781243122.908611-l6s9vt	48c9e5dc-6641-4331-91a0-44a1cede5152	cam_01	2026-06-12 05:45:22.908+00	2026-06-12 05:45:23.93+00	alert	f	{"audio": [], "zones": [], "objects": ["person"], "metadata": null, "detections": ["1781243039.050232-cmqtsb"], "sub_labels": [], "thumb_time": 1781243124.280896, "verified_objects": []}	{"frigate_instance_name": "البيت"}	2026-06-12 13:47:49.247631+00	2026-06-12 22:58:52.950885+00	1781243122.908611-l6s9vt	f	\N	\N	\N
cb4141c4-3e95-44ee-8bf1-433694cb8117	1781242422.288319-dfgmqx	48c9e5dc-6641-4331-91a0-44a1cede5152	cam_02	2026-06-12 05:33:42.288+00	2026-06-12 05:33:50.923+00	alert	f	{"audio": [], "zones": [], "objects": ["person"], "metadata": null, "detections": ["1781242421.077597-np0qay"], "sub_labels": [], "thumb_time": 1781242423.697243, "verified_objects": []}	{"frigate_instance_name": "البيت"}	2026-06-12 13:47:49.258968+00	2026-06-12 22:58:52.950885+00	1781242422.288319-dfgmqx	f	\N	\N	\N
dd97dbf2-5792-4b28-99cd-6acd36a597bc	1781241417.984088-g6cokb	48c9e5dc-6641-4331-91a0-44a1cede5152	cam_01	2026-06-12 05:16:57.984+00	2026-06-12 05:17:00.807+00	alert	f	{"audio": [], "zones": [], "objects": ["person"], "metadata": null, "detections": ["1781241417.218568-hrzl1a"], "sub_labels": [], "thumb_time": 1781241418.825005, "verified_objects": []}	{"frigate_instance_name": "البيت"}	2026-06-12 13:47:49.272028+00	2026-06-12 22:58:52.950885+00	1781241417.984088-g6cokb	f	\N	\N	\N
1326fcd9-2808-4454-bf59-da8ec8b59834	1781251037.568619-38s5bq	48c9e5dc-6641-4331-91a0-44a1cede5152	cam_01	2026-06-12 07:57:17.568+00	2026-06-12 07:58:49.493+00	alert	f	{"audio": [], "zones": [], "objects": ["person"], "metadata": null, "detections": ["1781250998.00557-rtpiyu"], "sub_labels": [], "thumb_time": 1781251038.701072, "verified_objects": []}	{"frigate_instance_name": "البيت"}	2026-06-12 13:47:49.053664+00	2026-06-12 22:58:52.950885+00	1781251037.568619-38s5bq	f	\N	\N	\N
eec2c102-7679-4178-98c0-23132a3f5340	1781250485.559208-h539tr	48c9e5dc-6641-4331-91a0-44a1cede5152	cam_02	2026-06-12 07:48:05.559+00	2026-06-12 07:55:09.871+00	alert	t	{"audio": [], "zones": [], "objects": ["person"], "metadata": null, "detections": ["1781250484.127306-ld8477", "1781250490.93242-ddnbp1"], "sub_labels": [], "thumb_time": 1781250494.514842, "verified_objects": []}	{"frigate_instance_name": "البيت"}	2026-06-12 13:47:49.067255+00	2026-06-12 22:58:52.950885+00	1781250485.559208-h539tr	f	\N	\N	\N
aeca4468-f670-4881-9e88-053a941a9192	1781249663.036403-82wbu3	48c9e5dc-6641-4331-91a0-44a1cede5152	cam_02	2026-06-12 07:34:23.036+00	2026-06-12 07:45:28.521+00	alert	f	{"audio": [], "zones": [], "objects": ["person"], "metadata": null, "detections": ["1781249907.976503-3d5kii", "1781249970.203744-qqeifw", "1781249661.234953-htvdd7", "1781250181.484007-e74h7y", "1781250131.743448-iu9df2", "1781249747.120297-o1pkb3"], "sub_labels": [], "thumb_time": 1781249975.288, "verified_objects": []}	{"frigate_instance_name": "البيت"}	2026-06-12 13:47:49.081263+00	2026-06-12 22:58:52.950885+00	1781249663.036403-82wbu3	f	\N	\N	\N
b9270ea5-2e91-4606-9d21-98ba7a60757e	1781249156.019788-7l10wb	48c9e5dc-6641-4331-91a0-44a1cede5152	cam_01	2026-06-12 07:25:56.019+00	2026-06-12 07:26:22.544+00	alert	f	{"audio": [], "zones": [], "objects": ["person"], "metadata": null, "detections": ["1781249154.681641-kznvr1"], "sub_labels": [], "thumb_time": 1781249157.60141, "verified_objects": []}	{"frigate_instance_name": "البيت"}	2026-06-12 13:47:49.093954+00	2026-06-12 22:58:52.950885+00	1781249156.019788-7l10wb	f	\N	\N	\N
b7fcf4ab-84fa-4b6e-8288-4247b858da62	1781248225.655208-tu9k6c	48c9e5dc-6641-4331-91a0-44a1cede5152	cam_01	2026-06-12 07:10:25.655+00	2026-06-12 07:11:17.918+00	alert	f	{"audio": [], "zones": [], "objects": ["person"], "metadata": null, "detections": ["1781248208.901702-fnr0g7"], "sub_labels": [], "thumb_time": 1781248227.674749, "verified_objects": []}	{"frigate_instance_name": "البيت"}	2026-06-12 13:47:49.107869+00	2026-06-12 22:58:52.950885+00	1781248225.655208-tu9k6c	f	\N	\N	\N
8a5812fe-ec33-4761-a652-4b2dc1281d49	1781247544.786932-y72xyt	48c9e5dc-6641-4331-91a0-44a1cede5152	cam_01	2026-06-12 06:59:04.786+00	2026-06-12 06:59:19.472+00	alert	f	{"audio": [], "zones": [], "objects": ["person"], "metadata": null, "detections": ["1781247494.877541-3elevx"], "sub_labels": [], "thumb_time": 1781247546.392618, "verified_objects": []}	{"frigate_instance_name": "البيت"}	2026-06-12 13:47:49.121719+00	2026-06-12 22:58:52.950885+00	1781247544.786932-y72xyt	f	\N	\N	\N
9bdba2bc-b31d-44b8-b621-5d3cfc7ccac4	1781247169.461308-ny9n9y	48c9e5dc-6641-4331-91a0-44a1cede5152	cam_02	2026-06-12 06:52:49.461+00	2026-06-12 07:23:45.151+00	alert	f	{"audio": [], "zones": [], "objects": ["person"], "metadata": null, "detections": ["1781247282.664048-s8lmrs", "1781248278.558866-dgwcj6", "1781247168.231578-zjwkek", "1781247592.187425-ga1in4", "1781248037.283484-9ts93c", "1781247549.215591-in5zdw", "1781247202.181359-ox4e95", "1781248838.542483-5dc69f", "1781248339.037742-20wh29", "1781247443.74542-d3pgsb", "1781248876.555462-1pgt6d", "1781247321.416397-v8498i", "1781249007.156978-om90vl", "1781247363.554165-cg7doe", "1781247827.819712-ctfah7", "1781247237.862203-zhw7rp"], "sub_labels": [], "thumb_time": 1781247255.928715, "verified_objects": []}	{"frigate_instance_name": "البيت"}	2026-06-12 13:47:49.136426+00	2026-06-12 22:58:52.950885+00	1781247169.461308-ny9n9y	f	\N	\N	\N
385a6a8a-37e2-4aba-90c3-5428a556dc5b	1781246736.668357-jnhzvc	48c9e5dc-6641-4331-91a0-44a1cede5152	cam_01	2026-06-12 06:45:36.668+00	2026-06-12 06:45:43.881+00	alert	f	{"audio": [], "zones": [], "objects": ["person"], "metadata": null, "detections": ["1781246735.538324-phdtx0"], "sub_labels": [], "thumb_time": 1781246737.994425, "verified_objects": []}	{"frigate_instance_name": "البيت"}	2026-06-12 13:47:49.149419+00	2026-06-12 22:58:52.950885+00	1781246736.668357-jnhzvc	f	\N	\N	\N
8ce5c820-f3a8-4556-b035-c514d65a7582	1781246331.659791-cfhzek	48c9e5dc-6641-4331-91a0-44a1cede5152	cam_02	2026-06-12 06:38:51.659+00	2026-06-12 06:52:01.817+00	alert	f	{"audio": [], "zones": [], "objects": ["person"], "metadata": null, "detections": ["1781247027.314205-bfrzm6", "1781246776.223189-j6optd", "1781246725.233617-d1dalg", "1781246817.309823-3jnf70", "1781246997.419826-xin90l", "1781246441.49469-rmxtz1", "1781246686.730304-3nt0jz", "1781246659.569307-u4lbho", "1781246766.47894-5rjsrg", "1781246670.420106-ozd5dj", "1781245821.429591-fg8dc2"], "sub_labels": [], "thumb_time": 1781247018.900505, "verified_objects": []}	{"frigate_instance_name": "البيت"}	2026-06-12 13:47:49.165068+00	2026-06-12 22:58:52.950885+00	1781246331.659791-cfhzek	f	\N	\N	\N
8fd7a828-b0cb-47cf-9831-4291816d8bb9	1781245987.695163-vb75jg	48c9e5dc-6641-4331-91a0-44a1cede5152	cam_01	2026-06-12 06:33:07.695+00	2026-06-12 06:33:56.592+00	alert	f	{"audio": [], "zones": [], "objects": ["person"], "metadata": null, "detections": ["1781245986.673757-5yur0p"], "sub_labels": [], "thumb_time": 1781245989.048143, "verified_objects": []}	{"frigate_instance_name": "البيت"}	2026-06-12 13:47:49.182317+00	2026-06-12 22:58:52.950885+00	1781245987.695163-vb75jg	f	\N	\N	\N
251d95c4-bcdb-4882-91d9-49702dd4f483	1781245294.179969-xcrbe1	48c9e5dc-6641-4331-91a0-44a1cede5152	cam_01	2026-06-12 06:21:34.179+00	2026-06-12 06:21:38.491+00	alert	f	{"audio": [], "zones": [], "objects": ["person"], "metadata": null, "detections": ["1781245293.059049-oytqgf"], "sub_labels": [], "thumb_time": 1781245295.565926, "verified_objects": []}	{"frigate_instance_name": "البيت"}	2026-06-12 13:47:49.19593+00	2026-06-12 22:58:52.950885+00	1781245294.179969-xcrbe1	f	\N	\N	\N
dad13db6-e556-468d-8c40-6774a682fe82	1781244778.879642-w4koy2	48c9e5dc-6641-4331-91a0-44a1cede5152	cam_01	2026-06-12 06:12:58.879+00	2026-06-12 06:12:58.879+00	alert	f	{"audio": [], "zones": [], "objects": ["person"], "metadata": null, "detections": ["1781244777.758354-jsamgo"], "sub_labels": [], "thumb_time": 1781244780.135905, "verified_objects": []}	{"frigate_instance_name": "البيت"}	2026-06-12 13:47:49.210424+00	2026-06-12 22:58:52.950885+00	1781244778.879642-w4koy2	f	\N	\N	\N
f45deef2-f7a6-4d27-b6f3-037981678816	1781244534.486181-a3sqbu	48c9e5dc-6641-4331-91a0-44a1cede5152	cam_01	2026-06-12 06:08:54.486+00	2026-06-12 06:09:03.448+00	alert	f	{"audio": [], "zones": [], "objects": ["person"], "metadata": null, "detections": ["1781244533.526593-f5yqjo"], "sub_labels": [], "thumb_time": 1781244535.946089, "verified_objects": []}	{"frigate_instance_name": "البيت"}	2026-06-12 13:47:49.223537+00	2026-06-12 22:58:52.950885+00	1781244534.486181-a3sqbu	f	\N	\N	\N
4afc02a5-f0cc-4c10-bbfe-afa21b8b1d8c	1781243858.051661-lvzvkd	48c9e5dc-6641-4331-91a0-44a1cede5152	cam_01	2026-06-12 05:57:38.051+00	2026-06-12 05:57:49.197+00	alert	f	{"audio": [], "zones": [], "objects": ["person"], "metadata": null, "detections": ["1781243856.978831-0mhegb"], "sub_labels": [], "thumb_time": 1781243859.502111, "verified_objects": []}	{"frigate_instance_name": "البيت"}	2026-06-12 13:47:49.237505+00	2026-06-12 22:58:52.950885+00	1781243858.051661-lvzvkd	f	\N	\N	\N
7f5a9724-f3a0-4e50-b6cb-15a004a41a8b	1781242947.248437-bvhu3r	48c9e5dc-6641-4331-91a0-44a1cede5152	cam_01	2026-06-12 05:42:27.248+00	2026-06-12 05:43:23.763+00	alert	f	{"audio": [], "zones": [], "objects": ["person"], "metadata": null, "detections": ["1781242946.51861-zrrxv5"], "sub_labels": [], "thumb_time": 1781242948.294231, "verified_objects": []}	{"frigate_instance_name": "البيت"}	2026-06-12 13:47:49.251421+00	2026-06-12 22:58:52.950885+00	1781242947.248437-bvhu3r	f	\N	\N	\N
41d96637-ddcc-4fc9-9110-3e2bbed43017	1781241881.983432-4rdg74	48c9e5dc-6641-4331-91a0-44a1cede5152	cam_01	2026-06-12 05:24:41.983+00	2026-06-12 05:25:02.475+00	alert	f	{"audio": [], "zones": [], "objects": ["person"], "metadata": null, "detections": ["1781241881.302866-wipupc"], "sub_labels": [], "thumb_time": 1781241883.145999, "verified_objects": []}	{"frigate_instance_name": "البيت"}	2026-06-12 13:47:49.264461+00	2026-06-12 22:58:52.950885+00	1781241881.983432-4rdg74	f	\N	\N	\N
78be3698-5d7b-4c92-823c-41b6d448f24f	1781241079.52989-j0y9vi	48c9e5dc-6641-4331-91a0-44a1cede5152	cam_01	2026-06-12 05:11:19.529+00	2026-06-12 05:12:48.715+00	alert	f	{"audio": [], "zones": [], "objects": ["person"], "metadata": null, "detections": ["1781241109.241325-m8rncf", "1781241067.377031-m8vomx", "1781241140.191349-1jjjwd", "1781241110.731383-8vsink"], "sub_labels": [], "thumb_time": 1781241115.572759, "verified_objects": []}	{"frigate_instance_name": "البيت"}	2026-06-12 13:47:49.276166+00	2026-06-12 22:58:52.950885+00	1781241079.52989-j0y9vi	f	\N	\N	\N
ee20f9fe-1305-41d5-8f1a-0e47952fc6ed	1781240514.889932-picw2i	48c9e5dc-6641-4331-91a0-44a1cede5152	cam_01	2026-06-12 05:01:54.889+00	2026-06-12 05:02:10.219+00	alert	f	{"audio": [], "zones": [], "objects": ["person"], "metadata": null, "detections": ["1781240514.182854-5ki4ve"], "sub_labels": [], "thumb_time": 1781240515.804292, "verified_objects": []}	{"frigate_instance_name": "البيت"}	2026-06-12 13:47:49.292689+00	2026-06-12 22:58:52.950885+00	1781240514.889932-picw2i	f	\N	\N	\N
1c22a5ab-bbd4-4f64-ad38-340f80623d31	1781239946.828741-aewbcx	48c9e5dc-6641-4331-91a0-44a1cede5152	cam_01	2026-06-12 04:52:26.828+00	2026-06-12 04:52:27.64+00	alert	f	{"audio": [], "zones": [], "objects": ["person"], "metadata": null, "detections": ["1781239946.087235-8vm8vj"], "sub_labels": [], "thumb_time": 1781239947.830552, "verified_objects": []}	{"frigate_instance_name": "البيت"}	2026-06-12 13:47:49.305575+00	2026-06-12 22:58:52.950885+00	1781239946.828741-aewbcx	f	\N	\N	\N
dcca8581-ef3e-420e-bc70-00b00fea03ca	1781239436.116206-4x1u05	48c9e5dc-6641-4331-91a0-44a1cede5152	cam_01	2026-06-12 04:43:56.116+00	2026-06-12 04:43:56.85+00	alert	f	{"audio": [], "zones": [], "objects": ["person"], "metadata": null, "detections": ["1781239435.290336-69xh18"], "sub_labels": [], "thumb_time": 1781239437.030801, "verified_objects": []}	{"frigate_instance_name": "البيت"}	2026-06-12 13:47:49.317928+00	2026-06-12 22:58:52.950885+00	1781239436.116206-4x1u05	f	\N	\N	\N
a21ecce0-324f-4c07-b5b3-501f24d83aa7	1781238915.276105-5qrxp2	48c9e5dc-6641-4331-91a0-44a1cede5152	cam_01	2026-06-12 04:35:15.276+00	2026-06-12 04:35:49.849+00	alert	f	{"audio": [], "zones": [], "objects": ["person"], "metadata": null, "detections": ["1781238948.00091-lydybj", "1781238914.539766-bsgqsc"], "sub_labels": [], "thumb_time": 1781238916.361432, "verified_objects": []}	{"frigate_instance_name": "البيت"}	2026-06-12 13:47:49.330723+00	2026-06-12 22:58:52.950885+00	1781238915.276105-5qrxp2	f	\N	\N	\N
8f976e7b-e837-4e14-b48b-a779627cf6b3	1781238428.84368-s3ohs6	48c9e5dc-6641-4331-91a0-44a1cede5152	cam_01	2026-06-12 04:27:08.843+00	2026-06-12 04:27:12.048+00	alert	f	{"audio": [], "zones": [], "objects": ["person"], "metadata": null, "detections": ["1781238428.05636-0jdlm6"], "sub_labels": [], "thumb_time": 1781238429.788645, "verified_objects": []}	{"frigate_instance_name": "البيت"}	2026-06-12 13:47:49.343065+00	2026-06-12 22:58:52.950885+00	1781238428.84368-s3ohs6	f	\N	\N	\N
90604a00-9bdf-4c61-8069-e37f6f2b26c8	1781237469.136851-40c9k6	48c9e5dc-6641-4331-91a0-44a1cede5152	cam_01	2026-06-12 04:11:09.136+00	2026-06-12 04:11:10.812+00	alert	f	{"audio": [], "zones": [], "objects": ["person"], "metadata": null, "detections": ["1781237468.266611-5vnpyb"], "sub_labels": [], "thumb_time": 1781237470.176337, "verified_objects": []}	{"frigate_instance_name": "البيت"}	2026-06-12 13:47:49.356406+00	2026-06-12 22:58:52.950885+00	1781237469.136851-40c9k6	f	\N	\N	\N
509e21f9-8003-4a9f-a707-24a572ed76a4	1781235085.585403-muedab	48c9e5dc-6641-4331-91a0-44a1cede5152	cam_01	2026-06-12 03:31:25.585+00	2026-06-12 03:32:14.057+00	alert	f	{"audio": [], "zones": [], "objects": ["person"], "metadata": null, "detections": ["1781235083.759928-wt232p"], "sub_labels": [], "thumb_time": 1781235086.738495, "verified_objects": []}	{"frigate_instance_name": "البيت"}	2026-06-12 13:47:49.371561+00	2026-06-12 22:58:52.950885+00	1781235085.585403-muedab	f	\N	\N	\N
2621e63c-b631-47df-b0f7-4dfc0202cdc6	1781279667.208779-2no2rg	48c9e5dc-6641-4331-91a0-44a1cede5152	cam_01	2026-06-12 15:54:27.208+00	2026-06-12 15:54:27.208+00	alert	f	{"audio": [], "zones": [], "objects": ["person"], "metadata": null, "detections": ["1781279513.550186-745afn"], "sub_labels": [], "thumb_time": 1781279683.501888, "verified_objects": []}	{"frigate_instance_name": "البيت"}	2026-06-12 15:55:40.330784+00	2026-06-12 22:58:52.950885+00	1781279667.208779-2no2rg	f	\N	\N	\N
03ab8303-2503-4c70-a90f-ac9f56c1e946	1781279497.677633-2r2jy2	48c9e5dc-6641-4331-91a0-44a1cede5152	cam_01	2026-06-12 15:51:37.677+00	2026-06-12 15:53:18.676+00	alert	f	{"audio": [], "zones": [], "objects": ["person"], "metadata": null, "detections": ["1781279497.677633-9xwfcu", "1781279531.374537-u9izbn", "1781279482.850635-we3yia", "1781279513.550186-745afn"], "sub_labels": [], "thumb_time": 1781279581.27735, "verified_objects": []}	{"frigate_instance_name": "البيت"}	2026-06-12 15:55:40.336519+00	2026-06-12 22:58:52.950885+00	1781279497.677633-2r2jy2	f	\N	\N	\N
11724ab2-59f5-48c5-9316-e0335b533e1f	1781279255.161627-rnqke3	48c9e5dc-6641-4331-91a0-44a1cede5152	cam_01	2026-06-12 15:47:35.161+00	2026-06-12 15:47:35.161+00	alert	f	{"audio": [], "zones": [], "objects": ["person"], "metadata": null, "detections": ["1781279238.295769-qy5z6d"], "sub_labels": [], "thumb_time": 1781279275.689848, "verified_objects": []}	{"frigate_instance_name": "البيت"}	2026-06-12 15:55:40.341095+00	2026-06-12 22:58:52.950885+00	1781279255.161627-rnqke3	f	\N	\N	\N
1d8d298e-d1fa-429b-9883-6aae12671e57	1781279153.571928-ksnpfk	48c9e5dc-6641-4331-91a0-44a1cede5152	cam_03	2026-06-12 15:45:53.571+00	2026-06-12 15:52:09.025+00	alert	f	{"audio": [], "zones": [], "objects": ["car"], "metadata": null, "detections": ["1781278188.188238-fq1x9c"], "sub_labels": [], "thumb_time": 1781279167.149215, "verified_objects": []}	{"frigate_instance_name": "البيت"}	2026-06-12 15:55:40.362641+00	2026-06-12 22:58:52.950885+00	1781279153.571928-ksnpfk	f	\N	\N	\N
d779f356-fe80-46e1-865d-1c4e56a84821	1781278981.872072-vktv6n	48c9e5dc-6641-4331-91a0-44a1cede5152	cam_01	2026-06-12 15:43:01.872+00	2026-06-12 15:43:01.872+00	alert	f	{"audio": [], "zones": [], "objects": ["person"], "metadata": null, "detections": ["1781278887.253494-9hqtga"], "sub_labels": [], "thumb_time": 1781279002.507928, "verified_objects": []}	{"frigate_instance_name": "البيت"}	2026-06-12 15:55:40.367395+00	2026-06-12 22:58:52.950885+00	1781278981.872072-vktv6n	f	\N	\N	\N
aaa9f5e6-a30a-4e60-99b3-b8d198ff4e72	1781278887.253494-c2vu51	48c9e5dc-6641-4331-91a0-44a1cede5152	cam_01	2026-06-12 15:41:27.253+00	2026-06-12 15:41:27.253+00	alert	f	{"audio": [], "zones": [], "objects": ["person"], "metadata": null, "detections": ["1781278832.597674-tu5mr6"], "sub_labels": [], "thumb_time": 1781278899.15607, "verified_objects": []}	{"frigate_instance_name": "البيت"}	2026-06-12 15:55:40.371442+00	2026-06-12 22:58:52.950885+00	1781278887.253494-c2vu51	f	\N	\N	\N
2d351668-b0c9-434f-8843-cbcf5d01846a	1781277633.268434-bqqoyj	48c9e5dc-6641-4331-91a0-44a1cede5152	cam_01	2026-06-12 15:20:33.268+00	2026-06-12 15:22:55.285+00	alert	f	{"audio": [], "zones": [], "objects": ["person"], "metadata": null, "detections": ["1781277664.636272-ijm1wo", "1781277711.632803-jj2mhe", "1781277743.695379-lnuka6", "1781277192.347177-i7nksb"], "sub_labels": [], "thumb_time": 1781277697.111748, "verified_objects": []}	{"frigate_instance_name": "البيت"}	2026-06-12 15:55:40.376736+00	2026-06-12 22:58:52.950885+00	1781277633.268434-bqqoyj	f	\N	\N	\N
4b7e0342-00f0-4b81-af32-a1a4dde85584	1781276974.650506-4w2p6i	48c9e5dc-6641-4331-91a0-44a1cede5152	cam_01	2026-06-12 15:09:34.65+00	2026-06-12 15:19:30.996+00	alert	f	{"audio": [], "zones": [], "objects": ["person"], "metadata": null, "detections": ["1781277099.275324-gwtp7a", "1781277083.126417-9r55e7", "1781277023.221448-p671gy", "1781276974.650506-n8e84z", "1781277132.687991-ws08nc", "1781277083.126417-lwg7ak", "1781276073.95235-57fc78", "1781277161.462296-2x6kp3", "1781277192.347177-i7nksb", "1781276956.593213-ugn4o6"], "sub_labels": [], "thumb_time": 1781277193.887718, "verified_objects": []}	{"frigate_instance_name": "البيت"}	2026-06-12 15:55:40.382333+00	2026-06-12 22:58:52.950885+00	1781276974.650506-4w2p6i	f	\N	\N	\N
79877f7e-1505-4e2f-b811-fab0d5aa4e71	1781276716.532803-ahjdpn	48c9e5dc-6641-4331-91a0-44a1cede5152	cam_03	2026-06-12 15:05:16.532+00	2026-06-12 15:29:28.452+00	alert	f	{"audio": [], "zones": [], "objects": ["car"], "metadata": null, "detections": ["1781276685.630254-3qfujj"], "sub_labels": [], "thumb_time": 1781276730.208799, "verified_objects": []}	{"frigate_instance_name": "البيت"}	2026-06-12 15:55:40.386265+00	2026-06-12 22:58:52.950885+00	1781276716.532803-ahjdpn	f	\N	\N	\N
2d134c64-b07a-450f-9a0e-04fdd350c35b	1781276666.660441-txhuik	48c9e5dc-6641-4331-91a0-44a1cede5152	cam_01	2026-06-12 15:04:26.66+00	2026-06-12 15:04:58.789+00	alert	f	{"audio": [], "zones": [], "objects": ["person"], "metadata": null, "detections": ["1781276631.723696-rsq1zl"], "sub_labels": [], "thumb_time": 1781276682.273176, "verified_objects": []}	{"frigate_instance_name": "البيت"}	2026-06-12 15:55:40.391353+00	2026-06-12 22:58:52.950885+00	1781276666.660441-txhuik	f	\N	\N	\N
46a232ab-ef73-4989-993f-838e6f87b5ea	1781276436.518351-8w2ewr	48c9e5dc-6641-4331-91a0-44a1cede5152	cam_01	2026-06-12 15:00:36.518+00	2026-06-12 15:00:36.518+00	alert	f	{"audio": [], "zones": [], "objects": ["person"], "metadata": null, "detections": ["1781276402.24077-lby4fz"], "sub_labels": [], "thumb_time": 1781276454.958755, "verified_objects": []}	{"frigate_instance_name": "البيت"}	2026-06-12 15:55:40.397841+00	2026-06-12 22:58:52.950885+00	1781276436.518351-8w2ewr	f	\N	\N	\N
3df92b84-d979-439c-bbdb-ea06f16ba392	1781276239.822283-76uh7j	48c9e5dc-6641-4331-91a0-44a1cede5152	cam_01	2026-06-12 14:57:19.822+00	2026-06-12 14:58:41.636+00	alert	f	{"audio": [], "zones": [], "objects": ["person"], "metadata": null, "detections": ["1781276223.749445-zhgxft", "1781275249.526663-pqwo9a"], "sub_labels": [], "thumb_time": 1781276259.646728, "verified_objects": []}	{"frigate_instance_name": "البيت"}	2026-06-12 15:55:40.40306+00	2026-06-12 22:58:52.950885+00	1781276239.822283-76uh7j	f	\N	\N	\N
fc391f65-1680-4d3e-a71d-9297c1fd95c3	1781275886.479259-l5qihx	48c9e5dc-6641-4331-91a0-44a1cede5152	cam_03	2026-06-12 14:51:26.479+00	2026-06-12 14:51:54.794+00	alert	f	{"audio": [], "zones": [], "objects": ["car"], "metadata": null, "detections": ["1781274362.932263-n2zdb6"], "sub_labels": [], "thumb_time": 1781275899.810456, "verified_objects": []}	{"frigate_instance_name": "البيت"}	2026-06-12 15:55:40.417132+00	2026-06-12 22:58:52.950885+00	1781275886.479259-l5qihx	f	\N	\N	\N
95349ce8-a8ef-4567-8863-3b0a622f9f7f	1781274931.624586-1uwoes	48c9e5dc-6641-4331-91a0-44a1cede5152	cam_01	2026-06-12 14:35:31.624+00	2026-06-12 14:36:48.392+00	alert	f	{"audio": [], "zones": [], "objects": ["person"], "metadata": null, "detections": ["1781274915.189286-e7k04r", "1781274994.155435-ho6fue", "1781274978.109276-syvxh7", "1781274915.189286-679gib"], "sub_labels": [], "thumb_time": 1781274946.450231, "verified_objects": []}	{"frigate_instance_name": "البيت"}	2026-06-12 15:55:40.432318+00	2026-06-12 22:58:52.950885+00	1781274931.624586-1uwoes	f	\N	\N	\N
a5e47539-e54a-463b-9a52-97b5af717156	1781274100.025654-nsbw8p	48c9e5dc-6641-4331-91a0-44a1cede5152	cam_02	2026-06-12 14:21:40.025+00	2026-06-12 14:32:13.112+00	alert	f	{"audio": [], "zones": [], "objects": ["person"], "metadata": null, "detections": ["1781274095.086472-ivv8ci", "1781274655.610019-8rlrix"], "sub_labels": [], "thumb_time": 1781274105.427749, "verified_objects": []}	{"frigate_instance_name": "البيت"}	2026-06-12 15:55:40.446469+00	2026-06-12 22:58:52.950885+00	1781274100.025654-nsbw8p	f	\N	\N	\N
5d1b366c-270c-45d3-b955-56c44ece4f42	1781273534.393652-05bxiw	48c9e5dc-6641-4331-91a0-44a1cede5152	cam_02	2026-06-12 14:12:14.393+00	2026-06-12 14:17:23.844+00	alert	f	{"audio": [], "zones": [], "objects": ["person"], "metadata": null, "detections": ["1781273529.022394-ib7yvp", "1781273534.393652-iks403"], "sub_labels": [], "thumb_time": 1781273582.160835, "verified_objects": []}	{"frigate_instance_name": "البيت"}	2026-06-12 15:55:40.458428+00	2026-06-12 22:58:52.950885+00	1781273534.393652-05bxiw	f	\N	\N	\N
f5c14206-2755-4115-bf81-7f8bfd512702	1781272896.117774-iahp3t	48c9e5dc-6641-4331-91a0-44a1cede5152	cam_02	2026-06-12 14:01:36.117+00	2026-06-12 14:11:07.246+00	alert	f	{"audio": [], "zones": [], "objects": ["person"], "metadata": null, "detections": ["1781273111.906178-oh91dm", "1781272493.049535-n7cco9", "1781273225.559434-ghkw6o", "1781272890.363032-bh0oib", "1781273372.776304-5hsyu4", "1781273211.798281-ihof47"], "sub_labels": [], "thumb_time": 1781273130.184704, "verified_objects": []}	{"frigate_instance_name": "البيت"}	2026-06-12 15:55:40.470264+00	2026-06-12 22:58:52.950885+00	1781272896.117774-iahp3t	f	\N	\N	\N
9c6cd760-d07f-4ebc-8cea-690aa5f3e937	1781272493.049535-ues5ti	48c9e5dc-6641-4331-91a0-44a1cede5152	cam_02	2026-06-12 13:54:53.049+00	2026-06-12 13:56:59.438+00	alert	f	{"audio": [], "zones": [], "objects": ["person"], "metadata": null, "detections": ["1781272487.488578-e68tui", "1781272493.049535-3dd0sl", "1781272493.049535-n7cco9"], "sub_labels": [], "thumb_time": 1781272506.929825, "verified_objects": []}	{"frigate_instance_name": "البيت"}	2026-06-12 15:55:40.484094+00	2026-06-12 22:58:52.950885+00	1781272493.049535-ues5ti	f	\N	\N	\N
01901da2-bd93-4911-93df-eec8626f0a7d	1781293315.292819-jwv21n	48c9e5dc-6641-4331-91a0-44a1cede5152	cam_01	2026-06-12 19:41:55.292+00	2026-06-12 19:41:55.292+00	alert	f	{"audio": [], "zones": [], "objects": ["person"], "metadata": null, "detections": ["1781293303.828793-ecl7b4"], "sub_labels": [], "thumb_time": 1781293322.866793, "verified_objects": []}	{"frigate_instance_name": "البيت"}	2026-06-12 22:39:34.424834+00	2026-06-12 22:58:52.950885+00	1781293315.292819-jwv21n	f	\N	\N	\N
6ab1ade5-18f9-4966-b609-8fe3f94efb6b	1781286366.24065-nj07nx	48c9e5dc-6641-4331-91a0-44a1cede5152	cam_01	2026-06-12 17:46:06.24+00	2026-06-12 17:46:35.376+00	alert	f	{"audio": [], "zones": [], "objects": ["person"], "metadata": null, "detections": ["1781285610.617247-wc1kgy"], "sub_labels": [], "thumb_time": 1781286382.426758, "verified_objects": []}	{"frigate_instance_name": "البيت"}	2026-06-12 22:39:34.452217+00	2026-06-12 22:58:52.950885+00	1781286366.24065-nj07nx	f	\N	\N	\N
7f350c11-e9dd-400c-b53b-cdce9374c91a	1781285802.709257-c6346o	48c9e5dc-6641-4331-91a0-44a1cede5152	cam_01	2026-06-12 17:36:42.709+00	2026-06-12 17:43:07.208+00	alert	f	{"audio": [], "zones": [], "objects": ["person"], "metadata": null, "detections": ["1781284388.7563-7oqpuk", "1781286170.042456-cjzch2", "1781285771.67229-bm76j4", "1781286019.627254-cqeidr"], "sub_labels": [], "thumb_time": 1781286020.792782, "verified_objects": []}	{"frigate_instance_name": "البيت"}	2026-06-12 22:39:34.474201+00	2026-06-12 22:58:52.950885+00	1781285802.709257-c6346o	f	\N	\N	\N
7b0905b5-26d6-42c2-94b7-41918c4b7c55	1781285183.106606-wfaehr	48c9e5dc-6641-4331-91a0-44a1cede5152	cam_01	2026-06-12 17:26:23.106+00	2026-06-12 17:28:42.916+00	alert	f	{"audio": [], "zones": [], "objects": ["person"], "metadata": null, "detections": ["1781285167.318551-6561gs", "1781285138.93828-50im4r"], "sub_labels": [], "thumb_time": 1781285227.828803, "verified_objects": []}	{"frigate_instance_name": "البيت"}	2026-06-12 22:39:34.497056+00	2026-06-12 22:58:52.950885+00	1781285183.106606-wfaehr	f	\N	\N	\N
cb6a84c6-e201-49a5-b1ba-a09c4c68f3a3	1781284426.931486-3z40cf	48c9e5dc-6641-4331-91a0-44a1cede5152	cam_01	2026-06-12 17:13:46.931+00	2026-06-12 17:25:23.837+00	alert	f	{"audio": [], "zones": [], "objects": ["person"], "metadata": null, "detections": ["1781284343.148474-bn8afo", "1781281749.59056-sxj3xb"], "sub_labels": [], "thumb_time": 1781284512.219477, "verified_objects": []}	{"frigate_instance_name": "البيت"}	2026-06-12 22:39:34.531785+00	2026-06-12 22:58:52.950885+00	1781284426.931486-3z40cf	f	\N	\N	\N
02f52884-f849-43e0-af28-07f4fe908511	1781283690.134361-7kwnux	48c9e5dc-6641-4331-91a0-44a1cede5152	cam_01	2026-06-12 17:01:30.134+00	2026-06-12 17:02:52.873+00	alert	f	{"audio": [], "zones": [], "objects": ["person"], "metadata": null, "detections": ["1781283675.07575-s1lhgy"], "sub_labels": [], "thumb_time": 1781283707.529905, "verified_objects": []}	{"frigate_instance_name": "البيت"}	2026-06-12 22:39:34.565869+00	2026-06-12 22:58:52.950885+00	1781283690.134361-7kwnux	f	\N	\N	\N
57cf61b1-deaf-4b7b-82bc-c1accfec2ba7	1781283441.825091-pdl72g	48c9e5dc-6641-4331-91a0-44a1cede5152	cam_01	2026-06-12 16:57:21.825+00	2026-06-12 16:57:50.342+00	alert	f	{"audio": [], "zones": [], "objects": ["person"], "metadata": null, "detections": ["1781283428.712185-gcgrqz"], "sub_labels": [], "thumb_time": 1781283457.312065, "verified_objects": []}	{"frigate_instance_name": "البيت"}	2026-06-12 22:39:34.603869+00	2026-06-12 22:58:52.950885+00	1781283441.825091-pdl72g	f	\N	\N	\N
6c758213-c61e-4684-9f84-5f41ced43c43	1781282368.993671-3xt02n	48c9e5dc-6641-4331-91a0-44a1cede5152	cam_01	2026-06-12 16:39:28.993+00	2026-06-12 16:40:46.111+00	alert	f	{"audio": [], "zones": [], "objects": ["person"], "metadata": null, "detections": ["1781282350.965298-nidcl9", "1781282350.965298-5gx0m5", "1781282368.993671-yjijjq"], "sub_labels": [], "thumb_time": 1781282385.187464, "verified_objects": []}	{"frigate_instance_name": "البيت"}	2026-06-12 22:39:34.65371+00	2026-06-12 22:58:52.950885+00	1781282368.993671-3xt02n	f	\N	\N	\N
7ba72a4d-b56b-4dba-87c7-5536b326e5b2	1781281900.309116-6ygj1b	48c9e5dc-6641-4331-91a0-44a1cede5152	cam_01	2026-06-12 16:31:40.309+00	2026-06-12 16:32:44.922+00	alert	f	{"audio": [], "zones": [], "objects": ["person"], "metadata": null, "detections": ["1781281886.064289-vkx20b"], "sub_labels": [], "thumb_time": 1781281914.033772, "verified_objects": []}	{"frigate_instance_name": "البيت"}	2026-06-12 22:39:34.710359+00	2026-06-12 22:58:52.950885+00	1781281900.309116-6ygj1b	f	\N	\N	\N
e4217e6d-5736-4af4-8e2a-ced4a4e304e1	1781281737.012898-8vdozu	48c9e5dc-6641-4331-91a0-44a1cede5152	cam_01	2026-06-12 16:28:57.012+00	2026-06-12 16:29:24.812+00	alert	f	{"audio": [], "zones": [], "objects": ["person"], "metadata": null, "detections": ["1781281723.355463-sqyvyu"], "sub_labels": [], "thumb_time": 1781281751.348047, "verified_objects": []}	{"frigate_instance_name": "البيت"}	2026-06-12 22:39:34.788806+00	2026-06-12 22:58:52.950885+00	1781281737.012898-8vdozu	f	\N	\N	\N
e687112e-2a39-4d18-be3a-c7dbfcd5bed2	1781281580.896882-4emjcv	48c9e5dc-6641-4331-91a0-44a1cede5152	cam_01	2026-06-12 16:26:20.896+00	2026-06-12 16:26:33.985+00	alert	f	{"audio": [], "zones": [], "objects": ["person"], "metadata": null, "detections": ["1781281567.877562-dmxu1a"], "sub_labels": [], "thumb_time": 1781281595.372793, "verified_objects": []}	{"frigate_instance_name": "البيت"}	2026-06-12 22:39:34.888326+00	2026-06-12 22:58:52.950885+00	1781281580.896882-4emjcv	f	\N	\N	\N
058e77fd-e601-4a3e-b082-551a64fb619d	1781280554.53775-vqy467	48c9e5dc-6641-4331-91a0-44a1cede5152	cam_01	2026-06-12 16:09:14.537+00	2026-06-12 16:10:48.355+00	alert	f	{"audio": [], "zones": [], "objects": ["person"], "metadata": null, "detections": ["1781280542.170456-g5zqgn", "1781280542.170456-fg6ltz"], "sub_labels": [], "thumb_time": 1781280583.876902, "verified_objects": []}	{"frigate_instance_name": "البيت"}	2026-06-12 22:39:35.031504+00	2026-06-12 22:58:52.950885+00	1781280554.53775-vqy467	f	\N	\N	\N
af078b29-47f1-4689-b091-3aa1458f6dc8	1781279771.394178-etfupy	48c9e5dc-6641-4331-91a0-44a1cede5152	cam_01	2026-06-12 15:56:11.394+00	2026-06-12 15:57:15.306+00	alert	f	{"audio": [], "zones": [], "objects": ["person"], "metadata": null, "detections": ["1781279754.683539-80jpdc"], "sub_labels": [], "thumb_time": 1781279787.977891, "verified_objects": []}	{"frigate_instance_name": "البيت"}	2026-06-12 22:39:35.274255+00	2026-06-12 22:58:52.950885+00	1781279771.394178-etfupy	f	\N	\N	\N
\.


--
-- Data for Name: frigate_stats_history; Type: TABLE DATA; Schema: public; Owner: postgres
--

COPY public.frigate_stats_history (id, frigate_instance_id, recorded_at, cpu_usages, gpu_usages, memory_usage, detector_speeds, camera_fps, service_info) FROM stdin;
\.


--
-- Data for Name: frigate_sync_logs; Type: TABLE DATA; Schema: public; Owner: postgres
--

COPY public.frigate_sync_logs (id, frigate_instance_id, sync_type, status, events_processed, events_inserted, events_skipped, duration_ms, error_message, started_at, completed_at) FROM stdin;
c026dcb4-1437-40c7-9a5c-45c5dccb89b5	48c9e5dc-6641-4331-91a0-44a1cede5152	events	completed	200	200	0	\N	\N	2026-06-12 22:55:47.374+00	2026-06-12 22:55:48.893+00
a6dd60aa-edc1-4db1-81b5-f2b4400d377f	48c9e5dc-6641-4331-91a0-44a1cede5152	events	completed	200	0	200	\N	\N	2026-06-12 23:02:46.177+00	2026-06-12 23:02:46.737+00
\.


--
-- Data for Name: frigate_timeline; Type: TABLE DATA; Schema: public; Owner: postgres
--

COPY public.frigate_timeline (id, camera_id, start_time, end_time, segment_type, file_path, duration_seconds, created_at, frigate_instance_id, class_type, data, metadata, entry_id) FROM stdin;
7db00759-7fa7-46b8-bdc6-71aa25588032	\N	2026-06-12 03:24:25.291+00	2026-06-12 03:25:25.291+00	detection	\N	60	2026-06-12 13:47:49.486393+00	48c9e5dc-6641-4331-91a0-44a1cede5152	visible	{"box": [0.9359375, 0.7388888888888889, 0.059375, 0.21666666666666667], "label": "person", "score": 0.71484375, "region": [0.5, 0.1111111111111111, 0.5, 0.8888888888888888], "attribute": "", "sub_label": null}	{"camera_name": "cam_01", "frigate_instance_name": "البيت"}	48c9e5dc-6641-4331-91a0-44a1cede5152_cam_01_1781234665.291284_visible
e16e9569-d6bd-45db-b090-fff141f6bbc1	\N	2026-06-12 03:24:34.826+00	2026-06-12 03:25:34.826+00	detection	\N	60	2026-06-12 13:47:49.493605+00	48c9e5dc-6641-4331-91a0-44a1cede5152	gone	{"box": [0.61875, 0.7472222222222222, 0.040625, 0.09444444444444444], "label": "person", "score": 0.65234375, "region": [0.5, 0.1111111111111111, 0.5, 0.8888888888888888], "attribute": "", "sub_label": null}	{"camera_name": "cam_01", "frigate_instance_name": "البيت"}	48c9e5dc-6641-4331-91a0-44a1cede5152_cam_01_1781234674.826475_gone
bc0fd753-3cae-4525-a942-6d7cc8e4981c	\N	2026-06-12 03:31:23.759+00	2026-06-12 03:32:23.759+00	detection	\N	60	2026-06-12 13:47:49.499864+00	48c9e5dc-6641-4331-91a0-44a1cede5152	visible	{"box": [0.7453125, 0.7277777777777777, 0.0671875, 0.2361111111111111], "label": "person", "score": 0.76953125, "region": [0.5, 0.1111111111111111, 0.5, 0.8888888888888888], "attribute": "", "sub_label": null}	{"camera_name": "cam_01", "frigate_instance_name": "البيت"}	48c9e5dc-6641-4331-91a0-44a1cede5152_cam_01_1781235083.759928_visible
9a8db8e1-4bc7-4c74-a3ea-b5822dcd14cb	\N	2026-06-12 03:32:14.057+00	2026-06-12 03:33:14.057+00	detection	\N	60	2026-06-12 13:47:49.505168+00	48c9e5dc-6641-4331-91a0-44a1cede5152	gone	{"box": [0.759375, 0.6805555555555556, 0.03125, 0.1638888888888889], "label": "person", "score": 0.640625, "region": [0.48125, 0.1111111111111111, 0.5, 0.8888888888888888], "attribute": "", "sub_label": null}	{"camera_name": "cam_01", "frigate_instance_name": "البيت"}	48c9e5dc-6641-4331-91a0-44a1cede5152_cam_01_1781235134.057282_gone
f0ce6db0-b099-4247-835a-ec5768e31c5c	\N	2026-06-12 03:36:38.889+00	2026-06-12 03:37:38.889+00	detection	\N	60	2026-06-12 13:47:49.510565+00	48c9e5dc-6641-4331-91a0-44a1cede5152	visible	{"box": [0.8890625, 0.725, 0.059375, 0.2222222222222222], "label": "person", "score": 0.53515625, "region": [0.5, 0.1111111111111111, 0.5, 0.8888888888888888], "attribute": "", "sub_label": null}	{"camera_name": "cam_01", "frigate_instance_name": "البيت"}	48c9e5dc-6641-4331-91a0-44a1cede5152_cam_01_1781235398.889411_visible
2f2605a2-a2fe-4423-ab29-6de11fe1176e	\N	2026-06-12 03:36:56.336+00	2026-06-12 03:37:56.336+00	detection	\N	60	2026-06-12 13:47:49.51657+00	48c9e5dc-6641-4331-91a0-44a1cede5152	gone	{"box": [0.6515625, 0.7083333333333334, 0.0421875, 0.10277777777777777], "label": "person", "score": 0.6640625, "region": [0.3890625, 0.1111111111111111, 0.5, 0.8888888888888888], "attribute": "", "sub_label": null}	{"camera_name": "cam_01", "frigate_instance_name": "البيت"}	48c9e5dc-6641-4331-91a0-44a1cede5152_cam_01_1781235416.33627_gone
02d06b32-6571-4a8c-86ad-4e804958f758	\N	2026-06-12 04:09:17.161+00	2026-06-12 04:10:17.161+00	detection	\N	60	2026-06-12 13:47:49.521356+00	48c9e5dc-6641-4331-91a0-44a1cede5152	visible	{"box": [0.771875, 0.7916666666666666, 0.0734375, 0.20555555555555555], "label": "person", "score": 0.7265625, "region": [0.5, 0.1111111111111111, 0.5, 0.8888888888888888], "attribute": "", "sub_label": null}	{"camera_name": "cam_01", "frigate_instance_name": "البيت"}	48c9e5dc-6641-4331-91a0-44a1cede5152_cam_01_1781237357.161254_visible
57232ddb-56e0-49c0-9647-70f24ed80573	\N	2026-06-12 04:09:18.765+00	2026-06-12 04:10:18.765+00	detection	\N	60	2026-06-12 13:47:49.543761+00	48c9e5dc-6641-4331-91a0-44a1cede5152	gone	{"box": [0.6828125, 0.6805555555555556, 0.0671875, 0.19444444444444445], "label": "person", "score": 0.55859375, "region": [0.5, 0.1111111111111111, 0.5, 0.8888888888888888], "attribute": "", "sub_label": null}	{"camera_name": "cam_01", "frigate_instance_name": "البيت"}	48c9e5dc-6641-4331-91a0-44a1cede5152_cam_01_1781237358.765266_gone
daca617b-2210-45e5-b5a7-8103e5eda0e2	\N	2026-06-12 04:11:08.266+00	2026-06-12 04:12:08.266+00	detection	\N	60	2026-06-12 13:47:49.548754+00	48c9e5dc-6641-4331-91a0-44a1cede5152	visible	{"box": [0.8421875, 0.8194444444444444, 0.078125, 0.17777777777777778], "label": "person", "score": 0.5859375, "region": [0.5, 0.1111111111111111, 0.5, 0.8888888888888888], "attribute": "", "sub_label": null}	{"camera_name": "cam_01", "frigate_instance_name": "البيت"}	48c9e5dc-6641-4331-91a0-44a1cede5152_cam_01_1781237468.266611_visible
1adb3b64-8f5f-4cb4-8ddf-cfdeb8345d56	\N	2026-06-12 04:11:10.812+00	2026-06-12 04:12:10.812+00	detection	\N	60	2026-06-12 13:47:49.554122+00	48c9e5dc-6641-4331-91a0-44a1cede5152	gone	{"box": [0.728125, 0.7555555555555555, 0.053125, 0.22777777777777777], "label": "person", "score": 0.6953125, "region": [0.5, 0.1111111111111111, 0.5, 0.8888888888888888], "attribute": "", "sub_label": null}	{"camera_name": "cam_01", "frigate_instance_name": "البيت"}	48c9e5dc-6641-4331-91a0-44a1cede5152_cam_01_1781237470.812529_gone
b3e5d6b9-3da6-4923-b297-1abf43315412	\N	2026-06-12 04:22:43.227+00	2026-06-12 04:23:43.227+00	detection	\N	60	2026-06-12 13:47:49.558866+00	48c9e5dc-6641-4331-91a0-44a1cede5152	visible	{"box": [0.7640625, 0.8083333333333333, 0.0953125, 0.18333333333333332], "label": "person", "score": 0.65234375, "region": [0.5, 0.1111111111111111, 0.5, 0.8888888888888888], "attribute": "", "sub_label": null}	{"camera_name": "cam_01", "frigate_instance_name": "البيت"}	48c9e5dc-6641-4331-91a0-44a1cede5152_cam_01_1781238163.227087_visible
26e32d25-65f5-4676-a0fb-a9b30597ebfb	\N	2026-06-12 04:22:44.082+00	2026-06-12 04:23:44.082+00	detection	\N	60	2026-06-12 13:47:49.563144+00	48c9e5dc-6641-4331-91a0-44a1cede5152	gone	{"box": [0.7109375, 0.8583333333333333, 0.109375, 0.1361111111111111], "label": "person", "score": 0.7265625, "region": [0.5, 0.1111111111111111, 0.5, 0.8888888888888888], "attribute": "", "sub_label": null}	{"camera_name": "cam_01", "frigate_instance_name": "البيت"}	48c9e5dc-6641-4331-91a0-44a1cede5152_cam_01_1781238164.08232_gone
7d4b08fb-6ceb-4de7-bd12-2ff238b2224a	\N	2026-06-12 04:23:05.447+00	2026-06-12 04:24:05.447+00	detection	\N	60	2026-06-12 13:47:49.567348+00	48c9e5dc-6641-4331-91a0-44a1cede5152	visible	{"box": [0.771875, 0.7833333333333333, 0.0671875, 0.21388888888888888], "label": "person", "score": 0.76953125, "region": [0.5, 0.1111111111111111, 0.5, 0.8888888888888888], "attribute": "", "sub_label": null}	{"camera_name": "cam_01", "frigate_instance_name": "البيت"}	48c9e5dc-6641-4331-91a0-44a1cede5152_cam_01_1781238185.447802_visible
54a7eec0-0ab1-4524-bee7-9d093cdde60e	\N	2026-06-12 04:23:09.487+00	2026-06-12 04:24:09.487+00	detection	\N	60	2026-06-12 13:47:49.573781+00	48c9e5dc-6641-4331-91a0-44a1cede5152	gone	{"box": [0.690625, 0.6861111111111111, 0.0328125, 0.14444444444444443], "label": "person", "score": 0.51171875, "region": [0.4625, 0.1111111111111111, 0.5, 0.8888888888888888], "attribute": "", "sub_label": null}	{"camera_name": "cam_01", "frigate_instance_name": "البيت"}	48c9e5dc-6641-4331-91a0-44a1cede5152_cam_01_1781238189.487849_gone
37af3292-c4f7-4cc4-8131-57333170bd6a	\N	2026-06-12 04:26:00.711+00	2026-06-12 04:27:00.711+00	detection	\N	60	2026-06-12 13:47:49.579566+00	48c9e5dc-6641-4331-91a0-44a1cede5152	visible	{"box": [0.7375, 0.7861111111111111, 0.065625, 0.2111111111111111], "label": "person", "score": 0.67578125, "region": [0.5, 0.1111111111111111, 0.5, 0.8888888888888888], "attribute": "", "sub_label": null}	{"camera_name": "cam_01", "frigate_instance_name": "البيت"}	48c9e5dc-6641-4331-91a0-44a1cede5152_cam_01_1781238360.711682_visible
748f1afa-6fa1-4925-898a-400549f0f3aa	\N	2026-06-12 04:26:03.047+00	2026-06-12 04:27:03.047+00	detection	\N	60	2026-06-12 13:47:49.584776+00	48c9e5dc-6641-4331-91a0-44a1cede5152	gone	{"box": [0.76875, 0.7166666666666667, 0.0515625, 0.23333333333333334], "label": "person", "score": 0.71484375, "region": [0.5, 0.1111111111111111, 0.5, 0.8888888888888888], "attribute": "", "sub_label": null}	{"camera_name": "cam_01", "frigate_instance_name": "البيت"}	48c9e5dc-6641-4331-91a0-44a1cede5152_cam_01_1781238363.047223_gone
3bb629fe-d14e-4258-b867-ecd00311467f	\N	2026-06-12 04:27:08.056+00	2026-06-12 04:28:08.056+00	detection	\N	60	2026-06-12 13:47:49.600709+00	48c9e5dc-6641-4331-91a0-44a1cede5152	visible	{"box": [0.778125, 0.7805555555555556, 0.0734375, 0.21666666666666667], "label": "person", "score": 0.70703125, "region": [0.5, 0.1111111111111111, 0.5, 0.8888888888888888], "attribute": "", "sub_label": null}	{"camera_name": "cam_01", "frigate_instance_name": "البيت"}	48c9e5dc-6641-4331-91a0-44a1cede5152_cam_01_1781238428.05636_visible
2e007022-9fc5-4cb5-8485-2534770b7c58	\N	2026-06-12 04:31:22.337+00	2026-06-12 04:32:22.337+00	detection	\N	60	2026-06-12 13:47:49.617282+00	48c9e5dc-6641-4331-91a0-44a1cede5152	gone	{"box": [0.69375, 0.6888888888888889, 0.028125, 0.1361111111111111], "label": "person", "score": 0.53515625, "region": [0.5, 0.1111111111111111, 0.5, 0.8888888888888888], "attribute": "", "sub_label": null}	{"camera_name": "cam_01", "frigate_instance_name": "البيت"}	48c9e5dc-6641-4331-91a0-44a1cede5152_cam_01_1781238682.337379_gone
93967c91-76b7-4094-bc25-861361dc697c	\N	2026-06-12 04:33:34.51+00	2026-06-12 04:34:34.51+00	detection	\N	60	2026-06-12 13:47:49.630346+00	48c9e5dc-6641-4331-91a0-44a1cede5152	visible	{"box": [0.771875, 0.7555555555555555, 0.0703125, 0.23055555555555557], "label": "person", "score": 0.74609375, "region": [0.5, 0.1111111111111111, 0.5, 0.8888888888888888], "attribute": "", "sub_label": null}	{"camera_name": "cam_01", "frigate_instance_name": "البيت"}	48c9e5dc-6641-4331-91a0-44a1cede5152_cam_01_1781238814.51098_visible
195a9d94-8eee-42a3-b838-f3bb7bdd6bcb	\N	2026-06-12 04:33:59.838+00	2026-06-12 04:34:59.838+00	detection	\N	60	2026-06-12 13:47:49.647308+00	48c9e5dc-6641-4331-91a0-44a1cede5152	gone	{"box": [0.8421875, 0.8833333333333333, 0.0921875, 0.10833333333333334], "label": "person", "score": 0.57421875, "region": [0.5, 0.1111111111111111, 0.5, 0.8888888888888888], "attribute": "", "sub_label": null}	{"camera_name": "cam_01", "frigate_instance_name": "البيت"}	48c9e5dc-6641-4331-91a0-44a1cede5152_cam_01_1781238839.838316_gone
dff1c1b9-ec70-43ff-af8b-bf874a0067f3	\N	2026-06-12 04:35:48+00	2026-06-12 04:36:48+00	detection	\N	60	2026-06-12 13:47:49.664348+00	48c9e5dc-6641-4331-91a0-44a1cede5152	visible	{"box": [0.7640625, 0.775, 0.06875, 0.2222222222222222], "label": "person", "score": 0.76953125, "region": [0.5, 0.1111111111111111, 0.5, 0.8888888888888888], "attribute": "", "sub_label": null}	{"camera_name": "cam_01", "frigate_instance_name": "البيت"}	48c9e5dc-6641-4331-91a0-44a1cede5152_cam_01_1781238948.00091_visible
075cece6-0abd-46b2-822e-2892e2099b48	\N	2026-06-12 04:36:51.13+00	2026-06-12 04:37:51.13+00	detection	\N	60	2026-06-12 13:47:49.681722+00	48c9e5dc-6641-4331-91a0-44a1cede5152	gone	{"box": [0.7546875, 0.6861111111111111, 0.0515625, 0.18611111111111112], "label": "person", "score": 0.6171875, "region": [0.5, 0.1111111111111111, 0.5, 0.8888888888888888], "attribute": "", "sub_label": null}	{"camera_name": "cam_01", "frigate_instance_name": "البيت"}	48c9e5dc-6641-4331-91a0-44a1cede5152_cam_01_1781239011.13057_gone
5e52c614-c0aa-482c-84b0-b4fe010c1589	\N	2026-06-12 04:43:55.29+00	2026-06-12 04:44:55.29+00	detection	\N	60	2026-06-12 13:47:49.696488+00	48c9e5dc-6641-4331-91a0-44a1cede5152	visible	{"box": [0.7703125, 0.75, 0.053125, 0.2222222222222222], "label": "person", "score": 0.74609375, "region": [0.5, 0.1111111111111111, 0.5, 0.8888888888888888], "attribute": "", "sub_label": null}	{"camera_name": "cam_01", "frigate_instance_name": "البيت"}	48c9e5dc-6641-4331-91a0-44a1cede5152_cam_01_1781239435.290336_visible
c16e57e1-0f49-42ee-b9de-48cf65b8de69	\N	2026-06-12 04:49:23.017+00	2026-06-12 04:50:23.017+00	detection	\N	60	2026-06-12 13:47:49.715957+00	48c9e5dc-6641-4331-91a0-44a1cede5152	gone	{"box": [0.9203125, 0.8416666666666667, 0.078125, 0.15555555555555556], "label": "person", "score": 0.62890625, "region": [0.5, 0.1111111111111111, 0.5, 0.8888888888888888], "attribute": "", "sub_label": null}	{"camera_name": "cam_01", "frigate_instance_name": "البيت"}	48c9e5dc-6641-4331-91a0-44a1cede5152_cam_01_1781239763.017703_gone
2daa5dcb-5972-4994-bf3f-72b43ab1b50e	\N	2026-06-12 04:51:21.625+00	2026-06-12 04:52:21.625+00	detection	\N	60	2026-06-12 13:47:49.733416+00	48c9e5dc-6641-4331-91a0-44a1cede5152	visible	{"box": [0.7734375, 0.7527777777777778, 0.0625, 0.2361111111111111], "label": "person", "score": 0.71484375, "region": [0.5, 0.1111111111111111, 0.5, 0.8888888888888888], "attribute": "", "sub_label": null}	{"camera_name": "cam_01", "frigate_instance_name": "البيت"}	48c9e5dc-6641-4331-91a0-44a1cede5152_cam_01_1781239881.625026_visible
b14b7a18-195d-42af-a16f-cb07919d7262	\N	2026-06-12 04:52:27.64+00	2026-06-12 04:53:27.64+00	detection	\N	60	2026-06-12 13:47:49.750504+00	48c9e5dc-6641-4331-91a0-44a1cede5152	gone	{"box": [0.6671875, 0.7972222222222223, 0.06875, 0.2], "label": "person", "score": 0.67578125, "region": [0.4078125, 0.1111111111111111, 0.5, 0.8888888888888888], "attribute": "", "sub_label": null}	{"camera_name": "cam_01", "frigate_instance_name": "البيت"}	48c9e5dc-6641-4331-91a0-44a1cede5152_cam_01_1781239947.64005_gone
0a752419-a5bd-41ce-82eb-a3682006fef5	\N	2026-06-12 04:59:58.592+00	2026-06-12 05:00:58.592+00	detection	\N	60	2026-06-12 13:47:49.764722+00	48c9e5dc-6641-4331-91a0-44a1cede5152	visible	{"box": [0.7328125, 0.7944444444444444, 0.06875, 0.20277777777777778], "label": "person", "score": 0.7265625, "region": [0.5, 0.1111111111111111, 0.5, 0.8888888888888888], "attribute": "", "sub_label": null}	{"camera_name": "cam_01", "frigate_instance_name": "البيت"}	48c9e5dc-6641-4331-91a0-44a1cede5152_cam_01_1781240398.592141_visible
4dc47411-3dbf-413d-808c-c39e8e7953c8	\N	2026-06-12 05:02:10.219+00	2026-06-12 05:03:10.219+00	detection	\N	60	2026-06-12 13:47:49.781559+00	48c9e5dc-6641-4331-91a0-44a1cede5152	gone	{"box": [0.878125, 0.7083333333333334, 0.053125, 0.21388888888888888], "label": "person", "score": 0.62890625, "region": [0.5, 0.1111111111111111, 0.5, 0.8888888888888888], "attribute": "", "sub_label": null}	{"camera_name": "cam_01", "frigate_instance_name": "البيت"}	48c9e5dc-6641-4331-91a0-44a1cede5152_cam_01_1781240530.219466_gone
7e63ec37-a4d2-4fa6-942e-9ff682c324ee	\N	2026-06-12 05:06:39.039+00	2026-06-12 05:07:39.039+00	detection	\N	60	2026-06-12 13:47:49.7951+00	48c9e5dc-6641-4331-91a0-44a1cede5152	visible	{"box": [0.796875, 0.7638888888888888, 0.0703125, 0.225], "label": "person", "score": 0.734375, "region": [0.5, 0.1111111111111111, 0.5, 0.8888888888888888], "attribute": "", "sub_label": null}	{"camera_name": "cam_01", "frigate_instance_name": "البيت"}	48c9e5dc-6641-4331-91a0-44a1cede5152_cam_01_1781240799.039065_visible
9e9cdc5d-d449-43c9-9862-8a4e61918ef5	\N	2026-06-12 05:11:49.241+00	2026-06-12 05:12:49.241+00	detection	\N	60	2026-06-12 13:47:49.808938+00	48c9e5dc-6641-4331-91a0-44a1cede5152	visible	{"box": [0.76875, 0.775, 0.06875, 0.2222222222222222], "label": "person", "score": 0.7265625, "region": [0.5, 0.1111111111111111, 0.5, 0.8888888888888888], "attribute": "", "sub_label": null}	{"camera_name": "cam_01", "frigate_instance_name": "البيت"}	48c9e5dc-6641-4331-91a0-44a1cede5152_cam_01_1781241109.241325_visible
bf75d52c-e213-4f3c-9980-fdaa0f280df8	\N	2026-06-12 04:26:26.008+00	2026-06-12 04:27:26.008+00	detection	\N	60	2026-06-12 13:47:49.590057+00	48c9e5dc-6641-4331-91a0-44a1cede5152	visible	{"box": [0.771875, 0.7694444444444445, 0.0640625, 0.22777777777777777], "label": "person", "score": 0.76953125, "region": [0.5, 0.1111111111111111, 0.5, 0.8888888888888888], "attribute": "", "sub_label": null}	{"camera_name": "cam_01", "frigate_instance_name": "البيت"}	48c9e5dc-6641-4331-91a0-44a1cede5152_cam_01_1781238386.00809_visible
c2f040de-3c05-4948-8bbf-d92b63f5a302	\N	2026-06-12 04:27:12.048+00	2026-06-12 04:28:12.048+00	detection	\N	60	2026-06-12 13:47:49.605836+00	48c9e5dc-6641-4331-91a0-44a1cede5152	gone	{"box": [0.6921875, 0.6805555555555556, 0.0328125, 0.15], "label": "person", "score": 0.53515625, "region": [0.5, 0.1111111111111111, 0.5, 0.8888888888888888], "attribute": "", "sub_label": null}	{"camera_name": "cam_01", "frigate_instance_name": "البيت"}	48c9e5dc-6641-4331-91a0-44a1cede5152_cam_01_1781238432.048054_gone
e21fd46f-6880-475d-95b9-3e4d03ead267	\N	2026-06-12 04:33:14.681+00	2026-06-12 04:34:14.681+00	detection	\N	60	2026-06-12 13:47:49.621984+00	48c9e5dc-6641-4331-91a0-44a1cede5152	visible	{"box": [0.8984375, 0.7111111111111111, 0.0671875, 0.21388888888888888], "label": "person", "score": 0.640625, "region": [0.5, 0.1111111111111111, 0.5, 0.8888888888888888], "attribute": "", "sub_label": null}	{"camera_name": "cam_01", "frigate_instance_name": "البيت"}	48c9e5dc-6641-4331-91a0-44a1cede5152_cam_01_1781238794.681665_visible
9a5f672e-c174-4fc0-8944-e524bb0c26bc	\N	2026-06-12 04:33:37.094+00	2026-06-12 04:34:37.094+00	detection	\N	60	2026-06-12 13:47:49.636892+00	48c9e5dc-6641-4331-91a0-44a1cede5152	gone	{"box": [0.6765625, 0.6722222222222223, 0.0578125, 0.17777777777777778], "label": "person", "score": 0.5234375, "region": [0.5, 0.1111111111111111, 0.5, 0.8888888888888888], "attribute": "", "sub_label": null}	{"camera_name": "cam_01", "frigate_instance_name": "البيت"}	48c9e5dc-6641-4331-91a0-44a1cede5152_cam_01_1781238817.094311_gone
370f4a50-b76d-47d8-8e5b-83125b72667d	\N	2026-06-12 04:35:14.539+00	2026-06-12 04:36:14.539+00	detection	\N	60	2026-06-12 13:47:49.653366+00	48c9e5dc-6641-4331-91a0-44a1cede5152	visible	{"box": [0.7734375, 0.7527777777777778, 0.0765625, 0.2361111111111111], "label": "person", "score": 0.76171875, "region": [0.5, 0.1111111111111111, 0.5, 0.8888888888888888], "attribute": "", "sub_label": null}	{"camera_name": "cam_01", "frigate_instance_name": "البيت"}	48c9e5dc-6641-4331-91a0-44a1cede5152_cam_01_1781238914.539766_visible
7e098135-7239-43b8-8dc7-f94a432323e5	\N	2026-06-12 04:35:49.849+00	2026-06-12 04:36:49.849+00	detection	\N	60	2026-06-12 13:47:49.669253+00	48c9e5dc-6641-4331-91a0-44a1cede5152	gone	{"box": [0.69375, 0.6972222222222222, 0.0296875, 0.1], "label": "person", "score": 0.5234375, "region": [0.5, 0.1111111111111111, 0.5, 0.8888888888888888], "attribute": "", "sub_label": null}	{"camera_name": "cam_01", "frigate_instance_name": "البيت"}	48c9e5dc-6641-4331-91a0-44a1cede5152_cam_01_1781238949.849163_gone
e54ba964-26c4-4037-ba06-a19df136eb60	\N	2026-06-12 04:39:04.024+00	2026-06-12 04:40:04.024+00	detection	\N	60	2026-06-12 13:47:49.687205+00	48c9e5dc-6641-4331-91a0-44a1cede5152	visible	{"box": [0.7828125, 0.7277777777777777, 0.0546875, 0.23055555555555557], "label": "person", "score": 0.75390625, "region": [0.5, 0.1111111111111111, 0.5, 0.8888888888888888], "attribute": "", "sub_label": null}	{"camera_name": "cam_01", "frigate_instance_name": "البيت"}	48c9e5dc-6641-4331-91a0-44a1cede5152_cam_01_1781239144.024975_visible
13f5a4ae-664f-433d-82de-94503f1229c8	\N	2026-06-12 04:43:56.85+00	2026-06-12 04:44:56.85+00	detection	\N	60	2026-06-12 13:47:49.703698+00	48c9e5dc-6641-4331-91a0-44a1cede5152	gone	{"box": [0.6921875, 0.6833333333333333, 0.03125, 0.14444444444444443], "label": "person", "score": 0.55859375, "region": [0.5, 0.1111111111111111, 0.5, 0.8888888888888888], "attribute": "", "sub_label": null}	{"camera_name": "cam_01", "frigate_instance_name": "البيت"}	48c9e5dc-6641-4331-91a0-44a1cede5152_cam_01_1781239436.850166_gone
1bb5d12a-1843-4d2e-b181-97f2f3cb9d42	\N	2026-06-12 04:51:08.811+00	2026-06-12 04:52:08.811+00	detection	\N	60	2026-06-12 13:47:49.722017+00	48c9e5dc-6641-4331-91a0-44a1cede5152	visible	{"box": [0.7609375, 0.7583333333333333, 0.0953125, 0.23333333333333334], "label": "person", "score": 0.640625, "region": [0.428125, 0.1111111111111111, 0.5, 0.8888888888888888], "attribute": "", "sub_label": null}	{"camera_name": "cam_01", "frigate_instance_name": "البيت"}	48c9e5dc-6641-4331-91a0-44a1cede5152_cam_01_1781239868.811462_visible
51b94aff-1d49-4cb9-a92a-419a12cd0014	\N	2026-06-12 04:51:30.684+00	2026-06-12 04:52:30.684+00	detection	\N	60	2026-06-12 13:47:49.738965+00	48c9e5dc-6641-4331-91a0-44a1cede5152	gone	{"box": [0.665625, 0.8972222222222223, 0.05625, 0.09166666666666666], "label": "person", "score": 0.5234375, "region": [0.5, 0.1111111111111111, 0.5, 0.8888888888888888], "attribute": "", "sub_label": null}	{"camera_name": "cam_01", "frigate_instance_name": "البيت"}	48c9e5dc-6641-4331-91a0-44a1cede5152_cam_01_1781239890.684917_gone
6dac0264-3b0d-44e1-b496-08da03dfb7bc	\N	2026-06-12 04:55:17.083+00	2026-06-12 04:56:17.083+00	detection	\N	60	2026-06-12 13:47:49.754696+00	48c9e5dc-6641-4331-91a0-44a1cede5152	visible	{"box": [0.828125, 0.7638888888888888, 0.0796875, 0.23333333333333334], "label": "person", "score": 0.76953125, "region": [0.5, 0.1111111111111111, 0.5, 0.8888888888888888], "attribute": "", "sub_label": null}	{"camera_name": "cam_01", "frigate_instance_name": "البيت"}	48c9e5dc-6641-4331-91a0-44a1cede5152_cam_01_1781240117.083836_visible
2aff47d0-04ff-4dee-8008-96ea03959046	\N	2026-06-12 05:00:01.414+00	2026-06-12 05:01:01.414+00	detection	\N	60	2026-06-12 13:47:49.771502+00	48c9e5dc-6641-4331-91a0-44a1cede5152	gone	{"box": [0.753125, 0.7472222222222222, 0.059375, 0.2111111111111111], "label": "person", "score": 0.74609375, "region": [0.5, 0.1111111111111111, 0.5, 0.8888888888888888], "attribute": "", "sub_label": null}	{"camera_name": "cam_01", "frigate_instance_name": "البيت"}	48c9e5dc-6641-4331-91a0-44a1cede5152_cam_01_1781240401.414302_gone
19958ccc-9fca-4e21-8c2a-e804c0447138	\N	2026-06-12 05:03:48.796+00	2026-06-12 05:04:48.796+00	detection	\N	60	2026-06-12 13:47:49.785736+00	48c9e5dc-6641-4331-91a0-44a1cede5152	visible	{"box": [0.8328125, 0.7833333333333333, 0.0640625, 0.21388888888888888], "label": "person", "score": 0.67578125, "region": [0.5, 0.1111111111111111, 0.5, 0.8888888888888888], "attribute": "", "sub_label": null}	{"camera_name": "cam_01", "frigate_instance_name": "البيت"}	48c9e5dc-6641-4331-91a0-44a1cede5152_cam_01_1781240628.796437_visible
928a0cb8-7f31-4e03-bfb5-54d9205d4741	\N	2026-06-12 05:06:40.645+00	2026-06-12 05:07:40.645+00	detection	\N	60	2026-06-12 13:47:49.799518+00	48c9e5dc-6641-4331-91a0-44a1cede5152	gone	{"box": [0.8234375, 0.7, 0.05, 0.22777777777777777], "label": "person", "score": 0.640625, "region": [0.5, 0.1111111111111111, 0.5, 0.8888888888888888], "attribute": "", "sub_label": null}	{"camera_name": "cam_01", "frigate_instance_name": "البيت"}	48c9e5dc-6641-4331-91a0-44a1cede5152_cam_01_1781240800.645581_gone
ea13f2fb-39e6-4906-89de-b0ebda49f86b	\N	2026-06-12 05:11:50.731+00	2026-06-12 05:12:50.731+00	detection	\N	60	2026-06-12 13:47:49.812969+00	48c9e5dc-6641-4331-91a0-44a1cede5152	visible	{"box": [0.69375, 0.7027777777777777, 0.028125, 0.10277777777777777], "label": "person", "score": 0.51171875, "region": [0.5, 0.1111111111111111, 0.5, 0.8888888888888888], "attribute": "", "sub_label": null}	{"camera_name": "cam_01", "frigate_instance_name": "البيت"}	48c9e5dc-6641-4331-91a0-44a1cede5152_cam_01_1781241110.731383_visible
fa4a7412-70fe-471a-b1ac-810c3546cbab	\N	2026-06-12 04:26:27.964+00	2026-06-12 04:27:27.964+00	detection	\N	60	2026-06-12 13:47:49.595789+00	48c9e5dc-6641-4331-91a0-44a1cede5152	gone	{"box": [0.6921875, 0.6944444444444444, 0.0390625, 0.11944444444444445], "label": "person", "score": 0.546875, "region": [0.5, 0.1111111111111111, 0.5, 0.8888888888888888], "attribute": "", "sub_label": null}	{"camera_name": "cam_01", "frigate_instance_name": "البيت"}	48c9e5dc-6641-4331-91a0-44a1cede5152_cam_01_1781238387.964037_gone
362ffdda-e0d5-4bc5-9cd0-f7b8931092b5	\N	2026-06-12 04:31:18.745+00	2026-06-12 04:32:18.745+00	detection	\N	60	2026-06-12 13:47:49.610621+00	48c9e5dc-6641-4331-91a0-44a1cede5152	visible	{"box": [0.8078125, 0.7833333333333333, 0.0734375, 0.21388888888888888], "label": "person", "score": 0.65234375, "region": [0.5, 0.1111111111111111, 0.5, 0.8888888888888888], "attribute": "", "sub_label": null}	{"camera_name": "cam_01", "frigate_instance_name": "البيت"}	48c9e5dc-6641-4331-91a0-44a1cede5152_cam_01_1781238678.74539_visible
c23c72ff-3b73-4f55-8f70-0d339d4cbfd9	\N	2026-06-12 04:33:18.848+00	2026-06-12 04:34:18.848+00	detection	\N	60	2026-06-12 13:47:49.625904+00	48c9e5dc-6641-4331-91a0-44a1cede5152	gone	{"box": [0.8171875, 0.8805555555555555, 0.1109375, 0.11388888888888889], "label": "person", "score": 0.65234375, "region": [0.5, 0.1111111111111111, 0.5, 0.8888888888888888], "attribute": "", "sub_label": null}	{"camera_name": "cam_01", "frigate_instance_name": "البيت"}	48c9e5dc-6641-4331-91a0-44a1cede5152_cam_01_1781238798.848228_gone
5799f3db-53d4-4da9-9daa-750c2f73fbe3	\N	2026-06-12 04:33:54.377+00	2026-06-12 04:34:54.377+00	detection	\N	60	2026-06-12 13:47:49.642252+00	48c9e5dc-6641-4331-91a0-44a1cede5152	visible	{"box": [0.74375, 0.725, 0.0515625, 0.24166666666666667], "label": "person", "score": 0.76953125, "region": [0.5, 0.1111111111111111, 0.5, 0.8888888888888888], "attribute": "", "sub_label": null}	{"camera_name": "cam_01", "frigate_instance_name": "البيت"}	48c9e5dc-6641-4331-91a0-44a1cede5152_cam_01_1781238834.377616_visible
1d3030af-97f3-455f-b2d0-19fa969ad6ef	\N	2026-06-12 04:35:15.276+00	2026-06-12 04:36:15.276+00	detection	\N	60	2026-06-12 13:47:49.659404+00	48c9e5dc-6641-4331-91a0-44a1cede5152	gone	{"box": [0.7328125, 0.7555555555555555, 0.071875, 0.21666666666666667], "label": "person", "score": 0.76953125, "region": [0.5, 0.1111111111111111, 0.5, 0.8888888888888888], "attribute": "", "sub_label": null}	{"camera_name": "cam_01", "frigate_instance_name": "البيت"}	48c9e5dc-6641-4331-91a0-44a1cede5152_cam_01_1781238915.276105_gone
dc142bd0-4dfa-4e04-9de9-88deb61bf49f	\N	2026-06-12 04:36:45.101+00	2026-06-12 04:37:45.101+00	detection	\N	60	2026-06-12 13:47:49.673648+00	48c9e5dc-6641-4331-91a0-44a1cede5152	visible	{"box": [0.7171875, 0.7972222222222223, 0.071875, 0.2], "label": "person", "score": 0.70703125, "region": [0.4921875, 0.1111111111111111, 0.5, 0.8888888888888888], "attribute": "", "sub_label": null}	{"camera_name": "cam_01", "frigate_instance_name": "البيت"}	48c9e5dc-6641-4331-91a0-44a1cede5152_cam_01_1781239005.101794_visible
3c8e9fad-9fb8-409d-9f64-6517db206e76	\N	2026-06-12 04:39:06.394+00	2026-06-12 04:40:06.394+00	detection	\N	60	2026-06-12 13:47:49.692095+00	48c9e5dc-6641-4331-91a0-44a1cede5152	gone	{"box": [0.584375, 0.6388888888888888, 0.0890625, 0.2], "label": "person", "score": 0.51171875, "region": [0.4859375, 0.1111111111111111, 0.5, 0.8888888888888888], "attribute": "", "sub_label": null}	{"camera_name": "cam_01", "frigate_instance_name": "البيت"}	48c9e5dc-6641-4331-91a0-44a1cede5152_cam_01_1781239146.394571_gone
3b464f8d-e4b9-419a-8c39-ac8c8dd5c488	\N	2026-06-12 04:49:19.092+00	2026-06-12 04:50:19.092+00	detection	\N	60	2026-06-12 13:47:49.709688+00	48c9e5dc-6641-4331-91a0-44a1cede5152	visible	{"box": [0.78125, 0.7611111111111111, 0.0546875, 0.2361111111111111], "label": "person", "score": 0.76171875, "region": [0.5, 0.1111111111111111, 0.5, 0.8888888888888888], "attribute": "", "sub_label": null}	{"camera_name": "cam_01", "frigate_instance_name": "البيت"}	48c9e5dc-6641-4331-91a0-44a1cede5152_cam_01_1781239759.092644_visible
38db8b1b-e2a9-4e9d-b27b-89825a8cbc8f	\N	2026-06-12 04:51:11.77+00	2026-06-12 04:52:11.77+00	detection	\N	60	2026-06-12 13:47:49.728193+00	48c9e5dc-6641-4331-91a0-44a1cede5152	gone	{"box": [0.928125, 0.7305555555555555, 0.0703125, 0.25555555555555554], "label": "person", "score": 0.57421875, "region": [0.5, 0.1111111111111111, 0.5, 0.8888888888888888], "attribute": "", "sub_label": null}	{"camera_name": "cam_01", "frigate_instance_name": "البيت"}	48c9e5dc-6641-4331-91a0-44a1cede5152_cam_01_1781239871.770053_gone
4e5f0b33-0a84-432b-ba8a-1e57282d6e1e	\N	2026-06-12 04:52:26.087+00	2026-06-12 04:53:26.087+00	detection	\N	60	2026-06-12 13:47:49.744168+00	48c9e5dc-6641-4331-91a0-44a1cede5152	visible	{"box": [0.7609375, 0.7722222222222223, 0.059375, 0.21944444444444444], "label": "person", "score": 0.76953125, "region": [0.425, 0.1111111111111111, 0.5, 0.8888888888888888], "attribute": "", "sub_label": null}	{"camera_name": "cam_01", "frigate_instance_name": "البيت"}	48c9e5dc-6641-4331-91a0-44a1cede5152_cam_01_1781239946.087235_visible
2673f6fb-ddeb-4e14-bb0d-f6f144a285db	\N	2026-06-12 04:55:20.755+00	2026-06-12 04:56:20.755+00	detection	\N	60	2026-06-12 13:47:49.759787+00	48c9e5dc-6641-4331-91a0-44a1cede5152	gone	{"box": [0.9015625, 0.6972222222222222, 0.05, 0.2], "label": "person", "score": 0.609375, "region": [0.5, 0.1111111111111111, 0.5, 0.8888888888888888], "attribute": "", "sub_label": null}	{"camera_name": "cam_01", "frigate_instance_name": "البيت"}	48c9e5dc-6641-4331-91a0-44a1cede5152_cam_01_1781240120.755613_gone
e0a929df-dc3a-4873-8f36-43a96d5b64d4	\N	2026-06-12 05:01:54.182+00	2026-06-12 05:02:54.182+00	detection	\N	60	2026-06-12 13:47:49.776667+00	48c9e5dc-6641-4331-91a0-44a1cede5152	visible	{"box": [0.7828125, 0.7527777777777778, 0.0734375, 0.24444444444444444], "label": "person", "score": 0.7265625, "region": [0.5, 0.1111111111111111, 0.5, 0.8888888888888888], "attribute": "", "sub_label": null}	{"camera_name": "cam_01", "frigate_instance_name": "البيت"}	48c9e5dc-6641-4331-91a0-44a1cede5152_cam_01_1781240514.182854_visible
fe4b0d76-c9fc-435e-a05e-96db42f01427	\N	2026-06-12 05:03:55.731+00	2026-06-12 05:04:55.731+00	detection	\N	60	2026-06-12 13:47:49.790852+00	48c9e5dc-6641-4331-91a0-44a1cede5152	gone	{"box": [0.2265625, 0.7972222222222223, 0.0875, 0.2], "label": "person", "score": 0.6640625, "region": [0.2046875, 0.1111111111111111, 0.5, 0.8888888888888888], "attribute": "", "sub_label": null}	{"camera_name": "cam_01", "frigate_instance_name": "البيت"}	48c9e5dc-6641-4331-91a0-44a1cede5152_cam_01_1781240635.731306_gone
86b72e31-be80-448b-b774-34fad345ad82	\N	2026-06-12 05:11:07.377+00	2026-06-12 05:12:07.377+00	detection	\N	60	2026-06-12 13:47:49.803945+00	48c9e5dc-6641-4331-91a0-44a1cede5152	visible	{"box": [0.6, 0.7777777777777778, 0.0671875, 0.21944444444444444], "label": "person", "score": 0.51171875, "region": [0.5, 0.1111111111111111, 0.5, 0.8888888888888888], "attribute": "", "sub_label": null}	{"camera_name": "cam_01", "frigate_instance_name": "البيت"}	48c9e5dc-6641-4331-91a0-44a1cede5152_cam_01_1781241067.377031_visible
9bb76f5f-e3cf-4a8c-a907-e0198bdb8d3f	\N	2026-06-12 05:11:54.625+00	2026-06-12 05:12:54.625+00	detection	\N	60	2026-06-12 13:47:49.816675+00	48c9e5dc-6641-4331-91a0-44a1cede5152	gone	{"box": [0.1890625, 0.7861111111111111, 0.0078125, 0.019444444444444445], "label": "person", "score": 0.5234375, "region": [0.1078125, 0.1111111111111111, 0.5, 0.8888888888888888], "attribute": "", "sub_label": null}	{"camera_name": "cam_01", "frigate_instance_name": "البيت"}	48c9e5dc-6641-4331-91a0-44a1cede5152_cam_01_1781241114.625023_gone
8a4f0a71-c169-4a8e-b841-8b8ebcfa624f	\N	2026-06-12 05:12:06.02+00	2026-06-12 05:13:06.02+00	detection	\N	60	2026-06-12 13:47:49.82059+00	48c9e5dc-6641-4331-91a0-44a1cede5152	gone	{"box": [0.88125, 0.8694444444444445, 0.0953125, 0.12777777777777777], "label": "person", "score": 0.55859375, "region": [0.5, 0.1111111111111111, 0.5, 0.8888888888888888], "attribute": "", "sub_label": null}	{"camera_name": "cam_01", "frigate_instance_name": "البيت"}	48c9e5dc-6641-4331-91a0-44a1cede5152_cam_01_1781241126.020998_gone
8af1f6f2-b37e-498d-b721-518b097ba8e0	\N	2026-06-12 05:12:48.715+00	2026-06-12 05:13:48.715+00	detection	\N	60	2026-06-12 13:47:49.834651+00	48c9e5dc-6641-4331-91a0-44a1cede5152	gone	{"box": [0.590625, 0.7944444444444444, 0.071875, 0.19722222222222222], "label": "person", "score": 0.65234375, "region": [0.4734375, 0.1111111111111111, 0.5, 0.8888888888888888], "attribute": "", "sub_label": null}	{"camera_name": "cam_01", "frigate_instance_name": "البيت"}	48c9e5dc-6641-4331-91a0-44a1cede5152_cam_01_1781241168.715254_gone
e066c430-8a1d-437f-8183-ce82098385df	\N	2026-06-12 05:18:56.526+00	2026-06-12 05:19:56.526+00	detection	\N	60	2026-06-12 13:47:49.847526+00	48c9e5dc-6641-4331-91a0-44a1cede5152	visible	{"box": [0.759375, 0.7166666666666667, 0.0671875, 0.21666666666666667], "label": "person", "score": 0.7265625, "region": [0.5, 0.1111111111111111, 0.5, 0.8888888888888888], "attribute": "", "sub_label": null}	{"camera_name": "cam_01", "frigate_instance_name": "البيت"}	48c9e5dc-6641-4331-91a0-44a1cede5152_cam_01_1781241536.526775_visible
25c1a8d2-89b0-4e1b-b408-4fb3d810fbc9	\N	2026-06-12 05:19:34.685+00	2026-06-12 05:20:34.685+00	detection	\N	60	2026-06-12 13:47:49.860334+00	48c9e5dc-6641-4331-91a0-44a1cede5152	gone	{"box": [0.7515625, 0.7166666666666667, 0.05625, 0.18055555555555555], "label": "person", "score": 0.5234375, "region": [0.5, 0.1111111111111111, 0.5, 0.8888888888888888], "attribute": "", "sub_label": null}	{"camera_name": "cam_01", "frigate_instance_name": "البيت"}	48c9e5dc-6641-4331-91a0-44a1cede5152_cam_01_1781241574.685539_gone
5fe92796-ee13-48a9-a605-7875ca52e5e3	\N	2026-06-12 05:24:41.302+00	2026-06-12 05:25:41.302+00	detection	\N	60	2026-06-12 13:47:49.874863+00	48c9e5dc-6641-4331-91a0-44a1cede5152	visible	{"box": [0.7984375, 0.775, 0.0578125, 0.2222222222222222], "label": "person", "score": 0.76953125, "region": [0.5, 0.1111111111111111, 0.5, 0.8888888888888888], "attribute": "", "sub_label": null}	{"camera_name": "cam_01", "frigate_instance_name": "البيت"}	48c9e5dc-6641-4331-91a0-44a1cede5152_cam_01_1781241881.302866_visible
f1ffc319-f9e5-40c0-809b-90c0124c32f9	\N	2026-06-12 05:33:50.923+00	2026-06-12 05:34:50.923+00	detection	\N	60	2026-06-12 13:47:49.888747+00	48c9e5dc-6641-4331-91a0-44a1cede5152	gone	{"box": [0.6296875, 0.11944444444444445, 0.05625, 0.36666666666666664], "label": "person", "score": 0.62890625, "region": [0.4359375, 0, 0.5, 0.8888888888888888], "attribute": "", "sub_label": null}	{"camera_name": "cam_02", "frigate_instance_name": "البيت"}	48c9e5dc-6641-4331-91a0-44a1cede5152_cam_02_1781242430.923012_gone
6b5d5e21-bfe1-4b9a-966b-c51c7ab767d0	\N	2026-06-12 05:42:26.518+00	2026-06-12 05:43:26.518+00	detection	\N	60	2026-06-12 13:47:49.901836+00	48c9e5dc-6641-4331-91a0-44a1cede5152	visible	{"box": [0.7765625, 0.7694444444444445, 0.065625, 0.22777777777777777], "label": "person", "score": 0.76953125, "region": [0.3984375, 0.1111111111111111, 0.5, 0.8888888888888888], "attribute": "", "sub_label": null}	{"camera_name": "cam_01", "frigate_instance_name": "البيت"}	48c9e5dc-6641-4331-91a0-44a1cede5152_cam_01_1781242946.51861_visible
4fcb5b6e-16e1-466a-a342-ed47025d17cb	\N	2026-06-12 05:45:23.93+00	2026-06-12 05:46:23.93+00	detection	\N	60	2026-06-12 13:47:49.914784+00	48c9e5dc-6641-4331-91a0-44a1cede5152	gone	{"box": [0.9296875, 0.7138888888888889, 0.0453125, 0.2388888888888889], "label": "person", "score": 0.68359375, "region": [0.5, 0.1111111111111111, 0.5, 0.8888888888888888], "attribute": "", "sub_label": null}	{"camera_name": "cam_01", "frigate_instance_name": "البيت"}	48c9e5dc-6641-4331-91a0-44a1cede5152_cam_01_1781243123.930482_gone
fb428d44-07b3-4d17-a39d-48109ddbe64f	\N	2026-06-12 05:51:50.321+00	2026-06-12 05:52:50.321+00	detection	\N	60	2026-06-12 13:47:49.927185+00	48c9e5dc-6641-4331-91a0-44a1cede5152	visible	{"box": [0.8703125, 0.7277777777777777, 0.05, 0.2361111111111111], "label": "person", "score": 0.76953125, "region": [0.5, 0.1111111111111111, 0.5, 0.8888888888888888], "attribute": "", "sub_label": null}	{"camera_name": "cam_01", "frigate_instance_name": "البيت"}	48c9e5dc-6641-4331-91a0-44a1cede5152_cam_01_1781243510.321527_visible
98911309-87b6-4ed0-9cfe-8dfbb135e37b	\N	2026-06-12 05:57:49.197+00	2026-06-12 05:58:49.197+00	detection	\N	60	2026-06-12 13:47:49.94352+00	48c9e5dc-6641-4331-91a0-44a1cede5152	gone	{"box": [0.3375, 0.8361111111111111, 0.1203125, 0.15833333333333333], "label": "person", "score": 0.57421875, "region": [0, 0.1111111111111111, 0.5, 0.8888888888888888], "attribute": "", "sub_label": null}	{"camera_name": "cam_01", "frigate_instance_name": "البيت"}	48c9e5dc-6641-4331-91a0-44a1cede5152_cam_01_1781243869.197414_gone
a2e2d676-b5a1-4b51-a65e-91055795e24c	\N	2026-06-12 06:03:29.351+00	2026-06-12 06:04:29.351+00	detection	\N	60	2026-06-12 13:47:49.957927+00	48c9e5dc-6641-4331-91a0-44a1cede5152	gone	{"box": [0.8859375, 0.825, 0.109375, 0.14722222222222223], "label": "car", "score": 0.57421875, "region": [0.5, 0.1111111111111111, 0.5, 0.8888888888888888], "attribute": "", "sub_label": null}	{"camera_name": "cam_01", "frigate_instance_name": "البيت"}	48c9e5dc-6641-4331-91a0-44a1cede5152_cam_01_1781244209.351814_gone
d790e936-d27c-41af-8067-8d8c223eed51	\N	2026-06-12 06:04:13.819+00	2026-06-12 06:05:13.819+00	detection	\N	60	2026-06-12 13:47:49.973211+00	48c9e5dc-6641-4331-91a0-44a1cede5152	visible	{"box": [0.1140625, 0.08055555555555556, 0.1828125, 0.5555555555555556], "label": "person", "score": 0.78125, "region": [0, 0, 0.85625, 1.5222222222222221], "attribute": "", "sub_label": null}	{"camera_name": "cam_02", "frigate_instance_name": "البيت"}	48c9e5dc-6641-4331-91a0-44a1cede5152_cam_02_1781244253.819841_visible
cf706b1a-fac4-446a-b451-e0c01ea4bbf1	\N	2026-06-12 06:05:18.554+00	2026-06-12 06:06:18.554+00	detection	\N	60	2026-06-12 13:47:49.98704+00	48c9e5dc-6641-4331-91a0-44a1cede5152	gone	{"box": [0.884375, 0.14166666666666666, 0.10625, 0.39166666666666666], "label": "person", "score": 0.6953125, "region": [0.5, 0, 0.5, 0.8888888888888888], "attribute": "", "sub_label": null}	{"camera_name": "cam_02", "frigate_instance_name": "البيت"}	48c9e5dc-6641-4331-91a0-44a1cede5152_cam_02_1781244318.554412_gone
4baa6fab-e2af-48b7-9cd7-dc6fd54ced55	\N	2026-06-12 06:08:53.526+00	2026-06-12 06:09:53.526+00	detection	\N	60	2026-06-12 13:47:50.003421+00	48c9e5dc-6641-4331-91a0-44a1cede5152	visible	{"box": [0.8078125, 0.7527777777777778, 0.0515625, 0.22777777777777777], "label": "person", "score": 0.75390625, "region": [0.5, 0.1111111111111111, 0.5, 0.8888888888888888], "attribute": "", "sub_label": null}	{"camera_name": "cam_01", "frigate_instance_name": "البيت"}	48c9e5dc-6641-4331-91a0-44a1cede5152_cam_01_1781244533.526593_visible
da8e5110-8df0-493c-893a-47dd330bc100	\N	2026-06-12 05:12:20.191+00	2026-06-12 05:13:20.191+00	detection	\N	60	2026-06-12 13:47:49.825507+00	48c9e5dc-6641-4331-91a0-44a1cede5152	visible	{"box": [0.884375, 0.8083333333333333, 0.0796875, 0.18888888888888888], "label": "person", "score": 0.55859375, "region": [0.5, 0.1111111111111111, 0.5, 0.8888888888888888], "attribute": "", "sub_label": null}	{"camera_name": "cam_01", "frigate_instance_name": "البيت"}	48c9e5dc-6641-4331-91a0-44a1cede5152_cam_01_1781241140.191349_visible
7ac0cf25-3bd6-462b-9258-037fb1ae9bb7	\N	2026-06-12 05:16:57.218+00	2026-06-12 05:17:57.218+00	detection	\N	60	2026-06-12 13:47:49.838575+00	48c9e5dc-6641-4331-91a0-44a1cede5152	visible	{"box": [0.7578125, 0.7444444444444445, 0.0578125, 0.225], "label": "person", "score": 0.74609375, "region": [0.471875, 0.1111111111111111, 0.5, 0.8888888888888888], "attribute": "", "sub_label": null}	{"camera_name": "cam_01", "frigate_instance_name": "البيت"}	48c9e5dc-6641-4331-91a0-44a1cede5152_cam_01_1781241417.218568_visible
ef0bb5c1-a897-4168-951d-1fb5fbdb994a	\N	2026-06-12 05:18:57.259+00	2026-06-12 05:19:57.259+00	detection	\N	60	2026-06-12 13:47:49.851721+00	48c9e5dc-6641-4331-91a0-44a1cede5152	gone	{"box": [0.7015625, 0.7444444444444445, 0.0515625, 0.10555555555555556], "label": "person", "score": 0.5234375, "region": [0.5, 0.1111111111111111, 0.5, 0.8888888888888888], "attribute": "", "sub_label": null}	{"camera_name": "cam_01", "frigate_instance_name": "البيت"}	48c9e5dc-6641-4331-91a0-44a1cede5152_cam_01_1781241537.259603_gone
76d069ea-83ee-4efe-8a45-2c49b43aaafb	\N	2026-06-12 05:19:50.078+00	2026-06-12 05:20:50.078+00	detection	\N	60	2026-06-12 13:47:49.86578+00	48c9e5dc-6641-4331-91a0-44a1cede5152	visible	{"box": [0.7796875, 0.7805555555555556, 0.0640625, 0.21666666666666667], "label": "person", "score": 0.76953125, "region": [0.5, 0.1111111111111111, 0.5, 0.8888888888888888], "attribute": "", "sub_label": null}	{"camera_name": "cam_01", "frigate_instance_name": "البيت"}	48c9e5dc-6641-4331-91a0-44a1cede5152_cam_01_1781241590.078753_visible
83596a30-66cb-4359-9929-4693f6f31660	\N	2026-06-12 05:25:02.475+00	2026-06-12 05:26:02.475+00	detection	\N	60	2026-06-12 13:47:49.880505+00	48c9e5dc-6641-4331-91a0-44a1cede5152	gone	{"box": [0.7078125, 0.7611111111111111, 0.05, 0.08055555555555556], "label": "person", "score": 0.546875, "region": [0.5, 0.1111111111111111, 0.5, 0.8888888888888888], "attribute": "", "sub_label": null}	{"camera_name": "cam_01", "frigate_instance_name": "البيت"}	48c9e5dc-6641-4331-91a0-44a1cede5152_cam_01_1781241902.475244_gone
bc905347-378a-4f05-9f24-8e3749b4bf5e	\N	2026-06-12 05:37:48.609+00	2026-06-12 05:38:48.609+00	detection	\N	60	2026-06-12 13:47:49.89277+00	48c9e5dc-6641-4331-91a0-44a1cede5152	visible	{"box": [0.803125, 0.8555555555555555, 0.0703125, 0.14166666666666666], "label": "person", "score": 0.5859375, "region": [0.5, 0.1111111111111111, 0.5, 0.8888888888888888], "attribute": "", "sub_label": null}	{"camera_name": "cam_01", "frigate_instance_name": "البيت"}	48c9e5dc-6641-4331-91a0-44a1cede5152_cam_01_1781242668.609826_visible
cfd75c58-1feb-4181-93db-3278eacb0c3f	\N	2026-06-12 05:43:23.763+00	2026-06-12 05:44:23.763+00	detection	\N	60	2026-06-12 13:47:49.905687+00	48c9e5dc-6641-4331-91a0-44a1cede5152	gone	{"box": [0.44375, 0.7333333333333333, 0.125, 0.14444444444444443], "label": "person", "score": 0.51171875, "region": [0.15, 0.1111111111111111, 0.5, 0.8888888888888888], "attribute": "", "sub_label": null}	{"camera_name": "cam_01", "frigate_instance_name": "البيت"}	48c9e5dc-6641-4331-91a0-44a1cede5152_cam_01_1781243003.763561_gone
f4b6517d-d21d-464f-a825-b3399b95272f	\N	2026-06-12 05:51:19.637+00	2026-06-12 05:52:19.637+00	detection	\N	60	2026-06-12 13:47:49.918653+00	48c9e5dc-6641-4331-91a0-44a1cede5152	visible	{"box": [0.775, 0.7611111111111111, 0.0828125, 0.2361111111111111], "label": "person", "score": 0.75390625, "region": [0.4203125, 0.1111111111111111, 0.5, 0.8888888888888888], "attribute": "", "sub_label": null}	{"camera_name": "cam_01", "frigate_instance_name": "البيت"}	48c9e5dc-6641-4331-91a0-44a1cede5152_cam_01_1781243479.637239_visible
85b57f64-1b36-4dfe-9140-b9f7f44f9271	\N	2026-06-12 05:52:03.911+00	2026-06-12 05:53:03.911+00	detection	\N	60	2026-06-12 13:47:49.932964+00	48c9e5dc-6641-4331-91a0-44a1cede5152	gone	{"box": [0.8328125, 0.8944444444444445, 0.05625, 0.09722222222222222], "label": "person", "score": 0.55859375, "region": [0.5, 0.1111111111111111, 0.5, 0.8888888888888888], "attribute": "", "sub_label": null}	{"camera_name": "cam_01", "frigate_instance_name": "البيت"}	48c9e5dc-6641-4331-91a0-44a1cede5152_cam_01_1781243523.91125_gone
6cc71e8e-4580-442d-98f9-1b0e95cde027	\N	2026-06-12 06:00:44.81+00	2026-06-12 06:01:44.81+00	detection	\N	60	2026-06-12 13:47:49.94795+00	48c9e5dc-6641-4331-91a0-44a1cede5152	visible	{"box": [0.9296875, 0.7583333333333333, 0.0640625, 0.10833333333333334], "label": "car", "score": 0.68359375, "region": [0, 0, 1.04375, 1.8555555555555556], "attribute": "", "sub_label": null}	{"camera_name": "cam_01", "frigate_instance_name": "البيت"}	48c9e5dc-6641-4331-91a0-44a1cede5152_cam_01_1781244044.810687_visible
cce3d26a-0e76-4b2f-acc7-fb413504e4fd	\N	2026-06-12 06:03:57.232+00	2026-06-12 06:04:57.232+00	detection	\N	60	2026-06-12 13:47:49.963111+00	48c9e5dc-6641-4331-91a0-44a1cede5152	visible	{"box": [0.6171875, 0.12222222222222222, 0.0828125, 0.3861111111111111], "label": "person", "score": 0.78125, "region": [0.5, 0, 0.5, 0.8888888888888888], "attribute": "", "sub_label": null}	{"camera_name": "cam_02", "frigate_instance_name": "البيت"}	48c9e5dc-6641-4331-91a0-44a1cede5152_cam_02_1781244237.232963_visible
138d3e5a-d80f-4f78-9a0b-8addc1cc144b	\N	2026-06-12 06:04:41.918+00	2026-06-12 06:05:41.918+00	detection	\N	60	2026-06-12 13:47:49.978481+00	48c9e5dc-6641-4331-91a0-44a1cede5152	gone	{"box": [0.575, 0.13333333333333333, 0.1453125, 0.5638888888888889], "label": "person", "score": 0.76953125, "region": [0, 0, 1.01875, 1.8111111111111111], "attribute": "", "sub_label": null}	{"camera_name": "cam_02", "frigate_instance_name": "البيت"}	48c9e5dc-6641-4331-91a0-44a1cede5152_cam_02_1781244281.918871_gone
0e3a5120-cdee-4536-9a28-994e27e35f62	\N	2026-06-12 06:05:20.996+00	2026-06-12 06:06:20.996+00	detection	\N	60	2026-06-12 13:47:49.992839+00	48c9e5dc-6641-4331-91a0-44a1cede5152	visible	{"box": [0.628125, 0.09722222222222222, 0.0796875, 0.4305555555555556], "label": "person", "score": 0.59765625, "region": [0.5, 0, 0.5, 0.8888888888888888], "attribute": "", "sub_label": null}	{"camera_name": "cam_02", "frigate_instance_name": "البيت"}	48c9e5dc-6641-4331-91a0-44a1cede5152_cam_02_1781244320.996346_visible
49a16c0d-d82b-40fc-89d8-920353b21fe9	\N	2026-06-12 05:12:34.941+00	2026-06-12 05:13:34.941+00	detection	\N	60	2026-06-12 13:47:49.829949+00	48c9e5dc-6641-4331-91a0-44a1cede5152	gone	{"box": [0.5125, 0.7361111111111112, 0.0375, 0.10277777777777777], "label": "person", "score": 0.51171875, "region": [0.5, 0.1111111111111111, 0.5, 0.8888888888888888], "attribute": "", "sub_label": null}	{"camera_name": "cam_01", "frigate_instance_name": "البيت"}	48c9e5dc-6641-4331-91a0-44a1cede5152_cam_01_1781241154.941487_gone
1fb45291-0a08-4810-ad97-1ed2b84b69b2	\N	2026-06-12 05:17:00.807+00	2026-06-12 05:18:00.807+00	detection	\N	60	2026-06-12 13:47:49.843231+00	48c9e5dc-6641-4331-91a0-44a1cede5152	gone	{"box": [0.6515625, 0.7555555555555555, 0.0484375, 0.09444444444444444], "label": "person", "score": 0.5234375, "region": [0.3421875, 0.1111111111111111, 0.5, 0.8888888888888888], "attribute": "", "sub_label": null}	{"camera_name": "cam_01", "frigate_instance_name": "البيت"}	48c9e5dc-6641-4331-91a0-44a1cede5152_cam_01_1781241420.807764_gone
73c7624f-102a-4709-933e-07b947dfc12c	\N	2026-06-12 05:19:04.717+00	2026-06-12 05:20:04.717+00	detection	\N	60	2026-06-12 13:47:49.855472+00	48c9e5dc-6641-4331-91a0-44a1cede5152	visible	{"box": [0.765625, 0.8083333333333333, 0.1015625, 0.18888888888888888], "label": "person", "score": 0.609375, "region": [0.5, 0.1111111111111111, 0.5, 0.8888888888888888], "attribute": "", "sub_label": null}	{"camera_name": "cam_01", "frigate_instance_name": "البيت"}	48c9e5dc-6641-4331-91a0-44a1cede5152_cam_01_1781241544.717221_visible
ef006443-3aa9-4213-8f32-db02ece17755	\N	2026-06-12 05:19:54.016+00	2026-06-12 05:20:54.016+00	detection	\N	60	2026-06-12 13:47:49.870414+00	48c9e5dc-6641-4331-91a0-44a1cede5152	gone	{"box": [0.71875, 0.7472222222222222, 0.040625, 0.11388888888888889], "label": "person", "score": 0.55859375, "region": [0.5, 0.1111111111111111, 0.5, 0.8888888888888888], "attribute": "", "sub_label": null}	{"camera_name": "cam_01", "frigate_instance_name": "البيت"}	48c9e5dc-6641-4331-91a0-44a1cede5152_cam_01_1781241594.016675_gone
f2b3a52e-1a18-4e94-944e-7df74fa46099	\N	2026-06-12 05:33:41.077+00	2026-06-12 05:34:41.077+00	detection	\N	60	2026-06-12 13:47:49.884949+00	48c9e5dc-6641-4331-91a0-44a1cede5152	visible	{"box": [0.634375, 0.08055555555555556, 0.1078125, 0.4305555555555556], "label": "person", "score": 0.74609375, "region": [0.4375, 0, 0.5, 0.8888888888888888], "attribute": "", "sub_label": null}	{"camera_name": "cam_02", "frigate_instance_name": "البيت"}	48c9e5dc-6641-4331-91a0-44a1cede5152_cam_02_1781242421.077597_visible
d1630442-24aa-4773-99dd-75709aa61580	\N	2026-06-12 05:38:27.017+00	2026-06-12 05:39:27.017+00	detection	\N	60	2026-06-12 13:47:49.897927+00	48c9e5dc-6641-4331-91a0-44a1cede5152	gone	{"box": [0.3515625, 0.7611111111111111, 0.053125, 0.10277777777777777], "label": "person", "score": 0.51171875, "region": [0.196875, 0.1111111111111111, 0.5, 0.8888888888888888], "attribute": "", "sub_label": null}	{"camera_name": "cam_01", "frigate_instance_name": "البيت"}	48c9e5dc-6641-4331-91a0-44a1cede5152_cam_01_1781242707.017074_gone
9f42c926-c749-4fc4-b484-b8ccb68aba59	\N	2026-06-12 05:43:59.05+00	2026-06-12 05:44:59.05+00	detection	\N	60	2026-06-12 13:47:49.909262+00	48c9e5dc-6641-4331-91a0-44a1cede5152	visible	{"box": [0.846875, 0.7111111111111111, 0.0640625, 0.19166666666666668], "label": "person", "score": 0.5234375, "region": [0.478125, 0.1111111111111111, 0.5, 0.8888888888888888], "attribute": "", "sub_label": null}	{"camera_name": "cam_01", "frigate_instance_name": "البيت"}	48c9e5dc-6641-4331-91a0-44a1cede5152_cam_01_1781243039.050232_visible
61682e4e-6c10-48ae-8020-bef23bbab28c	\N	2026-06-12 05:51:25.661+00	2026-06-12 05:52:25.661+00	detection	\N	60	2026-06-12 13:47:49.922843+00	48c9e5dc-6641-4331-91a0-44a1cede5152	gone	{"box": [0.85625, 0.9, 0.05, 0.08888888888888889], "label": "person", "score": 0.55859375, "region": [0.4453125, 0.1111111111111111, 0.5, 0.8888888888888888], "attribute": "", "sub_label": null}	{"camera_name": "cam_01", "frigate_instance_name": "البيت"}	48c9e5dc-6641-4331-91a0-44a1cede5152_cam_01_1781243485.661419_gone
dd9a9343-6d1b-4743-89a8-0e10c50eae7e	\N	2026-06-12 05:57:36.978+00	2026-06-12 05:58:36.978+00	detection	\N	60	2026-06-12 13:47:49.938656+00	48c9e5dc-6641-4331-91a0-44a1cede5152	visible	{"box": [0.8875, 0.7777777777777778, 0.0703125, 0.21944444444444444], "label": "person", "score": 0.76953125, "region": [0.5, 0.1111111111111111, 0.5, 0.8888888888888888], "attribute": "", "sub_label": null}	{"camera_name": "cam_01", "frigate_instance_name": "البيت"}	48c9e5dc-6641-4331-91a0-44a1cede5152_cam_01_1781243856.978831_visible
0de2b408-cf57-4afd-8f82-2f7e276f199d	\N	2026-06-12 06:02:45.36+00	2026-06-12 06:03:45.36+00	detection	\N	60	2026-06-12 13:47:49.953045+00	48c9e5dc-6641-4331-91a0-44a1cede5152	stationary	{"box": [0.9265625, 0.8222222222222222, 0.06875, 0.06388888888888888], "label": "car", "score": 0.55859375, "region": [0.5, 0.1111111111111111, 0.5, 0.8888888888888888], "attribute": "", "sub_label": null}	{"camera_name": "cam_01", "frigate_instance_name": "البيت"}	48c9e5dc-6641-4331-91a0-44a1cede5152_cam_01_1781244165.360221_stationary
e2ba5197-667f-44b2-8255-c6d2dbb9e6c1	\N	2026-06-12 06:04:09.519+00	2026-06-12 06:05:09.519+00	detection	\N	60	2026-06-12 13:47:49.967417+00	48c9e5dc-6641-4331-91a0-44a1cede5152	gone	{"box": [0.5765625, 0.13333333333333333, 0.14375, 0.5694444444444444], "label": "person", "score": 0.76953125, "region": [0, 0, 1.125, 2], "attribute": "", "sub_label": null}	{"camera_name": "cam_02", "frigate_instance_name": "البيت"}	48c9e5dc-6641-4331-91a0-44a1cede5152_cam_02_1781244249.519484_gone
1ec5e637-bc85-42b0-b044-318e06d9a820	\N	2026-06-12 06:04:46.819+00	2026-06-12 06:05:46.819+00	detection	\N	60	2026-06-12 13:47:49.982767+00	48c9e5dc-6641-4331-91a0-44a1cede5152	visible	{"box": [0.140625, 0.11944444444444445, 0.1515625, 0.5944444444444444], "label": "person", "score": 0.8125, "region": [0, 0, 0.5, 0.8888888888888888], "attribute": "", "sub_label": null}	{"camera_name": "cam_02", "frigate_instance_name": "البيت"}	48c9e5dc-6641-4331-91a0-44a1cede5152_cam_02_1781244286.81942_visible
67bf08db-05fa-4ec5-92ca-2ff41737921f	\N	2026-06-12 06:05:22.241+00	2026-06-12 06:06:22.241+00	detection	\N	60	2026-06-12 13:47:49.998434+00	48c9e5dc-6641-4331-91a0-44a1cede5152	gone	{"box": [0.6203125, 0.08888888888888889, 0.0921875, 0.4], "label": "person", "score": 0.74609375, "region": [0.5, 0, 0.5, 0.8888888888888888], "attribute": "", "sub_label": null}	{"camera_name": "cam_02", "frigate_instance_name": "البيت"}	48c9e5dc-6641-4331-91a0-44a1cede5152_cam_02_1781244322.241376_gone
\.


--
-- Data for Name: frigate_triggers; Type: TABLE DATA; Schema: public; Owner: postgres
--

COPY public.frigate_triggers (id, frigate_instance_id, camera, name, description, trigger_type, similarity_threshold, enabled, last_triggered_at, actions, created_at) FROM stdin;
\.


--
-- Data for Name: frigate_zones; Type: TABLE DATA; Schema: public; Owner: postgres
--

COPY public.frigate_zones (id, camera_id, name, coordinates, zone_type, enabled, color, created_at, updated_at) FROM stdin;
\.


--
-- Data for Name: health_alerts; Type: TABLE DATA; Schema: public; Owner: postgres
--

COPY public.health_alerts (id, student_id, alert_type, value, severity, note, detected_at, notified, resolved) FROM stdin;
c6afd3e5-353d-4fc9-b4f8-b4a22c5df1d2	cf21af24-b770-421a-bc5c-4b9f8bb5d34d	glucose_low	55	high	هبوط سكر خطر (55 mg/dL)	2026-07-05 03:53:32.271725+00	f	f
f30d6da1-b725-4d98-aa06-6414bcb8419d	cf21af24-b770-421a-bc5c-4b9f8bb5d34d	seizure	\N	high	اشتباه نوبة صرع — تدخّل فوري	2026-07-05 03:53:32.305759+00	f	f
979544b5-a7ed-4410-a8a1-8fb28f4f4020	cf21af24-b770-421a-bc5c-4b9f8bb5d34d	glucose_high	280	high	ارتفاع سكر خطر (280 mg/dL)	2026-07-05 04:20:19.4425+00	f	f
\.


--
-- Data for Name: industries; Type: TABLE DATA; Schema: public; Owner: postgres
--

COPY public.industries (id, name, name_ar, description, description_ar, icon, active, created_at, updated_at) FROM stdin;
6a5cf301-7d4a-47fe-b254-e50d99c7f0a8	Restaurant	مطعم	Restaurant and food service businesses	المطاعم وخدمات الطعام	utensils	t	2026-06-12 00:20:00.463156+00	2026-06-12 00:20:00.463156+00
a3615aa9-9fcf-4440-87fa-18e8b1fc03f4	Hospital	مستشفى	Healthcare and medical facilities	المرافق الصحية والطبية	heart-pulse	t	2026-06-12 00:20:00.463156+00	2026-06-12 00:20:00.463156+00
e17bdee2-b726-4117-9a83-36c8bd2d6933	Company	شركة	Corporate and business organizations	الشركات والمؤسسات التجارية	building-2	t	2026-06-12 00:20:00.463156+00	2026-06-12 00:20:00.463156+00
bc65c62b-f701-49c3-94bf-a561c988b4f1	Hotel	فندق	Hospitality and accommodation services	خدمات الضيافة والإقامة	bed	t	2026-06-12 00:20:00.463156+00	2026-06-12 00:20:00.463156+00
7aff7ce2-2963-45d0-971a-93d202f9d5dc	Retail	تجارة التجزئة	Retail stores and shopping centers	متاجر التجزئة ومراكز التسوق	shopping-cart	t	2026-06-12 00:20:00.463156+00	2026-06-12 00:20:00.463156+00
65168eb2-f74e-4e96-b7a1-8c95a9f155d1	Education	تعليم	Educational institutions and schools	المؤسسات التعليمية والمدارس	graduation-cap	t	2026-06-12 00:20:00.463156+00	2026-06-12 00:20:00.463156+00
02024d3c-beea-4ae7-91d6-17e157e15e32	Government	حكومة	Government agencies and public services	الوكالات الحكومية والخدمات العامة	landmark	t	2026-06-12 00:20:00.463156+00	2026-06-12 00:20:00.463156+00
dc988786-39ed-4966-9cbc-c440a37ee3f6	Sports	رياضة	Sports facilities and fitness centers	المرافق الرياضية ومراكز اللياقة	dumbbell	t	2026-06-12 00:20:00.463156+00	2026-06-12 00:20:00.463156+00
\.


--
-- Data for Name: legal_documents; Type: TABLE DATA; Schema: public; Owner: postgres
--

COPY public.legal_documents (id, document_type, title, content, version, effective_date, created_at, updated_at, created_by, updated_by) FROM stdin;
e041928f-7ea8-423d-b25f-ccff5539b7f3	terms_of_service	شروط الخدمة	محتوى شروط الخدمة سيتم تحديثه من قبل الإدارة.	1	2026-06-12 00:20:00.447043+00	2026-06-12 00:20:00.447043+00	2026-06-12 00:20:00.447043+00	\N	\N
db14ece6-4aae-4b7d-b5e9-e8a4ee020475	privacy_policy	سياسة الخصوصية	محتوى سياسة الخصوصية سيتم تحديثه من قبل الإدارة.	1	2026-06-12 00:20:00.447043+00	2026-06-12 00:20:00.447043+00	2026-06-12 00:20:00.447043+00	\N	\N
\.


--
-- Data for Name: network_scan_results; Type: TABLE DATA; Schema: public; Owner: postgres
--

COPY public.network_scan_results (id, ip_address, port, manufacturer, model, device_type, protocol, mac_address, hostname, discovered_at, scan_session_id, user_id) FROM stdin;
\.


--
-- Data for Name: notification_labels; Type: TABLE DATA; Schema: public; Owner: postgres
--

COPY public.notification_labels (id, type, name_ar, name_en, is_active, created_at, updated_at, created_by) FROM stdin;
\.


--
-- Data for Name: notification_methods; Type: TABLE DATA; Schema: public; Owner: postgres
--

COPY public.notification_methods (id, name_ar, name_en, type, icon, enabled, settings, created_at, updated_at, created_by) FROM stdin;
01e215ce-4741-412e-9727-23f055ce5830	واتساب	WhatsApp	whatsapp	message-circle	t	{}	2026-06-12 00:20:00.543969+00	2026-06-12 00:20:00.543969+00	\N
072d9533-0830-4ac9-9c2b-96572da8248e	البريد الإلكتروني	Email	email	mail	t	{}	2026-06-12 00:20:00.543969+00	2026-06-12 00:20:00.543969+00	\N
ce1bae39-a951-416a-8538-33c7e837b92b	الهاتف	Phone	phone	phone	t	{}	2026-06-12 00:20:00.543969+00	2026-06-12 00:20:00.543969+00	\N
8cedb059-51db-4412-b1b0-4bd5dd662e75	الرسائل النصية	SMS	sms	message-square	t	{}	2026-06-12 00:20:00.543969+00	2026-06-12 00:20:00.543969+00	\N
\.


--
-- Data for Name: organization_settings; Type: TABLE DATA; Schema: public; Owner: postgres
--

COPY public.organization_settings (id, organization_id, setting_key, setting_value, description, created_at, updated_at) FROM stdin;
\.


--
-- Data for Name: organizations; Type: TABLE DATA; Schema: public; Owner: postgres
--

COPY public.organizations (id, name, subscription_tier, max_cameras, active, created_at, updated_at, subscription_limits, max_branches, features, subscription_status, industry_id) FROM stdin;
67e83f81-01f6-4621-91dc-bc59048c7c17	Default Organization	basic	5	t	2026-06-12 00:22:09.682823+00	2026-06-12 00:22:09.682823+00	{"users": 3, "cameras": 5, "branches": 1, "storage_gb": 10, "ai_detections_per_month": 1000}	1	{"analytics": false, "recording": false, "ai_detection": true, "live_streaming": true}	pending	\N
e8352779-7fc5-4492-9672-7a07a779b25b	Default Organization	basic	5	t	2026-06-12 00:24:01.257248+00	2026-06-12 00:24:01.257248+00	{"users": 3, "cameras": 5, "branches": 1, "storage_gb": 10, "ai_detections_per_month": 1000}	1	{"analytics": false, "recording": false, "ai_detection": true, "live_streaming": true}	pending	\N
cb9e9cfe-03a8-44b1-adb3-854ce61fbe21	مطاعم الذواقة (تجريبي)	basic	100	t	2026-07-04 13:03:02.211031+00	2026-07-04 13:03:40.263831+00	{"users": 3, "cameras": 5, "branches": 1, "storage_gb": 10, "ai_detections_per_month": 1000}	1	{"analytics": false, "recording": false, "ai_detection": true, "live_streaming": true}	pending	\N
557d5fb7-b321-40ee-a074-9e847b4b8962	Default Organization	basic	5	t	2026-07-04 13:10:17.908345+00	2026-07-04 13:10:17.908345+00	{"users": 3, "cameras": 5, "branches": 1, "storage_gb": 10, "ai_detections_per_month": 1000}	1	{"analytics": false, "recording": false, "ai_detection": true, "live_streaming": true}	pending	\N
\.


--
-- Data for Name: pinned_dashboards; Type: TABLE DATA; Schema: public; Owner: postgres
--

COPY public.pinned_dashboards (id, user_id, instance_id, name, path, x, y, width, height, order_index, created_at, updated_at, zoom) FROM stdin;
\.


--
-- Data for Name: pinned_labels; Type: TABLE DATA; Schema: public; Owner: postgres
--

COPY public.pinned_labels (id, user_id, text, color, font_size, x, y, created_at, updated_at) FROM stdin;
\.


--
-- Data for Name: screen_permissions; Type: TABLE DATA; Schema: public; Owner: postgres
--

COPY public.screen_permissions (id, screen_key, path, title_en, title_ar, description_en, description_ar, allowed_roles, allow_super_admin, is_active, created_by, created_at, updated_at) FROM stdin;
\.


--
-- Data for Name: security_zones; Type: TABLE DATA; Schema: public; Owner: postgres
--

COPY public.security_zones (id, branch_id, name, description, coordinates, sensitivity_level, active_hours, created_at, updated_at, active) FROM stdin;
\.


--
-- Data for Name: storage_configs; Type: TABLE DATA; Schema: public; Owner: postgres
--

COPY public.storage_configs (id, name, type, config, is_active, created_at, updated_at, created_by) FROM stdin;
0346be93-d383-47c0-95cf-9c8fa296da86	Local Storage	local	{"path": "/uploads/models"}	t	2026-06-12 00:20:00.527808+00	2026-06-12 00:20:00.527808+00	\N
\.


--
-- Data for Name: students; Type: TABLE DATA; Schema: public; Owner: postgres
--

COPY public.students (id, organization_id, branch_id, name, condition, guardian_phone, clinic_phone, wearable_id, created_at) FROM stdin;
cf21af24-b770-421a-bc5c-4b9f8bb5d34d	cb9e9cfe-03a8-44b1-adb3-854ce61fbe21	0ab2ca49-ad88-4630-afb6-3ef008e1cef5	سالم أحمد (تجريبي)	diabetes	966500000001	966500000002	watch-demo-001	2026-07-05 03:53:26.725019+00
\.


--
-- Data for Name: subscribers; Type: TABLE DATA; Schema: public; Owner: postgres
--

COPY public.subscribers (id, user_id, email, stripe_customer_id, subscribed, subscription_tier, subscription_end, usage_analytics, billing_cycle, created_at, updated_at, subscription_status, approved_by, approved_at, last_activity, notes, organization_id) FROM stdin;
33cb19cb-1e5b-4295-969f-100fae681c17	8526382f-7ebb-4245-b8be-84c1f7a14e40	admin@admin.com	\N	f	basic	\N	{}	monthly	2026-06-12 00:24:01.257248+00	2026-06-12 00:24:13.097585+00	pending	\N	\N	2026-06-12 00:24:13.097585+00	\N	\N
f04a6b00-1988-4e61-8604-6d639684e3fe	a7b186ca-e6c3-4ece-9349-26a0dbf0defa	veedon.test@local.dev	\N	f	basic	\N	{}	monthly	2026-07-04 13:10:17.908345+00	2026-07-05 06:40:06.836696+00	pending	\N	\N	2026-07-05 06:40:06.836696+00	\N	\N
8ba08f08-8db0-48ce-8f28-c6ac01269ec1	f69c2370-64a4-467b-9be5-0262b271986a	ashraffarid@gmail.com	\N	f	basic	\N	{}	monthly	2026-06-12 00:22:09.682823+00	2026-07-05 07:09:16.27193+00	pending	\N	\N	2026-07-05 07:09:16.27193+00	\N	\N
\.


--
-- Data for Name: system_settings; Type: TABLE DATA; Schema: public; Owner: postgres
--

COPY public.system_settings (id, setting_key, setting_value, description, created_at, updated_at, updated_by) FROM stdin;
918eda42-5fbf-4279-9036-34edb0484630	default_storage_provider	{"type": "local"}	Default storage provider for model files	2026-06-12 00:20:00.527808+00	2026-06-12 00:20:00.527808+00	\N
c6f05119-0c3a-4524-8ed6-9c7dcd6a361b	max_file_size_mb	{"value": 100}	Maximum file size in MB for model uploads	2026-06-12 00:20:00.527808+00	2026-06-12 00:20:00.527808+00	\N
6f0f20c3-ddd5-4d3a-99a0-64cb84df447b	show_subscription_plans	{"enabled": false}	Control visibility of subscription plans on landing page	2026-06-12 00:20:00.570441+00	2026-06-12 00:20:00.582548+00	\N
8dffb3d7-cfd9-4a7b-91f1-47db832b74f8	messaging_global	{"twilio": {"enabled": false, "auth_token_secret": "TWILIO_AUTH_TOKEN", "from_phone_number": null, "account_sid_secret": "TWILIO_ACCOUNT_SID"}, "whatsapp_cloud": {"enabled": true, "business_phone_id": null, "from_phone_number": null, "access_token_secret": "WHATSAPP_CLOUD_ACCESS_TOKEN"}}	Global messaging providers configuration managed by system admin	2026-06-12 00:20:00.75604+00	2026-06-12 00:20:00.75604+00	\N
40627347-7203-476f-8160-0eaaadbcc87a	tts_global	{"free_tts": {"enabled": true, "default_voice": "auto"}, "elevenlabs": {"model": "eleven_turbo_v2_5", "enabled": false, "api_key_secret": "ELEVENLABS_API_KEY", "default_voice_id": "TX3LPaxmHKxFdv7VOQHJ"}, "default_provider": "free_tts"}	Global TTS providers configuration managed by system admin	2026-06-12 00:20:00.75604+00	2026-06-12 00:20:00.75604+00	\N
39fc8d5b-fb74-48aa-8fff-68a3d0c2ea74	ai_analysis_server_url	{"url": "https://203.161.35.97:11434"}	Server URL for AI analysis (e.g., Ollama server endpoint)	2026-06-12 00:20:00.785457+00	2026-06-12 00:20:00.785457+00	\N
a79c1308-5cba-4f6d-be0e-4078c7840937	mistral_ai_server_url	{"url": "https://a0415b97b37d.ngrok-free.app/v1/chat/completions"}	رابط خادم Mistral AI للتحليل الذكي للصور	2026-06-12 00:20:00.791515+00	2026-06-12 00:20:00.791515+00	\N
b69148bd-63b8-4cc7-ab7e-6c765dc5e663	frigate_sync_minutes	5	Minimum minutes between Frigate sync operations	2026-06-12 00:20:00.891752+00	2026-06-12 00:20:00.891752+00	\N
3f9f3e9c-3bbc-4c4a-95ac-4c1468d21ed2	frigate_last_sync_at	{"timestamp": "2026-06-12T23:02:46.740Z"}	Timestamp of last Frigate sync operation	2026-06-12 00:20:00.891752+00	2026-06-12 23:02:46.740636+00	\N
\.


--
-- Data for Name: user_branch_access; Type: TABLE DATA; Schema: public; Owner: postgres
--

COPY public.user_branch_access (id, user_id, branch_id, granted_by, granted_at) FROM stdin;
\.


--
-- Data for Name: user_group_members; Type: TABLE DATA; Schema: public; Owner: postgres
--

COPY public.user_group_members (id, group_id, user_role_id, added_by, added_at) FROM stdin;
\.


--
-- Data for Name: user_groups; Type: TABLE DATA; Schema: public; Owner: postgres
--

COPY public.user_groups (id, name, description, organization_id, group_type, metadata, created_by, created_at, updated_at) FROM stdin;
\.


--
-- Data for Name: user_preferences; Type: TABLE DATA; Schema: public; Owner: postgres
--

COPY public.user_preferences (id, user_id, language, timezone, theme, notifications, created_at, updated_at, ui_language, tts_language) FROM stdin;
3de40a8b-d677-4747-b22d-f14ed623ae09	8526382f-7ebb-4245-b8be-84c1f7a14e40	en	UTC	system	{"sms": false, "push": true, "email": true}	2026-06-12 00:24:01.257248+00	2026-06-12 00:24:01.257248+00	\N	\N
5457cbc0-4726-4a66-884d-57bf3f24c23a	a7b186ca-e6c3-4ece-9349-26a0dbf0defa	ar	UTC	system	{"sms": false, "push": true, "email": true}	2026-07-04 13:10:17.908345+00	2026-07-04 21:43:12.717901+00	ar	\N
563524ff-5c54-4cd9-95d8-9e98bf466331	f69c2370-64a4-467b-9be5-0262b271986a	ar	UTC	system	{"sms": false, "push": true, "email": true}	2026-06-12 00:22:09.682823+00	2026-07-05 06:10:42.906034+00	ar	\N
\.


--
-- Data for Name: user_roles; Type: TABLE DATA; Schema: public; Owner: postgres
--

COPY public.user_roles (id, user_id, organization_id, role, created_at, permissions, granted_by, granted_at, notification_type, notification_value, name) FROM stdin;
cad39fc8-3798-492f-8020-62e2129ef529	f69c2370-64a4-467b-9be5-0262b271986a	67e83f81-01f6-4621-91dc-bc59048c7c17	admin	2026-06-12 00:22:09.682823+00	{"manage_users": false, "view_cameras": true, "view_analytics": true, "manage_settings": false}	\N	2026-06-12 00:22:09.682823+00	\N	\N	\N
ebd9f75c-abf7-44e5-84b6-aa469698665f	8526382f-7ebb-4245-b8be-84c1f7a14e40	e8352779-7fc5-4492-9672-7a07a779b25b	admin	2026-06-12 00:24:01.257248+00	{"manage_users": false, "view_cameras": true, "view_analytics": true, "manage_settings": false}	\N	2026-06-12 00:24:01.257248+00	\N	\N	\N
40341238-0852-4e97-b5dd-cc38cd2bf1a9	a7b186ca-e6c3-4ece-9349-26a0dbf0defa	557d5fb7-b321-40ee-a074-9e847b4b8962	admin	2026-07-04 13:10:17.908345+00	{"manage_users": false, "view_cameras": true, "view_analytics": true, "manage_settings": false}	\N	2026-07-04 13:10:17.908345+00	\N	\N	\N
f622c8d6-b8ca-4dec-8739-3b6c236f280f	a7b186ca-e6c3-4ece-9349-26a0dbf0defa	\N	super_admin	2026-07-04 17:32:20.460025+00	{"manage_users": true, "view_cameras": true, "view_analytics": true, "manage_settings": true}	\N	2026-07-04 17:32:20.460025+00	\N	\N	\N
\.


--
-- Data for Name: workflow_forms; Type: TABLE DATA; Schema: public; Owner: postgres
--

COPY public.workflow_forms (id, name, name_ar, description, description_ar, activity_type, form_fields, is_active, created_by, created_at, updated_at, logo_url) FROM stdin;
\.


--
-- Data for Name: messages_2026_07_02; Type: TABLE DATA; Schema: realtime; Owner: supabase_admin
--

COPY realtime.messages_2026_07_02 (topic, extension, payload, event, private, updated_at, inserted_at, id, binary_payload) FROM stdin;
\.


--
-- Data for Name: messages_2026_07_03; Type: TABLE DATA; Schema: realtime; Owner: supabase_admin
--

COPY realtime.messages_2026_07_03 (topic, extension, payload, event, private, updated_at, inserted_at, id, binary_payload) FROM stdin;
\.


--
-- Data for Name: messages_2026_07_04; Type: TABLE DATA; Schema: realtime; Owner: supabase_admin
--

COPY realtime.messages_2026_07_04 (topic, extension, payload, event, private, updated_at, inserted_at, id, binary_payload) FROM stdin;
\.


--
-- Data for Name: messages_2026_07_05; Type: TABLE DATA; Schema: realtime; Owner: supabase_admin
--

COPY realtime.messages_2026_07_05 (topic, extension, payload, event, private, updated_at, inserted_at, id, binary_payload) FROM stdin;
\.


--
-- Data for Name: messages_2026_07_06; Type: TABLE DATA; Schema: realtime; Owner: supabase_admin
--

COPY realtime.messages_2026_07_06 (topic, extension, payload, event, private, updated_at, inserted_at, id, binary_payload) FROM stdin;
\.


--
-- Data for Name: messages_2026_07_07; Type: TABLE DATA; Schema: realtime; Owner: supabase_admin
--

COPY realtime.messages_2026_07_07 (topic, extension, payload, event, private, updated_at, inserted_at, id, binary_payload) FROM stdin;
\.


--
-- Data for Name: messages_2026_07_08; Type: TABLE DATA; Schema: realtime; Owner: supabase_admin
--

COPY realtime.messages_2026_07_08 (topic, extension, payload, event, private, updated_at, inserted_at, id, binary_payload) FROM stdin;
\.


--
-- Data for Name: schema_migrations; Type: TABLE DATA; Schema: realtime; Owner: supabase_admin
--

COPY realtime.schema_migrations (version, inserted_at) FROM stdin;
20211116024918	2026-06-12 00:19:50
20211116045059	2026-06-12 00:19:50
20211116050929	2026-06-12 00:19:50
20211116051442	2026-06-12 00:19:50
20211116212300	2026-06-12 00:19:50
20211116213355	2026-06-12 00:19:50
20211116213934	2026-06-12 00:19:50
20211116214523	2026-06-12 00:19:50
20211122062447	2026-06-12 00:19:50
20211124070109	2026-06-12 00:19:50
20211202204204	2026-06-12 00:19:50
20211202204605	2026-06-12 00:19:50
20211210212804	2026-06-12 00:19:50
20211228014915	2026-06-12 00:19:50
20220107221237	2026-06-12 00:19:50
20220228202821	2026-06-12 00:19:50
20220312004840	2026-06-12 00:19:50
20220603231003	2026-06-12 00:19:50
20220603232444	2026-06-12 00:19:50
20220615214548	2026-06-12 00:19:50
20220712093339	2026-06-12 00:19:50
20220908172859	2026-06-12 00:19:50
20220916233421	2026-06-12 00:19:50
20230119133233	2026-06-12 00:19:50
20230128025114	2026-06-12 00:19:50
20230128025212	2026-06-12 00:19:50
20230227211149	2026-06-12 00:19:50
20230228184745	2026-06-12 00:19:50
20230308225145	2026-06-12 00:19:50
20230328144023	2026-06-12 00:19:50
20231018144023	2026-06-12 00:19:50
20231204144023	2026-06-12 00:19:50
20231204144024	2026-06-12 00:19:50
20231204144025	2026-06-12 00:19:50
20240108234812	2026-06-12 00:19:50
20240109165339	2026-06-12 00:19:50
20240227174441	2026-06-12 00:19:50
20240311171622	2026-06-12 00:19:50
20240321100241	2026-06-12 00:19:50
20240401105812	2026-06-12 00:19:50
20240418121054	2026-06-12 00:19:50
20240523004032	2026-06-12 00:19:50
20240618124746	2026-06-12 00:19:50
20240801235015	2026-06-12 00:19:50
20240805133720	2026-06-12 00:19:50
20240827160934	2026-06-12 00:19:50
20240919163303	2026-06-12 00:19:50
20240919163305	2026-06-12 00:19:50
20241019105805	2026-06-12 00:19:50
20241030150047	2026-06-12 00:19:50
20241108114728	2026-06-12 00:19:50
20241121104152	2026-06-12 00:19:50
20241130184212	2026-06-12 00:19:50
20241220035512	2026-06-12 00:19:50
20241220123912	2026-06-12 00:19:50
20241224161212	2026-06-12 00:19:50
20250107150512	2026-06-12 00:19:50
20250110162412	2026-06-12 00:19:50
20250123174212	2026-06-12 00:19:50
20250128220012	2026-06-12 00:19:50
20250506224012	2026-06-12 00:19:50
20250523164012	2026-06-12 00:19:50
20250714121412	2026-06-12 00:19:50
20250905041441	2026-06-12 00:19:50
20251103001201	2026-06-12 00:19:50
20251120212548	2026-06-12 00:19:50
20251120215549	2026-06-12 00:19:50
20260218120000	2026-06-12 00:19:50
20260326120000	2026-06-12 00:19:50
20260514120000	2026-06-12 00:19:50
20260527120000	2026-06-12 00:19:50
20260528120000	2026-06-12 00:19:50
20260603120000	2026-06-12 00:19:50
\.


--
-- Data for Name: subscription; Type: TABLE DATA; Schema: realtime; Owner: supabase_admin
--

COPY realtime.subscription (id, subscription_id, entity, filters, claims, created_at, action_filter, selected_columns) FROM stdin;
\.


--
-- Data for Name: buckets; Type: TABLE DATA; Schema: storage; Owner: supabase_storage_admin
--

COPY storage.buckets (id, name, owner, created_at, updated_at, public, avif_autodetection, file_size_limit, allowed_mime_types, owner_id, type) FROM stdin;
form-logos	form-logos	\N	2026-06-12 00:20:00.557927+00	2026-06-12 00:20:00.557927+00	t	f	\N	\N	\N	STANDARD
model-files	model-files	\N	2026-06-12 00:20:00.527808+00	2026-06-12 00:20:00.527808+00	t	f	104857600	{application/octet-stream,application/x-pytorch,application/x-onnx,application/zip}	\N	STANDARD
form-attachments	form-attachments	\N	2026-06-12 00:20:00.743373+00	2026-06-12 00:20:00.743373+00	t	f	\N	\N	\N	STANDARD
test-uploads	test-uploads	\N	2026-06-12 00:20:00.869281+00	2026-06-12 00:20:00.869281+00	t	f	\N	\N	\N	STANDARD
frigate-models	frigate-models	\N	2026-06-14 02:48:56.510161+00	2026-06-14 02:48:56.510161+00	f	f	524288000	{application/octet-stream,application/x-yaml,text/yaml}	\N	STANDARD
\.


--
-- Data for Name: buckets_analytics; Type: TABLE DATA; Schema: storage; Owner: supabase_storage_admin
--

COPY storage.buckets_analytics (name, type, format, created_at, updated_at, id, deleted_at) FROM stdin;
\.


--
-- Data for Name: buckets_vectors; Type: TABLE DATA; Schema: storage; Owner: supabase_storage_admin
--

COPY storage.buckets_vectors (id, type, created_at, updated_at) FROM stdin;
\.


--
-- Data for Name: iceberg_namespaces; Type: TABLE DATA; Schema: storage; Owner: supabase_storage_admin
--

COPY storage.iceberg_namespaces (id, bucket_name, name, created_at, updated_at, metadata, catalog_id) FROM stdin;
\.


--
-- Data for Name: iceberg_tables; Type: TABLE DATA; Schema: storage; Owner: supabase_storage_admin
--

COPY storage.iceberg_tables (id, namespace_id, bucket_name, name, location, created_at, updated_at, remote_table_id, shard_key, shard_id, catalog_id) FROM stdin;
\.


--
-- Data for Name: migrations; Type: TABLE DATA; Schema: storage; Owner: supabase_storage_admin
--

COPY storage.migrations (id, name, hash, executed_at) FROM stdin;
0	create-migrations-table	e18db593bcde2aca2a408c4d1100f6abba2195df	2026-06-12 00:19:58.818121
1	initialmigration	6ab16121fbaa08bbd11b712d05f358f9b555d777	2026-06-12 00:19:58.825271
2	storage-schema	f6a1fa2c93cbcd16d4e487b362e45fca157a8dbd	2026-06-12 00:19:58.82768
3	pathtoken-column	2cb1b0004b817b29d5b0a971af16bafeede4b70d	2026-06-12 00:19:58.832408
4	add-migrations-rls	427c5b63fe1c5937495d9c635c263ee7a5905058	2026-06-12 00:19:58.836596
5	add-size-functions	79e081a1455b63666c1294a440f8ad4b1e6a7f84	2026-06-12 00:19:58.838726
6	change-column-name-in-get-size	ded78e2f1b5d7e616117897e6443a925965b30d2	2026-06-12 00:19:58.840908
7	add-rls-to-buckets	e7e7f86adbc51049f341dfe8d30256c1abca17aa	2026-06-12 00:19:58.843764
8	add-public-to-buckets	fd670db39ed65f9d08b01db09d6202503ca2bab3	2026-06-12 00:19:58.846996
9	fix-search-function	af597a1b590c70519b464a4ab3be54490712796b	2026-06-12 00:19:58.849419
10	search-files-search-function	b595f05e92f7e91211af1bbfe9c6a13bb3391e16	2026-06-12 00:19:58.851715
11	add-trigger-to-auto-update-updated_at-column	7425bdb14366d1739fa8a18c83100636d74dcaa2	2026-06-12 00:19:58.854047
12	add-automatic-avif-detection-flag	8e92e1266eb29518b6a4c5313ab8f29dd0d08df9	2026-06-12 00:19:58.857416
13	add-bucket-custom-limits	cce962054138135cd9a8c4bcd531598684b25e7d	2026-06-12 00:19:58.859845
14	use-bytes-for-max-size	941c41b346f9802b411f06f30e972ad4744dad27	2026-06-12 00:19:58.86226
15	add-can-insert-object-function	934146bc38ead475f4ef4b555c524ee5d66799e5	2026-06-12 00:19:58.869516
16	add-version	76debf38d3fd07dcfc747ca49096457d95b1221b	2026-06-12 00:19:58.872722
17	drop-owner-foreign-key	f1cbb288f1b7a4c1eb8c38504b80ae2a0153d101	2026-06-12 00:19:58.874951
18	add_owner_id_column_deprecate_owner	e7a511b379110b08e2f214be852c35414749fe66	2026-06-12 00:19:58.877223
19	alter-default-value-objects-id	02e5e22a78626187e00d173dc45f58fa66a4f043	2026-06-12 00:19:58.879499
20	list-objects-with-delimiter	cd694ae708e51ba82bf012bba00caf4f3b6393b7	2026-06-12 00:19:58.882616
21	s3-multipart-uploads	8c804d4a566c40cd1e4cc5b3725a664a9303657f	2026-06-12 00:19:58.885094
22	s3-multipart-uploads-big-ints	9737dc258d2397953c9953d9b86920b8be0cdb73	2026-06-12 00:19:58.889187
23	optimize-search-function	9d7e604cddc4b56a5422dc68c9313f4a1b6f132c	2026-06-12 00:19:58.892876
24	operation-function	8312e37c2bf9e76bbe841aa5fda889206d2bf8aa	2026-06-12 00:19:58.896207
25	custom-metadata	d974c6057c3db1c1f847afa0e291e6165693b990	2026-06-12 00:19:58.898344
26	objects-prefixes	215cabcb7f78121892a5a2037a09fedf9a1ae322	2026-06-12 00:19:58.900536
27	search-v2	859ba38092ac96eb3964d83bf53ccc0b141663a6	2026-06-12 00:19:58.90267
28	object-bucket-name-sorting	c73a2b5b5d4041e39705814fd3a1b95502d38ce4	2026-06-12 00:19:58.905846
29	create-prefixes	ad2c1207f76703d11a9f9007f821620017a66c21	2026-06-12 00:19:58.907808
30	update-object-levels	2be814ff05c8252fdfdc7cfb4b7f5c7e17f0bed6	2026-06-12 00:19:58.909886
31	objects-level-index	b40367c14c3440ec75f19bbce2d71e914ddd3da0	2026-06-12 00:19:58.911827
32	backward-compatible-index-on-objects	e0c37182b0f7aee3efd823298fb3c76f1042c0f7	2026-06-12 00:19:58.914946
33	backward-compatible-index-on-prefixes	b480e99ed951e0900f033ec4eb34b5bdcb4e3d49	2026-06-12 00:19:58.916805
34	optimize-search-function-v1	ca80a3dc7bfef894df17108785ce29a7fc8ee456	2026-06-12 00:19:58.918881
35	add-insert-trigger-prefixes	458fe0ffd07ec53f5e3ce9df51bfdf4861929ccc	2026-06-12 00:19:58.920802
36	optimise-existing-functions	6ae5fca6af5c55abe95369cd4f93985d1814ca8f	2026-06-12 00:19:58.923531
37	add-bucket-name-length-trigger	3944135b4e3e8b22d6d4cbb568fe3b0b51df15c1	2026-06-12 00:19:58.925604
38	iceberg-catalog-flag-on-buckets	02716b81ceec9705aed84aa1501657095b32e5c5	2026-06-12 00:19:58.928237
39	add-search-v2-sort-support	6706c5f2928846abee18461279799ad12b279b78	2026-06-12 00:19:58.935295
40	fix-prefix-race-conditions-optimized	7ad69982ae2d372b21f48fc4829ae9752c518f6b	2026-06-12 00:19:58.93853
41	add-object-level-update-trigger	07fcf1a22165849b7a029deed059ffcde08d1ae0	2026-06-12 00:19:58.940694
42	rollback-prefix-triggers	771479077764adc09e2ea2043eb627503c034cd4	2026-06-12 00:19:58.942816
43	fix-object-level	84b35d6caca9d937478ad8a797491f38b8c2979f	2026-06-12 00:19:58.944693
44	vector-bucket-type	99c20c0ffd52bb1ff1f32fb992f3b351e3ef8fb3	2026-06-12 00:19:58.947777
45	vector-buckets	049e27196d77a7cb76497a85afae669d8b230953	2026-06-12 00:19:58.950131
46	buckets-objects-grants	fedeb96d60fefd8e02ab3ded9fbde05632f84aed	2026-06-12 00:19:58.953717
47	iceberg-table-metadata	649df56855c24d8b36dd4cc1aeb8251aa9ad42c2	2026-06-12 00:19:58.956107
48	iceberg-catalog-ids	e0e8b460c609b9999ccd0df9ad14294613eed939	2026-06-12 00:19:58.959493
49	buckets-objects-grants-postgres	072b1195d0d5a2f888af6b2302a1938dd94b8b3d	2026-06-12 00:19:58.971156
50	search-v2-optimised	6323ac4f850aa14e7387eb32102869578b5bd478	2026-06-12 00:19:58.973692
51	index-backward-compatible-search	2ee395d433f76e38bcd3856debaf6e0e5b674011	2026-06-12 00:19:58.984124
52	drop-not-used-indexes-and-functions	5cc44c8696749ac11dd0dc37f2a3802075f3a171	2026-06-12 00:19:58.985607
53	drop-index-lower-name	d0cb18777d9e2a98ebe0bc5cc7a42e57ebe41854	2026-06-12 00:19:58.990738
54	drop-index-object-level	6289e048b1472da17c31a7eba1ded625a6457e67	2026-06-12 00:19:58.993342
55	prevent-direct-deletes	262a4798d5e0f2e7c8970232e03ce8be695d5819	2026-06-12 00:19:58.994969
56	fix-optimized-search-function	b823ed1e418101032fa01374edc9a436e54e3ed4	2026-06-12 00:19:58.997402
57	s3-multipart-uploads-metadata	f127886e00d1b374fadbc7c6b31e09336aad5287	2026-06-12 00:19:59.001483
58	operation-ergonomics	00ca5d483b3fe0d522133d9002ccc5df98365120	2026-06-12 00:19:59.004279
59	drop-unused-functions	38456f13e39691c2bbb4b5151d0d1cdbabd4a8c4	2026-06-12 00:19:59.0067
60	optimize-existing-functions-again	db35e1c91a9201e59f4fef8d972c2f277d68b157	2026-06-12 00:19:59.009075
\.


--
-- Data for Name: objects; Type: TABLE DATA; Schema: storage; Owner: supabase_storage_admin
--

COPY storage.objects (id, bucket_id, name, owner, created_at, updated_at, last_accessed_at, metadata, version, owner_id, user_metadata) FROM stdin;
a6648136-c7c7-4775-8f2e-d629fb81c94b	frigate-models	models/subh_firearm/best.pt	\N	2026-06-14 07:42:07.306196+00	2026-06-14 07:42:07.306196+00	2026-06-14 07:42:07.306196+00	{"eTag": "\\"a03b0c5aee7ad426fafd7265fa77ba5d\\"", "size": 6238307, "mimetype": "application/octet-stream", "cacheControl": "no-cache", "lastModified": "2026-06-14T07:42:07.288Z", "contentLength": 6238307, "httpStatusCode": 200}	9cdad23e-80c4-448d-95c3-af3eda16ce2e	\N	{}
07efc137-1275-44cb-9e91-c53898e4629f	frigate-models	models/abonai_fire_smoke/yolov8n.pt	\N	2026-06-14 02:58:57.155311+00	2026-06-14 07:41:53.730772+00	2026-06-14 02:58:57.155311+00	{"eTag": "\\"0305608151dd1725c9d7da6882ae52d5\\"", "size": 6534387, "mimetype": "application/octet-stream", "cacheControl": "no-cache", "lastModified": "2026-06-14T07:41:53.707Z", "contentLength": 6534387, "httpStatusCode": 200}	de25485e-250d-4c9f-8ee5-8ce42436a634	\N	{}
b4e6b7df-30f3-445f-aebb-f6835eafcb7e	frigate-models	models/hexmon_vyra_ppe/best.pt	\N	2026-06-14 02:58:58.291391+00	2026-06-14 07:41:59.286414+00	2026-06-14 02:58:58.291391+00	{"eTag": "\\"daa5a7a6561c78df9a5e141cbed65b8b\\"", "size": 52056210, "mimetype": "application/octet-stream", "cacheControl": "no-cache", "lastModified": "2026-06-14T07:41:59.207Z", "contentLength": 52056210, "httpStatusCode": 200}	162a2b88-a6dc-46ef-beee-14b06a1538d1	\N	{}
ca8b21bf-cea5-45f3-ae0d-95f094a41fa1	frigate-models	models/mkgoud_lpr/LP-detection.pt	\N	2026-06-14 07:47:28.525261+00	2026-06-14 07:47:28.525261+00	2026-06-14 07:47:28.525261+00	{"eTag": "\\"110481218c37bc27a963d1bbe85f78e6\\"", "size": 6239992, "mimetype": "application/octet-stream", "cacheControl": "no-cache", "lastModified": "2026-06-14T07:47:28.503Z", "contentLength": 6239992, "httpStatusCode": 200}	1a12d299-1c0a-4c9f-97eb-745e5bfbe06f	\N	{}
47222a8a-c97c-4689-b69e-87baae4318ac	frigate-models	models/keremberke_ppe/best.pt	\N	2026-06-14 02:58:58.724001+00	2026-06-14 07:42:01.358598+00	2026-06-14 02:58:58.724001+00	{"eTag": "\\"5f10a3f84dbc88b9d287a588c1f71f0c\\"", "size": 22500088, "mimetype": "application/octet-stream", "cacheControl": "no-cache", "lastModified": "2026-06-14T07:42:01.317Z", "contentLength": 22500088, "httpStatusCode": 200}	b5bd6ee2-506a-4331-a16a-ac9645db239f	\N	{}
225f3299-2729-43aa-8f41-81e0d7e41392	frigate-models	models/subh_threat/best.pt	\N	2026-06-14 07:42:04.451465+00	2026-06-14 07:42:04.451465+00	2026-06-14 07:42:04.451465+00	{"eTag": "\\"7453bb7a469f65e1eafa72df0f2da3fb\\"", "size": 6251747, "mimetype": "application/octet-stream", "cacheControl": "no-cache", "lastModified": "2026-06-14T07:42:04.428Z", "contentLength": 6251747, "httpStatusCode": 200}	79673a07-e690-4034-96e0-3d844bdec554	\N	{}
5a9a17dc-bdc3-4d8a-a649-6ab422f1e937	frigate-models	models/melih_fall/best.pt	\N	2026-06-14 02:59:00.496212+00	2026-06-14 07:42:11.703499+00	2026-06-14 02:59:00.496212+00	{"eTag": "\\"38436b66fc8bb3452ce7cf5efa667f8c\\"", "size": 5472282, "mimetype": "application/octet-stream", "cacheControl": "no-cache", "lastModified": "2026-06-14T07:42:11.688Z", "contentLength": 5472282, "httpStatusCode": 200}	97f22e16-fbe1-4859-a911-6ba5b6ba0899	\N	{}
ebb3efc4-d3dc-427e-bbc6-c5c5e4af79a8	frigate-models	models/keremberke_forklift/best.pt	\N	2026-06-14 02:59:02.486707+00	2026-06-14 07:42:15.667354+00	2026-06-14 02:59:02.486707+00	{"eTag": "\\"6f4fe49d71c67dfdf58db3554f12f109\\"", "size": 22485752, "mimetype": "application/octet-stream", "cacheControl": "no-cache", "lastModified": "2026-06-14T07:42:15.628Z", "contentLength": 22485752, "httpStatusCode": 200}	d6f8240d-845f-45bf-bb41-28a636fb6155	\N	{}
b545088f-8837-40ff-ae10-40c83e254602	frigate-models	models/enos_traffic_accident/epoch61.pt	\N	2026-06-14 07:47:20.522319+00	2026-06-14 07:47:20.522319+00	2026-06-14 07:47:20.522319+00	{"eTag": "\\"58c57cf390a31063eb225e8bc50c1fdf\\"", "size": 114368274, "mimetype": "application/octet-stream", "cacheControl": "no-cache", "lastModified": "2026-06-14T07:47:20.363Z", "contentLength": 114368274, "httpStatusCode": 200}	42c87340-8e5f-4050-8a49-aefdca695836	\N	{}
32b633a9-2429-4b1a-833e-e4b1fecd7099	frigate-models	models/risef_seatbelt/best.pt	\N	2026-06-14 07:47:24.000472+00	2026-06-14 07:47:24.000472+00	2026-06-14 07:47:24.000472+00	{"eTag": "\\"24b478871abf67604c9e22e67ea19363\\"", "size": 11024315, "mimetype": "application/octet-stream", "cacheControl": "no-cache", "lastModified": "2026-06-14T07:47:23.972Z", "contentLength": 11024315, "httpStatusCode": 200}	68acfd32-dc17-408c-a646-bccc770afe9c	\N	{}
9ebfc076-2886-487b-a205-d2be44fb39f0	frigate-models	models/musawer_fight/Yolo_nano_weights.pt	\N	2026-06-14 07:47:32.404846+00	2026-06-14 07:47:32.404846+00	2026-06-14 07:47:32.404846+00	{"eTag": "\\"71c7e339a30d2c583d2718009659c1c3\\"", "size": 6250147, "mimetype": "application/octet-stream", "cacheControl": "no-cache", "lastModified": "2026-06-14T07:47:32.383Z", "contentLength": 6250147, "httpStatusCode": 200}	7946c790-9910-492d-ab86-9d0efe58642b	\N	{}
\.


--
-- Data for Name: s3_multipart_uploads; Type: TABLE DATA; Schema: storage; Owner: supabase_storage_admin
--

COPY storage.s3_multipart_uploads (id, in_progress_size, upload_signature, bucket_id, key, version, owner_id, created_at, user_metadata, metadata) FROM stdin;
\.


--
-- Data for Name: s3_multipart_uploads_parts; Type: TABLE DATA; Schema: storage; Owner: supabase_storage_admin
--

COPY storage.s3_multipart_uploads_parts (id, upload_id, size, part_number, bucket_id, key, etag, owner_id, version, created_at) FROM stdin;
\.


--
-- Data for Name: vector_indexes; Type: TABLE DATA; Schema: storage; Owner: supabase_storage_admin
--

COPY storage.vector_indexes (id, name, bucket_id, data_type, dimension, distance_metric, metadata_configuration, created_at, updated_at) FROM stdin;
\.


--
-- Data for Name: hooks; Type: TABLE DATA; Schema: supabase_functions; Owner: supabase_functions_admin
--

COPY supabase_functions.hooks (id, hook_table_id, hook_name, created_at, request_id) FROM stdin;
\.


--
-- Data for Name: migrations; Type: TABLE DATA; Schema: supabase_functions; Owner: supabase_functions_admin
--

COPY supabase_functions.migrations (version, inserted_at) FROM stdin;
initial	2026-06-12 00:19:46.500688+00
20210809183423_update_grants	2026-06-12 00:19:46.500688+00
\.


--
-- Data for Name: schema_migrations; Type: TABLE DATA; Schema: supabase_migrations; Owner: postgres
--

COPY supabase_migrations.schema_migrations (version, statements, name) FROM stdin;
20250717210000	{"-- Disable RLS on all tables for local development\n-- This migration must run BEFORE other migrations to ensure clean reset\n-- (In Supabase local dev, RLS often conflicts with non-privileged anon access)\nDO $$\nDECLARE r record;\nBEGIN\n  -- Disable RLS on all existing tables (this is a no-op on first run, idempotent)\n  FOR r IN SELECT tablename FROM pg_tables WHERE schemaname = 'public' LOOP\n    EXECUTE format('ALTER TABLE public.%I DISABLE ROW LEVEL SECURITY', r.tablename);\n  END LOOP;\nEND $$"}	disable_rls_local
20250717213139	{"-- Create enum for subscription tiers\nCREATE TYPE subscription_tier AS ENUM ('basic', 'professional', 'enterprise')","-- Create enum for user roles\nCREATE TYPE user_role AS ENUM ('admin', 'manager', 'viewer')","-- Organizations table (multi-tenant support)\nCREATE TABLE organizations (\n    id UUID PRIMARY KEY DEFAULT gen_random_uuid(),\n    name TEXT NOT NULL,\n    subscription_tier subscription_tier NOT NULL DEFAULT 'basic',\n    max_cameras INTEGER NOT NULL DEFAULT 5,\n    active BOOLEAN NOT NULL DEFAULT true,\n    created_at TIMESTAMP WITH TIME ZONE DEFAULT NOW(),\n    updated_at TIMESTAMP WITH TIME ZONE DEFAULT NOW()\n)","-- Branches table (for multi-location support)\nCREATE TABLE branches (\n    id UUID PRIMARY KEY DEFAULT gen_random_uuid(),\n    organization_id UUID REFERENCES organizations(id) ON DELETE CASCADE,\n    name TEXT NOT NULL,\n    address TEXT,\n    latitude DECIMAL(10,8),\n    longitude DECIMAL(11,8),\n    active BOOLEAN NOT NULL DEFAULT true,\n    created_at TIMESTAMP WITH TIME ZONE DEFAULT NOW()\n)","-- Cameras table\nCREATE TABLE cameras (\n    id UUID PRIMARY KEY DEFAULT gen_random_uuid(),\n    branch_id UUID REFERENCES branches(id) ON DELETE CASCADE,\n    name TEXT NOT NULL,\n    rtsp_url TEXT,\n    frigate_identifier TEXT,\n    status TEXT DEFAULT 'offline',\n    last_connection TIMESTAMP WITH TIME ZONE,\n    config JSONB,\n    created_at TIMESTAMP WITH TIME ZONE DEFAULT NOW()\n)","-- Events table for surveillance events\nCREATE TABLE events (\n    id UUID PRIMARY KEY DEFAULT gen_random_uuid(),\n    camera_id UUID REFERENCES cameras(id) ON DELETE CASCADE,\n    event_type TEXT NOT NULL,\n    severity TEXT NOT NULL DEFAULT 'info',\n    metadata JSONB,\n    snapshot_url TEXT,\n    detected_at TIMESTAMP WITH TIME ZONE DEFAULT NOW(),\n    reviewed BOOLEAN NOT NULL DEFAULT false\n)","-- Trigger to update timestamps\nCREATE OR REPLACE FUNCTION update_modified_column()\nRETURNS TRIGGER AS $$\nBEGIN\n    NEW.updated_at = NOW();\n    RETURN NEW;\nEND;\n$$ LANGUAGE plpgsql","CREATE TRIGGER update_organizations_modtime\nBEFORE UPDATE ON organizations\nFOR EACH ROW\nEXECUTE FUNCTION update_modified_column()"}	a3dd5e65-6ea7-460b-806d-b04a8a293540
20250717213320	{"-- Create user_roles table first\nCREATE TABLE user_roles (\n    id UUID PRIMARY KEY DEFAULT gen_random_uuid(),\n    user_id UUID REFERENCES auth.users(id) ON DELETE CASCADE,\n    organization_id UUID REFERENCES organizations(id) ON DELETE CASCADE,\n    role user_role NOT NULL,\n    created_at TIMESTAMP WITH TIME ZONE DEFAULT NOW(),\n    UNIQUE(user_id, organization_id)\n)","-- Enable RLS on user_roles\nALTER TABLE user_roles ENABLE ROW LEVEL SECURITY","-- Create a function to check user roles\nCREATE OR REPLACE FUNCTION public.get_user_role(user_id UUID)\nRETURNS user_role\nLANGUAGE SQL SECURITY DEFINER\nAS $$\n  SELECT role FROM user_roles WHERE user_id = $1 LIMIT 1\n$$","-- Policy for user_roles\nCREATE POLICY \\"Users can view their own roles\\" ON user_roles\nFOR SELECT USING (user_id = auth.uid())","-- Policies for Organizations\nCREATE POLICY \\"Users can view their organization\\" ON organizations\nFOR SELECT USING (\n  EXISTS (\n    SELECT 1 FROM user_roles \n    WHERE user_id = auth.uid() \n    AND organization_id = organizations.id\n  )\n)","-- Policies for Branches  \nCREATE POLICY \\"Users can view branches in their organization\\" ON branches\nFOR SELECT USING (\n  EXISTS (\n    SELECT 1 FROM user_roles ur\n    WHERE ur.user_id = auth.uid() \n    AND ur.organization_id = branches.organization_id\n  )\n)","-- Policies for Cameras\nCREATE POLICY \\"Users can view cameras in their organization\\" ON cameras\nFOR SELECT USING (\n  EXISTS (\n    SELECT 1 FROM user_roles ur\n    JOIN branches b ON cameras.branch_id = b.id\n    WHERE ur.user_id = auth.uid() \n    AND ur.organization_id = b.organization_id\n  )\n)","-- Policies for Events\nCREATE POLICY \\"Users can view events in their organization\\" ON events\nFOR SELECT USING (\n  EXISTS (\n    SELECT 1 FROM user_roles ur\n    JOIN cameras c ON events.camera_id = c.id\n    JOIN branches b ON c.branch_id = b.id\n    WHERE ur.user_id = auth.uid() \n    AND ur.organization_id = b.organization_id\n  )\n)"}	3f48ee74-79a4-4c92-a618-cfd047830d49
20250717213325	{"-- Enable RLS on all tables\nALTER TABLE organizations ENABLE ROW LEVEL SECURITY","ALTER TABLE branches ENABLE ROW LEVEL SECURITY","ALTER TABLE cameras ENABLE ROW LEVEL SECURITY","ALTER TABLE events ENABLE ROW LEVEL SECURITY","-- Drop existing policies if they exist to make this migration idempotent\nDROP POLICY IF EXISTS \\"Users can view their organization\\" ON organizations","DROP POLICY IF EXISTS \\"Users can view branches in their organization\\" ON branches","DROP POLICY IF EXISTS \\"Users can view cameras in their organization\\" ON cameras","DROP POLICY IF EXISTS \\"Users can view events in their organization\\" ON events","-- Create a function to check user roles\nCREATE OR REPLACE FUNCTION public.get_user_role(user_id UUID)\nRETURNS user_role\nLANGUAGE SQL SECURITY DEFINER\nAS $$\n  SELECT role FROM user_roles WHERE user_id = $1 LIMIT 1\n$$","-- Policies for Organizations\nCREATE POLICY \\"Users can view their organization\\" ON organizations\nFOR SELECT USING (\n  EXISTS (\n    SELECT 1 FROM user_roles\n    WHERE user_id = auth.uid()\n    AND organization_id = organizations.id\n  )\n)","-- Policies for Branches\nCREATE POLICY \\"Users can view branches in their organization\\" ON branches\nFOR SELECT USING (\n  EXISTS (\n    SELECT 1 FROM user_roles ur\n    JOIN organizations o ON ur.organization_id = o.id\n    WHERE ur.user_id = auth.uid()\n    AND o.id = branches.organization_id\n  )\n)","-- Policies for Cameras\nCREATE POLICY \\"Users can view cameras in their organization\\" ON cameras\nFOR SELECT USING (\n  EXISTS (\n    SELECT 1 FROM user_roles ur\n    JOIN branches b ON cameras.branch_id = b.id\n    JOIN organizations o ON b.organization_id = o.id\n    WHERE ur.user_id = auth.uid()\n    AND ur.organization_id = o.id\n  )\n)","-- Policies for Events\nCREATE POLICY \\"Users can view events in their organization\\" ON events\nFOR SELECT USING (\n  EXISTS (\n    SELECT 1 FROM user_roles ur\n    JOIN cameras c ON events.camera_id = c.id\n    JOIN branches b ON c.branch_id = b.id\n    JOIN organizations o ON b.organization_id = o.id\n    WHERE ur.user_id = auth.uid()\n    AND ur.organization_id = o.id\n  )\n)"}	54c575ee-2301-4ee4-a4ee-861885aac686
20250717214028	{"-- Create a trigger to handle new user sign-ups\nCREATE OR REPLACE FUNCTION public.handle_new_user()\nRETURNS TRIGGER\nLANGUAGE plpgsql\nSECURITY DEFINER SET search_path = ''\nAS $$\nDECLARE\n  new_org_id UUID;\nBEGIN\n  -- Create the organization first\n  INSERT INTO public.organizations (name, subscription_tier)\n  VALUES (\n    COALESCE(new.raw_user_meta_data->>'organization_name', 'Default Organization'),\n    'basic'\n  )\n  RETURNING id INTO new_org_id;\n  \n  -- Create default branch for the organization\n  INSERT INTO public.branches (organization_id, name, address)\n  VALUES (new_org_id, 'Headquarters', 'Main Location');\n  \n  -- Add user role as admin for the organization\n  INSERT INTO public.user_roles (user_id, organization_id, role)\n  VALUES (new.id, new_org_id, 'admin');\n  \n  RETURN new;\nEND;\n$$","-- Create the trigger to execute on new user sign-up\nCREATE TRIGGER on_auth_user_created\n  AFTER INSERT ON auth.users\n  FOR EACH ROW EXECUTE FUNCTION public.handle_new_user()","-- Create additional tables for advanced features\n\n-- AI Models table to track available models\nCREATE TABLE ai_models (\n  id UUID PRIMARY KEY DEFAULT gen_random_uuid(),\n  name TEXT NOT NULL,\n  description TEXT,\n  category TEXT NOT NULL,\n  version TEXT NOT NULL,\n  enabled BOOLEAN NOT NULL DEFAULT true,\n  configuration JSONB,\n  created_at TIMESTAMP WITH TIME ZONE DEFAULT NOW()\n)","-- Security Zones table for camera coverage areas\nCREATE TABLE security_zones (\n  id UUID PRIMARY KEY DEFAULT gen_random_uuid(),\n  branch_id UUID REFERENCES branches(id) ON DELETE CASCADE,\n  name TEXT NOT NULL,\n  description TEXT,\n  coordinates JSONB, -- Polygon coordinates\n  sensitivity_level INTEGER NOT NULL DEFAULT 5, -- 1-10 scale\n  active_hours JSONB, -- Time ranges when zone is active\n  created_at TIMESTAMP WITH TIME ZONE DEFAULT NOW(),\n  updated_at TIMESTAMP WITH TIME ZONE DEFAULT NOW()\n)","-- Detection rules table for custom alerts\nCREATE TABLE detection_rules (\n  id UUID PRIMARY KEY DEFAULT gen_random_uuid(),\n  organization_id UUID REFERENCES organizations(id) ON DELETE CASCADE,\n  name TEXT NOT NULL,\n  description TEXT,\n  object_types TEXT[], -- person, vehicle, animal, etc.\n  min_confidence DECIMAL(5,2) NOT NULL DEFAULT 0.6,\n  cooldown_seconds INTEGER DEFAULT 60,\n  notification_channels TEXT[], -- email, sms, push, webhook\n  created_at TIMESTAMP WITH TIME ZONE DEFAULT NOW(),\n  updated_at TIMESTAMP WITH TIME ZONE DEFAULT NOW()\n)","-- Create index for better performance\nCREATE INDEX idx_events_camera_id ON events(camera_id)","CREATE INDEX idx_events_detected_at ON events(detected_at)","CREATE INDEX idx_cameras_branch_id ON cameras(branch_id)"}	44b2a868-310f-4d77-8d6b-f59e50f0fa5e
20250717220458	{"-- Enable Row Level Security on all tables that currently don't have it\nALTER TABLE public.ai_models ENABLE ROW LEVEL SECURITY","ALTER TABLE public.detection_rules ENABLE ROW LEVEL SECURITY","ALTER TABLE public.security_zones ENABLE ROW LEVEL SECURITY","-- Create RLS policies for ai_models (organization-based access)\nCREATE POLICY \\"Users can view AI models in their organization\\" \nON public.ai_models \nFOR SELECT \nUSING (\n  EXISTS (\n    SELECT 1 FROM user_roles ur \n    WHERE ur.user_id = auth.uid() \n    AND ur.organization_id IS NOT NULL\n  )\n)","CREATE POLICY \\"Admins can manage AI models\\" \nON public.ai_models \nFOR ALL \nUSING (\n  EXISTS (\n    SELECT 1 FROM user_roles ur \n    WHERE ur.user_id = auth.uid() \n    AND ur.role = 'admin'\n  )\n)","-- Create RLS policies for detection_rules (organization-based access)\nCREATE POLICY \\"Users can view detection rules in their organization\\" \nON public.detection_rules \nFOR SELECT \nUSING (\n  EXISTS (\n    SELECT 1 FROM user_roles ur \n    WHERE ur.user_id = auth.uid() \n    AND ur.organization_id = detection_rules.organization_id\n  )\n)","CREATE POLICY \\"Admins and managers can manage detection rules\\" \nON public.detection_rules \nFOR ALL \nUSING (\n  EXISTS (\n    SELECT 1 FROM user_roles ur \n    WHERE ur.user_id = auth.uid() \n    AND ur.organization_id = detection_rules.organization_id\n    AND ur.role IN ('admin', 'manager')\n  )\n)","-- Create RLS policies for security_zones (branch-based access)\nCREATE POLICY \\"Users can view security zones in their organization\\" \nON public.security_zones \nFOR SELECT \nUSING (\n  EXISTS (\n    SELECT 1 FROM user_roles ur \n    JOIN branches b ON ur.organization_id = b.organization_id\n    WHERE ur.user_id = auth.uid() \n    AND b.id = security_zones.branch_id\n  )\n)","CREATE POLICY \\"Admins and managers can manage security zones\\" \nON public.security_zones \nFOR ALL \nUSING (\n  EXISTS (\n    SELECT 1 FROM user_roles ur \n    JOIN branches b ON ur.organization_id = b.organization_id\n    WHERE ur.user_id = auth.uid() \n    AND b.id = security_zones.branch_id\n    AND ur.role IN ('admin', 'manager')\n  )\n)","-- Fix function security by setting proper search_path\nCREATE OR REPLACE FUNCTION public.update_modified_column()\nRETURNS trigger\nLANGUAGE plpgsql\nSECURITY DEFINER\nSET search_path = ''\nAS $function$\nBEGIN\n    NEW.updated_at = NOW();\n    RETURN NEW;\nEND;\n$function$","CREATE OR REPLACE FUNCTION public.get_user_role(user_id uuid)\nRETURNS user_role\nLANGUAGE sql\nSECURITY DEFINER\nSET search_path = ''\nAS $function$\n  SELECT role FROM public.user_roles WHERE user_id = $1 LIMIT 1\n$function$"}	f69c1427-0670-4ded-9e21-3ad6615394bc
20250717224834	{"-- Update subscription_tier enum to include AI-Premium\nALTER TYPE subscription_tier ADD VALUE IF NOT EXISTS 'ai-premium'","-- Create subscribers table for Stripe integration and billing\nCREATE TABLE IF NOT EXISTS public.subscribers (\n  id UUID PRIMARY KEY DEFAULT gen_random_uuid(),\n  user_id UUID REFERENCES auth.users(id) ON DELETE CASCADE,\n  email TEXT NOT NULL UNIQUE,\n  stripe_customer_id TEXT,\n  subscribed BOOLEAN NOT NULL DEFAULT false,\n  subscription_tier subscription_tier DEFAULT 'basic',\n  subscription_end TIMESTAMPTZ,\n  usage_analytics JSONB DEFAULT '{}',\n  billing_cycle TEXT DEFAULT 'monthly',\n  created_at TIMESTAMPTZ NOT NULL DEFAULT now(),\n  updated_at TIMESTAMPTZ NOT NULL DEFAULT now()\n)","-- Enable RLS on subscribers table\nALTER TABLE public.subscribers ENABLE ROW LEVEL SECURITY","-- Create policies for subscribers\nCREATE POLICY \\"Users can view their own subscription\\" ON public.subscribers\nFOR SELECT USING (user_id = auth.uid())","CREATE POLICY \\"Users can update their own subscription\\" ON public.subscribers\nFOR UPDATE USING (user_id = auth.uid())","CREATE POLICY \\"Service role can manage all subscriptions\\" ON public.subscribers\nFOR ALL USING (true)","-- Create user preferences table for multi-language support\nCREATE TABLE IF NOT EXISTS public.user_preferences (\n  id UUID PRIMARY KEY DEFAULT gen_random_uuid(),\n  user_id UUID REFERENCES auth.users(id) ON DELETE CASCADE UNIQUE,\n  language TEXT DEFAULT 'en' CHECK (language IN ('en', 'ar', 'uk', 'vi')),\n  timezone TEXT DEFAULT 'UTC',\n  theme TEXT DEFAULT 'system',\n  notifications JSONB DEFAULT '{\\"email\\": true, \\"push\\": true, \\"sms\\": false}',\n  created_at TIMESTAMPTZ NOT NULL DEFAULT now(),\n  updated_at TIMESTAMPTZ NOT NULL DEFAULT now()\n)","-- Enable RLS on user_preferences\nALTER TABLE public.user_preferences ENABLE ROW LEVEL SECURITY","-- Create policies for user_preferences\nCREATE POLICY \\"Users can manage their own preferences\\" ON public.user_preferences\nFOR ALL USING (user_id = auth.uid())","-- Update organizations table with subscription limits\nALTER TABLE public.organizations \nADD COLUMN IF NOT EXISTS subscription_limits JSONB DEFAULT '{\n  \\"cameras\\": 5,\n  \\"storage_gb\\": 10,\n  \\"ai_detections_per_month\\": 1000,\n  \\"users\\": 3,\n  \\"branches\\": 1\n}'","-- Create trigger to update updated_at for subscribers\nCREATE TRIGGER update_subscribers_updated_at\nBEFORE UPDATE ON public.subscribers\nFOR EACH ROW\nEXECUTE FUNCTION public.update_modified_column()","-- Create trigger to update updated_at for user_preferences\nCREATE TRIGGER update_user_preferences_updated_at\nBEFORE UPDATE ON public.user_preferences\nFOR EACH ROW\nEXECUTE FUNCTION public.update_modified_column()","-- Update handle_new_user function to create user preferences\nCREATE OR REPLACE FUNCTION public.handle_new_user()\nRETURNS trigger\nLANGUAGE plpgsql\nSECURITY DEFINER\nSET search_path TO ''\nAS $function$\nDECLARE\n  new_org_id UUID;\nBEGIN\n  -- Create the organization first\n  INSERT INTO public.organizations (name, subscription_tier)\n  VALUES (\n    COALESCE(new.raw_user_meta_data->>'organization_name', 'Default Organization'),\n    'basic'\n  )\n  RETURNING id INTO new_org_id;\n  \n  -- Create default branch for the organization\n  INSERT INTO public.branches (organization_id, name, address)\n  VALUES (new_org_id, 'Headquarters', 'Main Location');\n  \n  -- Add user role as admin for the organization\n  INSERT INTO public.user_roles (user_id, organization_id, role)\n  VALUES (new.id, new_org_id, 'admin');\n  \n  -- Create user preferences with default language\n  INSERT INTO public.user_preferences (user_id, language)\n  VALUES (new.id, COALESCE(new.raw_user_meta_data->>'language', 'en'));\n  \n  -- Create subscriber record\n  INSERT INTO public.subscribers (user_id, email, subscription_tier)\n  VALUES (new.id, new.email, 'basic');\n  \n  RETURN new;\nEND;\n$function$"}	1c330f4f-7377-4c1d-ae56-d46f2286e90e
20250719174037	{"-- Create table for legal documents (Terms of Service, Privacy Policy)\nCREATE TABLE public.legal_documents (\n  id UUID PRIMARY KEY DEFAULT gen_random_uuid(),\n  document_type TEXT NOT NULL UNIQUE CHECK (document_type IN ('terms_of_service', 'privacy_policy')),\n  title TEXT NOT NULL,\n  content TEXT NOT NULL,\n  version INTEGER NOT NULL DEFAULT 1,\n  effective_date TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW(),\n  created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW(),\n  updated_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW(),\n  created_by UUID REFERENCES auth.users(id),\n  updated_by UUID REFERENCES auth.users(id)\n)","-- Enable RLS\nALTER TABLE public.legal_documents ENABLE ROW LEVEL SECURITY","-- Create policies\n-- Anyone can view legal documents\nCREATE POLICY \\"Anyone can view legal documents\\" \nON public.legal_documents \nFOR SELECT \nUSING (true)","-- Only super admins can manage legal documents\nCREATE POLICY \\"Super admins can manage legal documents\\" \nON public.legal_documents \nFOR ALL \nUSING (\n  EXISTS (\n    SELECT 1 FROM user_roles ur \n    WHERE ur.user_id = auth.uid() \n    AND ur.role = 'admin'\n  )\n)","-- Create trigger for updated_at\nCREATE TRIGGER update_legal_documents_updated_at\nBEFORE UPDATE ON public.legal_documents\nFOR EACH ROW\nEXECUTE FUNCTION public.update_modified_column()","-- Insert default content\nINSERT INTO public.legal_documents (document_type, title, content) VALUES \n('terms_of_service', 'شروط الخدمة', 'محتوى شروط الخدمة سيتم تحديثه من قبل الإدارة.'),\n('privacy_policy', 'سياسة الخصوصية', 'محتوى سياسة الخصوصية سيتم تحديثه من قبل الإدارة.')"}	96a3ef42-1f2e-4528-98bb-35b1c1ac3462
20250719180019	{"-- Create a function to check if user is super admin\nCREATE OR REPLACE FUNCTION public.is_super_admin(user_email text)\nRETURNS boolean\nLANGUAGE sql\nSECURITY DEFINER\nSET search_path TO ''\nAS $function$\n  SELECT user_email = 'ashraffarid@gmail.com'\n$function$","-- Add super admin check function for authenticated users\nCREATE OR REPLACE FUNCTION public.is_current_user_super_admin()\nRETURNS boolean\nLANGUAGE sql\nSECURITY DEFINER\nSET search_path TO ''\nAS $function$\n  SELECT public.is_super_admin((SELECT email FROM auth.users WHERE id = auth.uid()))\n$function$","-- Update organizations table to add more subscription details\nALTER TABLE public.organizations \nADD COLUMN IF NOT EXISTS max_branches INTEGER DEFAULT 1,\nADD COLUMN IF NOT EXISTS features JSONB DEFAULT '{\\"ai_detection\\": true, \\"live_streaming\\": true, \\"recording\\": false, \\"analytics\\": false}',\nADD COLUMN IF NOT EXISTS subscription_status TEXT DEFAULT 'pending'","-- Update subscribers table with more detailed information\nALTER TABLE public.subscribers \nADD COLUMN IF NOT EXISTS subscription_status TEXT DEFAULT 'pending',\nADD COLUMN IF NOT EXISTS approved_by UUID REFERENCES auth.users(id),\nADD COLUMN IF NOT EXISTS approved_at TIMESTAMP WITH TIME ZONE,\nADD COLUMN IF NOT EXISTS last_activity TIMESTAMP WITH TIME ZONE DEFAULT now(),\nADD COLUMN IF NOT EXISTS notes TEXT","-- Update user_roles table to support more detailed permissions\nALTER TABLE public.user_roles \nADD COLUMN IF NOT EXISTS permissions JSONB DEFAULT '{\\"view_cameras\\": true, \\"manage_users\\": false, \\"view_analytics\\": true, \\"manage_settings\\": false}',\nADD COLUMN IF NOT EXISTS granted_by UUID REFERENCES auth.users(id),\nADD COLUMN IF NOT EXISTS granted_at TIMESTAMP WITH TIME ZONE DEFAULT now()","-- Create RLS policy for super admin to manage everything\nCREATE POLICY \\"Super admin can manage all subscribers\\" \nON public.subscribers \nFOR ALL \nUSING (public.is_current_user_super_admin())","CREATE POLICY \\"Super admin can manage all organizations\\" \nON public.organizations \nFOR ALL \nUSING (public.is_current_user_super_admin())","CREATE POLICY \\"Super admin can manage all user roles\\" \nON public.user_roles \nFOR ALL \nUSING (public.is_current_user_super_admin())","-- Update cameras table to include model and feature information\nALTER TABLE public.cameras \nADD COLUMN IF NOT EXISTS model TEXT DEFAULT 'AI-CAM-4K',\nADD COLUMN IF NOT EXISTS features JSONB DEFAULT '{\\"night_vision\\": true, \\"motion_detection\\": true, \\"ai_analysis\\": true, \\"audio_recording\\": false}',\nADD COLUMN IF NOT EXISTS max_resolution TEXT DEFAULT '4K'","-- Create a trigger to update last_activity for subscribers\nCREATE OR REPLACE FUNCTION public.update_subscriber_activity()\nRETURNS trigger\nLANGUAGE plpgsql\nSECURITY DEFINER\nSET search_path TO ''\nAS $function$\nBEGIN\n    UPDATE public.subscribers \n    SET last_activity = now() \n    WHERE user_id = NEW.user_id OR user_id = OLD.user_id;\n    RETURN COALESCE(NEW, OLD);\nEND;\n$function$","-- Add trigger for auth activity updates (when user logs in)\nCREATE OR REPLACE TRIGGER update_subscriber_activity_trigger\n    AFTER INSERT OR UPDATE ON auth.sessions\n    FOR EACH ROW\n    EXECUTE FUNCTION public.update_subscriber_activity()"}	227cb0c9-2ed5-4bf5-bbc3-c9d0f90ba96b
20250719180824	{"-- Update user roles enum to include new roles\nALTER TYPE user_role ADD VALUE IF NOT EXISTS 'super_admin'","ALTER TYPE user_role ADD VALUE IF NOT EXISTS 'company_admin'","ALTER TYPE user_role ADD VALUE IF NOT EXISTS 'branch_manager'"}	a715cd4d-42ee-4de6-8442-be4ae93cd00a
20250719181643	{"-- Role migration skipped (uses BEGIN/COMMIT which Supabase migrations don't support)\n-- UPDATE user_roles SET role = 'company_admin' WHERE role = 'admin';\n-- UPDATE user_roles SET role = 'branch_manager' WHERE role = 'manager'"}	14637df6-665b-4b6a-9f3c-56812654ca9c
20250719184214	{"-- إضافة جدول الأنشطة/الصناعات\nCREATE TABLE public.industries (\n    id UUID NOT NULL DEFAULT gen_random_uuid() PRIMARY KEY,\n    name TEXT NOT NULL,\n    name_ar TEXT NOT NULL,\n    description TEXT,\n    description_ar TEXT,\n    icon TEXT DEFAULT 'building',\n    active BOOLEAN NOT NULL DEFAULT true,\n    created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(),\n    updated_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now()\n)","-- إضافة عمود industry_id لجدول organizations\nALTER TABLE public.organizations \nADD COLUMN industry_id UUID REFERENCES public.industries(id)","-- إضافة عمود organization_id لجدول subscribers لربطهم مع المؤسسات\nALTER TABLE public.subscribers \nADD COLUMN organization_id UUID REFERENCES public.organizations(id)","-- إضافة بيانات الأنشطة الافتراضية\nINSERT INTO public.industries (name, name_ar, description, description_ar, icon) VALUES\n('Restaurant', 'مطعم', 'Restaurant and food service businesses', 'المطاعم وخدمات الطعام', 'utensils'),\n('Hospital', 'مستشفى', 'Healthcare and medical facilities', 'المرافق الصحية والطبية', 'heart-pulse'),\n('Company', 'شركة', 'Corporate and business organizations', 'الشركات والمؤسسات التجارية', 'building-2'),\n('Hotel', 'فندق', 'Hospitality and accommodation services', 'خدمات الضيافة والإقامة', 'bed'),\n('Retail', 'تجارة التجزئة', 'Retail stores and shopping centers', 'متاجر التجزئة ومراكز التسوق', 'shopping-cart'),\n('Education', 'تعليم', 'Educational institutions and schools', 'المؤسسات التعليمية والمدارس', 'graduation-cap'),\n('Government', 'حكومة', 'Government agencies and public services', 'الوكالات الحكومية والخدمات العامة', 'landmark'),\n('Sports', 'رياضة', 'Sports facilities and fitness centers', 'المرافق الرياضية ومراكز اللياقة', 'dumbbell')","-- إنشاء RLS policies للأنشطة\nALTER TABLE public.industries ENABLE ROW LEVEL SECURITY","-- Super admin يمكنه إدارة جميع الأنشطة\nCREATE POLICY \\"Super admin can manage all industries\\" \nON public.industries \nFOR ALL \nUSING (is_current_user_super_admin())","-- المستخدمون يمكنهم رؤية جميع الأنشطة\nCREATE POLICY \\"Users can view all industries\\" \nON public.industries \nFOR SELECT \nUSING (true)","-- تحديث trigger للـ updated_at\nCREATE TRIGGER update_industries_updated_at\n    BEFORE UPDATE ON public.industries\n    FOR EACH ROW\n    EXECUTE FUNCTION public.update_modified_column()"}	151beb3d-0dce-4580-92f0-813e987928d2
20250719195731	{"-- Create camera sources table for super admin management\nCREATE TABLE public.camera_sources (\n  id UUID NOT NULL DEFAULT gen_random_uuid() PRIMARY KEY,\n  name TEXT NOT NULL,\n  name_ar TEXT NOT NULL,\n  protocol TEXT NOT NULL, -- rtsp, http, youtube, file, etc.\n  requires_auth BOOLEAN NOT NULL DEFAULT false,\n  default_port INTEGER,\n  url_pattern TEXT, -- pattern for URL construction\n  description TEXT,\n  description_ar TEXT,\n  icon TEXT DEFAULT 'camera',\n  active BOOLEAN NOT NULL DEFAULT true,\n  created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(),\n  updated_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(),\n  created_by UUID REFERENCES auth.users(id)\n)","-- Enable RLS\nALTER TABLE public.camera_sources ENABLE ROW LEVEL SECURITY","-- Super admin can manage all camera sources\nCREATE POLICY \\"Super admin can manage camera sources\\" \nON public.camera_sources \nFOR ALL \nUSING (is_current_user_super_admin())","-- All authenticated users can view camera sources\nCREATE POLICY \\"Users can view camera sources\\" \nON public.camera_sources \nFOR SELECT \nUSING (auth.role() = 'authenticated' AND active = true)","-- Create trigger for updated_at\nCREATE TRIGGER update_camera_sources_updated_at\nBEFORE UPDATE ON public.camera_sources\nFOR EACH ROW\nEXECUTE FUNCTION public.update_modified_column()","-- Insert default camera sources\nINSERT INTO public.camera_sources (name, name_ar, protocol, requires_auth, default_port, url_pattern, description, description_ar) VALUES\n('RTSP Stream', 'بث RTSP', 'rtsp', true, 554, 'rtsp://[username]:[password]@[host]:[port]/[path]', 'Real Time Streaming Protocol for IP cameras', 'بروتوكول البث المباشر لكاميرات IP'),\n('HTTP Stream', 'بث HTTP', 'http', false, 80, 'http://[host]:[port]/[path]', 'HTTP video stream', 'بث الفيديو عبر HTTP'),\n('HTTPS Stream', 'بث HTTPS', 'https', false, 443, 'https://[host]:[port]/[path]', 'Secure HTTP video stream', 'بث الفيديو الآمن عبر HTTPS'),\n('YouTube Live', 'يوتيوب مباشر', 'youtube', false, NULL, 'https://youtube.com/watch?v=[id]', 'YouTube live stream', 'البث المباشر من يوتيوب'),\n('File Upload', 'رفع ملف', 'file', false, NULL, NULL, 'Upload video file', 'رفع ملف فيديو'),\n('Webcam', 'كاميرا ويب', 'webcam', false, NULL, NULL, 'Computer webcam', 'كاميرا الكمبيوتر'),\n('HLS Stream', 'بث HLS', 'hls', false, NULL, 'http://[host]:[port]/[path].m3u8', 'HTTP Live Streaming', 'البث المباشر عبر HTTP')","-- Create network discovery results table for real scanning\nCREATE TABLE public.network_scan_results (\n  id UUID NOT NULL DEFAULT gen_random_uuid() PRIMARY KEY,\n  ip_address INET NOT NULL,\n  port INTEGER NOT NULL,\n  manufacturer TEXT,\n  model TEXT,\n  device_type TEXT,\n  protocol TEXT,\n  mac_address TEXT,\n  hostname TEXT,\n  discovered_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(),\n  scan_session_id UUID NOT NULL,\n  user_id UUID REFERENCES auth.users(id)\n)","-- Enable RLS\nALTER TABLE public.network_scan_results ENABLE ROW LEVEL SECURITY","-- Users can only see their own scan results\nCREATE POLICY \\"Users can view their own scan results\\" \nON public.network_scan_results \nFOR SELECT \nUSING (user_id = auth.uid())","-- Users can insert their own scan results\nCREATE POLICY \\"Users can insert their own scan results\\" \nON public.network_scan_results \nFOR INSERT \nWITH CHECK (user_id = auth.uid())"}	ec0b9fae-b66d-4e25-8566-9e1db5da94e6
20250719200553	{"-- Add security zone and description to cameras table\nALTER TABLE public.cameras \nADD COLUMN security_zone_id uuid REFERENCES public.security_zones(id),\nADD COLUMN description text,\nADD COLUMN detection_rules jsonb DEFAULT '[]'::jsonb","-- Update cameras table with updated_at trigger\nCREATE TRIGGER update_cameras_updated_at\n    BEFORE UPDATE ON public.cameras\n    FOR EACH ROW\n    EXECUTE FUNCTION public.update_modified_column()","-- Add some default detection rule types\nINSERT INTO public.detection_rules (name, description, object_types, min_confidence, organization_id) VALUES\n('Fire Detection', 'Detect fire and smoke incidents', ARRAY['fire', 'smoke'], 0.8, null),\n('Person Counting', 'Count number of people in area', ARRAY['person'], 0.7, null),\n('Cleanliness Monitoring', 'Monitor cleanliness and hygiene standards', ARRAY['garbage', 'spill', 'mess'], 0.6, null),\n('Vehicle Detection', 'Detect vehicles in restricted areas', ARRAY['car', 'truck', 'motorcycle'], 0.7, null),\n('Intrusion Detection', 'Detect unauthorized access', ARRAY['person'], 0.8, null)\nON CONFLICT DO NOTHING"}	ba710535-8640-4b96-9e4b-d2d97be25b85
20250719202311	{"-- Make sensitivity_level nullable since it's optional\nALTER TABLE public.security_zones \nALTER COLUMN sensitivity_level DROP NOT NULL"}	c0d1d919-273d-4d50-afa1-3782cdc62c91
20250719202829	{"-- Update RLS policies for security_zones to allow users to create zones\nDROP POLICY IF EXISTS \\"Admins and managers can manage security zones\\" ON public.security_zones","-- Create separate policies for different operations\nCREATE POLICY \\"Users can create security zones in their organization\\" \nON public.security_zones \nFOR INSERT \nWITH CHECK (\n  EXISTS (\n    SELECT 1 FROM user_roles ur \n    JOIN branches b ON ur.organization_id = b.organization_id\n    WHERE ur.user_id = auth.uid() \n    AND b.id = security_zones.branch_id\n  )\n)","CREATE POLICY \\"Admins and managers can update security zones\\" \nON public.security_zones \nFOR UPDATE \nUSING (\n  EXISTS (\n    SELECT 1 FROM user_roles ur \n    JOIN branches b ON ur.organization_id = b.organization_id\n    WHERE ur.user_id = auth.uid() \n    AND b.id = security_zones.branch_id\n    AND ur.role IN ('admin', 'manager')\n  )\n)","CREATE POLICY \\"Admins and managers can delete security zones\\" \nON public.security_zones \nFOR DELETE \nUSING (\n  EXISTS (\n    SELECT 1 FROM user_roles ur \n    JOIN branches b ON ur.organization_id = b.organization_id\n    WHERE ur.user_id = auth.uid() \n    AND b.id = security_zones.branch_id\n    AND ur.role IN ('admin', 'manager')\n  )\n)"}	25a455cc-1b6a-462a-8e69-7d9e06a81c67
20250719203405	{"-- Skipped: hardcoded cloud user IDs not applicable to local DB\n-- INSERT INTO public.user_roles (user_id, organization_id, role, permissions) ..."}	fb9bddce-de94-432c-9a6e-f658697e1e56
20250719203750	{"-- Update user roles enum to include proper hierarchy\nALTER TYPE user_role ADD VALUE IF NOT EXISTS 'super_admin'","ALTER TYPE user_role ADD VALUE IF NOT EXISTS 'company_admin'","ALTER TYPE user_role ADD VALUE IF NOT EXISTS 'branch_manager'","-- Create a table to map branch managers to specific branches\nCREATE TABLE IF NOT EXISTS public.user_branch_access (\n    id UUID PRIMARY KEY DEFAULT gen_random_uuid(),\n    user_id UUID REFERENCES auth.users(id) ON DELETE CASCADE,\n    branch_id UUID REFERENCES branches(id) ON DELETE CASCADE,\n    granted_by UUID REFERENCES auth.users(id),\n    granted_at TIMESTAMP WITH TIME ZONE DEFAULT NOW(),\n    UNIQUE(user_id, branch_id)\n)","-- Enable RLS on user_branch_access\nALTER TABLE public.user_branch_access ENABLE ROW LEVEL SECURITY","-- Create policies for user_branch_access\nCREATE POLICY \\"Super admin can manage all branch access\\" \nON public.user_branch_access \nFOR ALL \nUSING (is_current_user_super_admin())","CREATE POLICY \\"Company admins can manage branch access in their organization\\" \nON public.user_branch_access \nFOR ALL \nUSING (\n  EXISTS (\n    SELECT 1 FROM user_roles ur \n    JOIN branches b ON user_branch_access.branch_id = b.id\n    WHERE ur.user_id = auth.uid() \n    AND ur.organization_id = b.organization_id\n    AND ur.role IN ('super_admin', 'company_admin')\n  )\n)","CREATE POLICY \\"Users can view their own branch access\\" \nON public.user_branch_access \nFOR SELECT \nUSING (user_id = auth.uid())","-- Update organizations policies for proper hierarchy\nDROP POLICY IF EXISTS \\"Users can view their organization\\" ON organizations","CREATE POLICY \\"Users can view their organization\\" ON organizations\nFOR SELECT USING (\n  is_current_user_super_admin() OR\n  EXISTS (\n    SELECT 1 FROM user_roles \n    WHERE user_id = auth.uid() \n    AND organization_id = organizations.id\n  )\n)","-- Update branches policies for proper hierarchy\nDROP POLICY IF EXISTS \\"Users can view branches in their organization\\" ON branches","CREATE POLICY \\"Users can view branches in their organization\\" ON branches\nFOR SELECT USING (\n  is_current_user_super_admin() OR\n  EXISTS (\n    SELECT 1 FROM user_roles ur\n    WHERE ur.user_id = auth.uid() \n    AND ur.organization_id = branches.organization_id\n  ) OR\n  EXISTS (\n    SELECT 1 FROM user_branch_access uba\n    WHERE uba.user_id = auth.uid()\n    AND uba.branch_id = branches.id\n  )\n)","-- Update cameras policies for proper hierarchy\nDROP POLICY IF EXISTS \\"Users can view cameras in their organization\\" ON cameras","CREATE POLICY \\"Users can view cameras in their organization\\" ON cameras\nFOR SELECT USING (\n  is_current_user_super_admin() OR\n  EXISTS (\n    SELECT 1 FROM user_roles ur\n    JOIN branches b ON cameras.branch_id = b.id\n    WHERE ur.user_id = auth.uid() \n    AND ur.organization_id = b.organization_id\n  ) OR\n  EXISTS (\n    SELECT 1 FROM user_branch_access uba\n    WHERE uba.user_id = auth.uid()\n    AND uba.branch_id = cameras.branch_id\n  )\n)","-- Update security zones policies for proper hierarchy\nDROP POLICY IF EXISTS \\"Users can view security zones in their organization\\" ON security_zones","CREATE POLICY \\"Users can view security zones in their organization\\" ON security_zones\nFOR SELECT USING (\n  is_current_user_super_admin() OR\n  EXISTS (\n    SELECT 1 FROM user_roles ur\n    JOIN branches b ON security_zones.branch_id = b.id\n    WHERE ur.user_id = auth.uid() \n    AND ur.organization_id = b.organization_id\n  ) OR\n  EXISTS (\n    SELECT 1 FROM user_branch_access uba\n    WHERE uba.user_id = auth.uid()\n    AND uba.branch_id = security_zones.branch_id\n  )\n)","DROP POLICY IF EXISTS \\"Users can create security zones in their organization\\" ON security_zones","CREATE POLICY \\"Users can create security zones in their organization\\" ON security_zones\nFOR INSERT WITH CHECK (\n  is_current_user_super_admin() OR\n  EXISTS (\n    SELECT 1 FROM user_roles ur\n    JOIN branches b ON security_zones.branch_id = b.id\n    WHERE ur.user_id = auth.uid() \n    AND ur.organization_id = b.organization_id\n    AND ur.role IN ('company_admin', 'branch_manager')\n  ) OR\n  EXISTS (\n    SELECT 1 FROM user_branch_access uba\n    WHERE uba.user_id = auth.uid()\n    AND uba.branch_id = security_zones.branch_id\n  )\n)","DROP POLICY IF EXISTS \\"Admins and managers can update security zones\\" ON security_zones","CREATE POLICY \\"Admins and managers can update security zones\\" ON security_zones\nFOR UPDATE USING (\n  is_current_user_super_admin() OR\n  EXISTS (\n    SELECT 1 FROM user_roles ur\n    JOIN branches b ON security_zones.branch_id = b.id\n    WHERE ur.user_id = auth.uid() \n    AND ur.organization_id = b.organization_id\n    AND ur.role IN ('company_admin', 'branch_manager')\n  ) OR\n  EXISTS (\n    SELECT 1 FROM user_branch_access uba\n    WHERE uba.user_id = auth.uid()\n    AND uba.branch_id = security_zones.branch_id\n  )\n)","DROP POLICY IF EXISTS \\"Admins and managers can delete security zones\\" ON security_zones","CREATE POLICY \\"Admins and managers can delete security zones\\" ON security_zones\nFOR DELETE USING (\n  is_current_user_super_admin() OR\n  EXISTS (\n    SELECT 1 FROM user_roles ur\n    JOIN branches b ON security_zones.branch_id = b.id\n    WHERE ur.user_id = auth.uid() \n    AND ur.organization_id = b.organization_id\n    AND ur.role IN ('company_admin', 'branch_manager')\n  ) OR\n  EXISTS (\n    SELECT 1 FROM user_branch_access uba\n    WHERE uba.user_id = auth.uid()\n    AND uba.branch_id = security_zones.branch_id\n  )\n)"}	ef74d52f-1f69-4ee4-9750-bb84db11c60f
20250719205321	{"-- Add active column to security_zones table\nALTER TABLE public.security_zones \nADD COLUMN IF NOT EXISTS active BOOLEAN NOT NULL DEFAULT true","-- Add index for better performance when filtering by active status\nCREATE INDEX IF NOT EXISTS idx_security_zones_active ON public.security_zones(active)","-- Add updated_at trigger for security_zones if it doesn't exist\nDROP TRIGGER IF EXISTS update_security_zones_updated_at ON public.security_zones","CREATE TRIGGER update_security_zones_updated_at\n    BEFORE UPDATE ON public.security_zones\n    FOR EACH ROW\n    EXECUTE FUNCTION public.update_modified_column()"}	df19613b-590e-4c77-b6da-d7813856770e
20250719211411	{"-- Add RLS policies for camera management\n-- Allow organization admins and managers to manage cameras\n\nCREATE POLICY \\"Admins and managers can update cameras\\"\nON public.cameras\nFOR UPDATE\nUSING (\n  EXISTS (\n    SELECT 1 \n    FROM user_roles ur\n    JOIN branches b ON ur.organization_id = b.organization_id\n    WHERE ur.user_id = auth.uid() \n    AND b.id = cameras.branch_id \n    AND ur.role IN ('admin', 'manager')\n  )\n)","CREATE POLICY \\"Admins and managers can insert cameras\\"\nON public.cameras\nFOR INSERT\nWITH CHECK (\n  EXISTS (\n    SELECT 1 \n    FROM user_roles ur\n    JOIN branches b ON ur.organization_id = b.organization_id\n    WHERE ur.user_id = auth.uid() \n    AND b.id = cameras.branch_id \n    AND ur.role IN ('admin', 'manager')\n  )\n)","CREATE POLICY \\"Admins and managers can delete cameras\\"\nON public.cameras\nFOR DELETE\nUSING (\n  EXISTS (\n    SELECT 1 \n    FROM user_roles ur\n    JOIN branches b ON ur.organization_id = b.organization_id\n    WHERE ur.user_id = auth.uid() \n    AND b.id = cameras.branch_id \n    AND ur.role IN ('admin', 'manager')\n  )\n)"}	e62a1641-2095-4bf3-af06-77a7acd41b21
20250719211832	{"-- Add missing updated_at column to cameras table\nALTER TABLE public.cameras\nADD COLUMN IF NOT EXISTS updated_at timestamp with time zone DEFAULT now()","-- Trigger already exists in earlier migration; skip recreation"}	b6b92ab5-f23f-4131-82f5-8123e2760b20
20250719211912	{"-- Check if updated_at column exists and add it if missing\nDO $$ \nBEGIN\n    IF NOT EXISTS (\n        SELECT 1 \n        FROM information_schema.columns \n        WHERE table_name = 'cameras' \n        AND column_name = 'updated_at'\n        AND table_schema = 'public'\n    ) THEN\n        ALTER TABLE public.cameras \n        ADD COLUMN updated_at timestamp with time zone DEFAULT now();\n    END IF;\nEND $$"}	8632895c-ff0f-4a8f-a8ec-1dba85fbedb9
20250719212133	{"-- Add enabled column to cameras table for activation status\nALTER TABLE public.cameras \nADD COLUMN enabled boolean NOT NULL DEFAULT true","-- Update existing cameras to be enabled by default\nUPDATE public.cameras \nSET enabled = true","-- Add comment to clarify the difference\nCOMMENT ON COLUMN public.cameras.enabled IS 'Camera activation status (مفعل/غير مفعل)'","COMMENT ON COLUMN public.cameras.status IS 'Camera connection status based on actual data/stream (متصلة/غير متصلة)'"}	c5eae882-74a2-49d8-abd3-7316429c1bcd
20250719213421	{"-- Create detection_types enum\nCREATE TYPE detection_method AS ENUM ('file', 'api')","-- Create alert_templates table for managing different types of alerts\nCREATE TABLE public.alert_templates (\n  id UUID NOT NULL DEFAULT gen_random_uuid() PRIMARY KEY,\n  name TEXT NOT NULL,\n  name_ar TEXT NOT NULL,\n  description TEXT,\n  description_ar TEXT,\n  detection_method detection_method NOT NULL,\n  \n  -- For file-based detection\n  model_file_url TEXT,\n  model_type TEXT, -- 'yolov8', 'yolov5', etc.\n  \n  -- For API-based detection\n  huggingface_api_key TEXT,\n  model_api_endpoint TEXT,\n  \n  enabled BOOLEAN NOT NULL DEFAULT true,\n  created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(),\n  updated_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(),\n  created_by UUID REFERENCES auth.users(id)\n)","-- Create camera_alert_assignments table to link cameras with alert templates\nCREATE TABLE public.camera_alert_assignments (\n  id UUID NOT NULL DEFAULT gen_random_uuid() PRIMARY KEY,\n  camera_id UUID NOT NULL,\n  alert_template_id UUID NOT NULL REFERENCES public.alert_templates(id) ON DELETE CASCADE,\n  enabled BOOLEAN NOT NULL DEFAULT true,\n  confidence_threshold NUMERIC DEFAULT 0.7,\n  created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(),\n  UNIQUE(camera_id, alert_template_id)\n)","-- Enable RLS on both tables\nALTER TABLE public.alert_templates ENABLE ROW LEVEL SECURITY","ALTER TABLE public.camera_alert_assignments ENABLE ROW LEVEL SECURITY","-- RLS policies for alert_templates\nCREATE POLICY \\"Super admin can manage all alert templates\\"\nON public.alert_templates\nFOR ALL\nTO authenticated\nUSING (is_current_user_super_admin())","CREATE POLICY \\"Users can view alert templates\\"\nON public.alert_templates\nFOR SELECT\nTO authenticated\nUSING (enabled = true)","-- RLS policies for camera_alert_assignments\nCREATE POLICY \\"Super admin can manage all camera alert assignments\\"\nON public.camera_alert_assignments\nFOR ALL\nTO authenticated\nUSING (is_current_user_super_admin())","CREATE POLICY \\"Users can view camera alert assignments in their organization\\"\nON public.camera_alert_assignments\nFOR SELECT\nTO authenticated\nUSING (\n  EXISTS (\n    SELECT 1 FROM cameras c\n    JOIN branches b ON c.branch_id = b.id\n    JOIN user_roles ur ON ur.organization_id = b.organization_id\n    WHERE c.id = camera_alert_assignments.camera_id\n    AND ur.user_id = auth.uid()\n  )\n)","-- Create update trigger for alert_templates\nCREATE TRIGGER update_alert_templates_updated_at\n  BEFORE UPDATE ON public.alert_templates\n  FOR EACH ROW\n  EXECUTE FUNCTION public.update_modified_column()","-- Insert some default alert templates\nINSERT INTO public.alert_templates (name, name_ar, description, description_ar, detection_method, model_type) VALUES\n('Fire Detection', 'كشف الحرائق', 'Detects fire and smoke in camera feeds', 'يكشف النار والدخان في لقطات الكاميرا', 'file', 'yolov8'),\n('Person Detection', 'كشف الأشخاص', 'Detects people in restricted areas', 'يكشف الأشخاص في المناطق المحظورة', 'file', 'yolov8'),\n('Violence Detection', 'كشف العنف', 'Detects violent behavior and fights', 'يكشف السلوك العنيف والمشاجرات', 'api', null),\n('Weapon Detection', 'كشف الأسلحة', 'Detects weapons like guns and knives', 'يكشف الأسلحة مثل المسدسات والسكاكين', 'file', 'yolov8')"}	d79afa51-ec57-4dac-8d16-a5128272bbf5
20250719214447	{"-- Skipped: hardcoded cloud user IDs not applicable to local DB\n-- INSERT INTO public.user_roles ...\n-- UPDATE public.user_roles ..."}	67fc4cf3-3a2e-4477-8b36-dd613c1ddaa4
20250719215338	{"-- Create storage configuration table for system-wide storage settings\nCREATE TABLE public.storage_configs (\n  id UUID NOT NULL DEFAULT gen_random_uuid() PRIMARY KEY,\n  name TEXT NOT NULL,\n  type TEXT NOT NULL CHECK (type IN ('google_drive', 'ftp', 'aws_s3', 'local')),\n  config JSONB NOT NULL DEFAULT '{}',\n  is_active BOOLEAN NOT NULL DEFAULT false,\n  created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(),\n  updated_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(),\n  created_by UUID REFERENCES auth.users(id)\n)","-- Create system settings table for general system configurations\nCREATE TABLE public.system_settings (\n  id UUID NOT NULL DEFAULT gen_random_uuid() PRIMARY KEY,\n  setting_key TEXT NOT NULL UNIQUE,\n  setting_value JSONB NOT NULL DEFAULT '{}',\n  description TEXT,\n  created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(),\n  updated_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(),\n  updated_by UUID REFERENCES auth.users(id)\n)","-- Create storage bucket for model files\nINSERT INTO storage.buckets (id, name, public, file_size_limit, allowed_mime_types)\nVALUES (\n  'model-files',\n  'model-files', \n  false,\n  104857600, -- 100MB limit\n  ARRAY['application/octet-stream', 'application/x-pytorch', 'application/x-onnx', 'application/zip']\n)","-- Enable RLS on storage tables\nALTER TABLE public.storage_configs ENABLE ROW LEVEL SECURITY","ALTER TABLE public.system_settings ENABLE ROW LEVEL SECURITY","-- RLS policies for storage_configs (super admin only)\nCREATE POLICY \\"Super admin can manage storage configs\\"\nON public.storage_configs\nFOR ALL\nTO authenticated\nUSING (is_current_user_super_admin())","-- RLS policies for system_settings (super admin only)\nCREATE POLICY \\"Super admin can manage system settings\\"\nON public.system_settings\nFOR ALL\nTO authenticated\nUSING (is_current_user_super_admin())","-- Storage policies for model files\nCREATE POLICY \\"Super admin can manage model files\\"\nON storage.objects\nFOR ALL\nTO authenticated\nUSING (bucket_id = 'model-files' AND is_current_user_super_admin())","CREATE POLICY \\"Users can view model files\\"\nON storage.objects\nFOR SELECT\nTO authenticated\nUSING (bucket_id = 'model-files')","-- Update triggers\nCREATE TRIGGER update_storage_configs_updated_at\n  BEFORE UPDATE ON public.storage_configs\n  FOR EACH ROW\n  EXECUTE FUNCTION public.update_modified_column()","CREATE TRIGGER update_system_settings_updated_at\n  BEFORE UPDATE ON public.system_settings\n  FOR EACH ROW\n  EXECUTE FUNCTION public.update_modified_column()","-- Insert default storage configuration\nINSERT INTO public.storage_configs (name, type, config, is_active) VALUES\n('Local Storage', 'local', '{\\"path\\": \\"/uploads/models\\"}', true)","-- Insert default system settings\nINSERT INTO public.system_settings (setting_key, setting_value, description) VALUES\n('default_storage_provider', '{\\"type\\": \\"local\\"}', 'Default storage provider for model files'),\n('max_file_size_mb', '{\\"value\\": 100}', 'Maximum file size in MB for model uploads')"}	d6b6b403-3027-485b-aa20-bbcea42aef1e
20250719220543	{"-- Create event types table\nCREATE TABLE public.event_types (\n  id UUID NOT NULL DEFAULT gen_random_uuid() PRIMARY KEY,\n  name_en TEXT NOT NULL,\n  name_ar TEXT NOT NULL,\n  description_en TEXT,\n  description_ar TEXT,\n  icon TEXT DEFAULT 'alert-circle',\n  color TEXT DEFAULT '#3b82f6',\n  enabled BOOLEAN NOT NULL DEFAULT true,\n  created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(),\n  updated_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(),\n  created_by UUID\n)","-- Create camera event assignments table (many-to-many relationship)\nCREATE TABLE public.camera_event_assignments (\n  id UUID NOT NULL DEFAULT gen_random_uuid() PRIMARY KEY,\n  camera_id UUID NOT NULL,\n  event_type_id UUID NOT NULL,\n  enabled BOOLEAN NOT NULL DEFAULT true,\n  confidence_threshold NUMERIC DEFAULT 0.7,\n  created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(),\n  UNIQUE(camera_id, event_type_id)\n)","-- Enable RLS\nALTER TABLE public.event_types ENABLE ROW LEVEL SECURITY","ALTER TABLE public.camera_event_assignments ENABLE ROW LEVEL SECURITY","-- RLS policies for event_types\nCREATE POLICY \\"Super admin can manage all event types\\"\nON public.event_types\nFOR ALL\nTO authenticated\nUSING (is_current_user_super_admin())","CREATE POLICY \\"Users can view event types\\"\nON public.event_types\nFOR SELECT\nTO authenticated\nUSING (enabled = true)","-- RLS policies for camera_event_assignments\nCREATE POLICY \\"Users can view camera event assignments in their organization\\"\nON public.camera_event_assignments\nFOR SELECT\nTO authenticated\nUSING (\n  EXISTS (\n    SELECT 1 FROM cameras c\n    JOIN branches b ON c.branch_id = b.id\n    JOIN user_roles ur ON ur.organization_id = b.organization_id\n    WHERE c.id = camera_event_assignments.camera_id \n    AND ur.user_id = auth.uid()\n  )\n)","CREATE POLICY \\"Admins and managers can manage camera event assignments\\"\nON public.camera_event_assignments\nFOR ALL\nTO authenticated\nUSING (\n  EXISTS (\n    SELECT 1 FROM cameras c\n    JOIN branches b ON c.branch_id = b.id\n    JOIN user_roles ur ON ur.organization_id = b.organization_id\n    WHERE c.id = camera_event_assignments.camera_id \n    AND ur.user_id = auth.uid()\n    AND ur.role IN ('admin', 'manager')\n  )\n)","-- Update triggers\nCREATE TRIGGER update_event_types_updated_at\n  BEFORE UPDATE ON public.event_types\n  FOR EACH ROW\n  EXECUTE FUNCTION public.update_modified_column()","-- Insert default event types\nINSERT INTO public.event_types (name_en, name_ar, description_en, description_ar, icon, color) VALUES\n('person', 'شخص', 'Person detection', 'اكتشاف الأشخاص', 'user', '#10b981'),\n('car', 'سيارة', 'Vehicle detection', 'اكتشاف المركبات', 'car', '#3b82f6'),\n('fire', 'حريق', 'Fire detection', 'اكتشاف الحرائق', 'flame', '#ef4444'),\n('weapon', 'سلاح', 'Weapon detection', 'اكتشاف الأسلحة', 'shield-alert', '#dc2626'),\n('theft', 'سرقة', 'Theft detection', 'اكتشاف السرقة', 'alert-triangle', '#f59e0b'),\n('intrusion', 'تسلل', 'Intrusion detection', 'اكتشاف التسلل', 'shield-x', '#8b5cf6'),\n('crowd', 'حشد', 'Crowd detection', 'اكتشاف التجمعات', 'users', '#06b6d4'),\n('violence', 'عنف', 'Violence detection', 'اكتشاف العنف', 'zap', '#e11d48')"}	4cf39518-efaf-493f-be93-1884522633c4
20250719223046	{"-- Create table to link alert templates with event types\nCREATE TABLE public.alert_template_events (\n  id UUID NOT NULL DEFAULT gen_random_uuid() PRIMARY KEY,\n  alert_template_id UUID NOT NULL REFERENCES public.alert_templates(id) ON DELETE CASCADE,\n  event_type_id UUID NOT NULL REFERENCES public.event_types(id) ON DELETE CASCADE,\n  created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(),\n  UNIQUE(alert_template_id, event_type_id)\n)","-- Enable RLS\nALTER TABLE public.alert_template_events ENABLE ROW LEVEL SECURITY","-- RLS policies for alert_template_events\nCREATE POLICY \\"Super admin can manage alert template events\\"\nON public.alert_template_events\nFOR ALL\nTO authenticated\nUSING (is_current_user_super_admin())","CREATE POLICY \\"Users can view alert template events\\"\nON public.alert_template_events\nFOR SELECT\nTO authenticated\nUSING (true)"}	e183ded2-95a0-4610-b6bd-81a1ccbaa1ac
20250719232934	{"-- Create notification methods table\nCREATE TABLE public.notification_methods (\n  id UUID NOT NULL DEFAULT gen_random_uuid() PRIMARY KEY,\n  name_ar TEXT NOT NULL,\n  name_en TEXT NOT NULL,\n  type TEXT NOT NULL CHECK (type IN ('whatsapp', 'email', 'phone', 'sms')),\n  icon TEXT DEFAULT 'bell',\n  enabled BOOLEAN NOT NULL DEFAULT true,\n  settings JSONB DEFAULT '{}',\n  created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(),\n  updated_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(),\n  created_by UUID REFERENCES auth.users(id)\n)","-- Enable RLS\nALTER TABLE public.notification_methods ENABLE ROW LEVEL SECURITY","-- Create policies\nCREATE POLICY \\"Super admin can manage notification methods\\" \nON public.notification_methods \nFOR ALL \nUSING (is_current_user_super_admin())","CREATE POLICY \\"Users can view notification methods\\" \nON public.notification_methods \nFOR SELECT \nUSING (enabled = true)","-- Add user notification preferences to user_roles table\nALTER TABLE public.user_roles \nADD COLUMN notification_type TEXT CHECK (notification_type IN ('whatsapp', 'email', 'phone', 'sms')),\nADD COLUMN notification_value TEXT","-- Insert default notification methods\nINSERT INTO public.notification_methods (name_ar, name_en, type, icon) VALUES\n('واتساب', 'WhatsApp', 'whatsapp', 'message-circle'),\n('البريد الإلكتروني', 'Email', 'email', 'mail'),\n('الهاتف', 'Phone', 'phone', 'phone'),\n('الرسائل النصية', 'SMS', 'sms', 'message-square')","-- Create trigger for updated_at\nCREATE TRIGGER update_notification_methods_updated_at\nBEFORE UPDATE ON public.notification_methods\nFOR EACH ROW\nEXECUTE FUNCTION public.update_modified_column()"}	256767ac-78c6-419c-b5d3-6999ac5380e7
20250719234548	{"-- Add name field to user_roles table to store representative names\nALTER TABLE public.user_roles \nADD COLUMN name TEXT"}	6bcf61fb-e000-42c7-815b-47e9611125c7
20250719235604	{"-- Create workflow forms table for system admin to create default forms\nCREATE TABLE public.workflow_forms (\n  id UUID NOT NULL DEFAULT gen_random_uuid() PRIMARY KEY,\n  name TEXT NOT NULL,\n  name_ar TEXT NOT NULL,\n  description TEXT,\n  description_ar TEXT,\n  activity_type TEXT NOT NULL,\n  form_fields JSONB NOT NULL DEFAULT '[]'::jsonb,\n  is_active BOOLEAN NOT NULL DEFAULT true,\n  created_by UUID,\n  created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(),\n  updated_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now()\n)","-- Create form assignments table for assigning forms to representatives\nCREATE TABLE public.form_assignments (\n  id UUID NOT NULL DEFAULT gen_random_uuid() PRIMARY KEY,\n  workflow_form_id UUID NOT NULL REFERENCES public.workflow_forms(id) ON DELETE CASCADE,\n  organization_id UUID NOT NULL,\n  representative_id UUID NOT NULL, -- user_roles.id\n  assigned_by UUID,\n  due_date TIMESTAMP WITH TIME ZONE,\n  reminder_frequency TEXT DEFAULT 'daily', -- daily, weekly, monthly\n  is_active BOOLEAN NOT NULL DEFAULT true,\n  created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(),\n  updated_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now()\n)","-- Create form submissions table for tracking completed forms\nCREATE TABLE public.form_submissions (\n  id UUID NOT NULL DEFAULT gen_random_uuid() PRIMARY KEY,\n  form_assignment_id UUID NOT NULL REFERENCES public.form_assignments(id) ON DELETE CASCADE,\n  submitted_data JSONB NOT NULL DEFAULT '{}'::jsonb,\n  submitted_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(),\n  submitted_by UUID\n)","-- Enable RLS\nALTER TABLE public.workflow_forms ENABLE ROW LEVEL SECURITY","ALTER TABLE public.form_assignments ENABLE ROW LEVEL SECURITY","ALTER TABLE public.form_submissions ENABLE ROW LEVEL SECURITY","-- RLS Policies for workflow_forms\nCREATE POLICY \\"Super admin can manage workflow forms\\" \nON public.workflow_forms \nFOR ALL \nUSING (is_current_user_super_admin())","CREATE POLICY \\"Users can view active workflow forms\\" \nON public.workflow_forms \nFOR SELECT \nUSING (is_active = true)","-- RLS Policies for form_assignments\nCREATE POLICY \\"Admins and managers can manage form assignments\\" \nON public.form_assignments \nFOR ALL \nUSING (EXISTS (\n  SELECT 1 FROM user_roles ur \n  WHERE ur.user_id = auth.uid() \n  AND ur.organization_id = form_assignments.organization_id \n  AND ur.role IN ('admin', 'manager')\n))","CREATE POLICY \\"Representatives can view their assignments\\" \nON public.form_assignments \nFOR SELECT \nUSING (representative_id IN (\n  SELECT id FROM user_roles WHERE user_id = auth.uid()\n))","-- RLS Policies for form_submissions\nCREATE POLICY \\"Admins and managers can view submissions in their organization\\" \nON public.form_submissions \nFOR SELECT \nUSING (EXISTS (\n  SELECT 1 FROM form_assignments fa \n  JOIN user_roles ur ON ur.organization_id = fa.organization_id \n  WHERE fa.id = form_submissions.form_assignment_id \n  AND ur.user_id = auth.uid() \n  AND ur.role IN ('admin', 'manager')\n))","CREATE POLICY \\"Representatives can manage their own submissions\\" \nON public.form_submissions \nFOR ALL \nUSING (EXISTS (\n  SELECT 1 FROM form_assignments fa \n  JOIN user_roles ur ON ur.id = fa.representative_id \n  WHERE fa.id = form_submissions.form_assignment_id \n  AND ur.user_id = auth.uid()\n))","-- Create update triggers\nCREATE TRIGGER update_workflow_forms_updated_at\nBEFORE UPDATE ON public.workflow_forms\nFOR EACH ROW\nEXECUTE FUNCTION public.update_modified_column()","CREATE TRIGGER update_form_assignments_updated_at\nBEFORE UPDATE ON public.form_assignments\nFOR EACH ROW\nEXECUTE FUNCTION public.update_modified_column()"}	06ff42f6-c76b-4f38-8ac8-287d1314fcb3
20250720003358	{"-- Create storage bucket for form logos\nINSERT INTO storage.buckets (id, name, public) VALUES ('form-logos', 'form-logos', true)","-- Create storage policies for form logos\nCREATE POLICY \\"Anyone can view form logos\\"\nON storage.objects FOR SELECT\nUSING (bucket_id = 'form-logos')","CREATE POLICY \\"Authenticated users can upload form logos\\"\nON storage.objects FOR INSERT\nWITH CHECK (bucket_id = 'form-logos' AND auth.role() = 'authenticated')","CREATE POLICY \\"Users can update their form logos\\"\nON storage.objects FOR UPDATE\nUSING (bucket_id = 'form-logos' AND auth.role() = 'authenticated')","CREATE POLICY \\"Users can delete their form logos\\"\nON storage.objects FOR DELETE\nUSING (bucket_id = 'form-logos' AND auth.role() = 'authenticated')","-- Add logo_url column to workflow_forms table\nALTER TABLE workflow_forms ADD COLUMN logo_url TEXT"}	30fafdc7-842b-4787-a04e-bccb268aa7f6
20250720020846	{"-- Create alert_template_industries table to link alert templates with industries\nCREATE TABLE public.alert_template_industries (\n  id UUID NOT NULL DEFAULT gen_random_uuid() PRIMARY KEY,\n  alert_template_id UUID NOT NULL REFERENCES public.alert_templates(id) ON DELETE CASCADE,\n  industry_id UUID NOT NULL REFERENCES public.industries(id) ON DELETE CASCADE,\n  created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(),\n  UNIQUE(alert_template_id, industry_id)\n)","-- Enable RLS\nALTER TABLE public.alert_template_industries ENABLE ROW LEVEL SECURITY","-- Create policies\nCREATE POLICY \\"Super admin can manage alert template industries\\" \nON public.alert_template_industries \nFOR ALL \nUSING (is_current_user_super_admin())","CREATE POLICY \\"Users can view alert template industries in their organization\\" \nON public.alert_template_industries \nFOR SELECT \nUSING (EXISTS (\n  SELECT 1 FROM user_roles ur\n  JOIN organizations o ON o.id = ur.organization_id\n  WHERE ur.user_id = auth.uid() \n  AND o.industry_id = alert_template_industries.industry_id\n))","-- Update RLS policy for alert_templates to show only templates linked to user's industry or all for super admin\nDROP POLICY IF EXISTS \\"Users can view alert templates\\" ON public.alert_templates","CREATE POLICY \\"Users can view alert templates for their industry\\" \nON public.alert_templates \nFOR SELECT \nUSING (\n  is_current_user_super_admin() OR \n  EXISTS (\n    SELECT 1 FROM alert_template_industries ati\n    JOIN user_roles ur ON ur.user_id = auth.uid()\n    JOIN organizations o ON o.id = ur.organization_id\n    WHERE ati.alert_template_id = alert_templates.id\n    AND ati.industry_id = o.industry_id\n  )\n)"}	549758eb-52c1-483f-8569-d9e2ab12d633
20250720033934	{"-- Make model-files bucket public so Edge Functions can access files\nUPDATE storage.buckets \nSET public = true \nWHERE id = 'model-files'"}	782ede5e-d51a-4b3d-8e5c-51d6b817973d
20250720084425	{"-- Insert system setting for subscription plans visibility (local-friendly)\nINSERT INTO public.system_settings (setting_key, setting_value, description)\nVALUES (\n  'show_subscription_plans',\n  '{\\"enabled\\": true}'::jsonb,\n  'Control visibility of subscription plans on landing page'\n) ON CONFLICT (setting_key) DO UPDATE SET\n  setting_value = EXCLUDED.setting_value,\n  description = EXCLUDED.description,\n  updated_at = now()"}	24201e12-84ff-490b-b32d-2c76f4eb0708
20250720084443	{"-- Insert system setting for subscription plans visibility  \nINSERT INTO public.system_settings (setting_key, setting_value, description)\nVALUES (\n  'show_subscription_plans',\n  '{\\"enabled\\": true}'::jsonb,\n  'Control visibility of subscription plans on landing page'\n) ON CONFLICT (setting_key) DO UPDATE SET \n  setting_value = EXCLUDED.setting_value,\n  description = EXCLUDED.description,\n  updated_at = now()"}	4147a0ef-0bf2-4a2f-a281-6aa02f082d60
20250720085027	{"-- Create policy to allow super admin to manage system settings\nCREATE POLICY \\"Super admins can manage system settings\\" \nON public.system_settings\nFOR ALL\nTO authenticated\nUSING (\n  EXISTS (\n    SELECT 1 FROM auth.users \n    WHERE auth.users.id = auth.uid() \n    AND auth.users.email = 'ashraffarid@gmail.com'\n  )\n)"}	dbd51024-fd61-49cc-b499-90e5300183dc
20250720085258	{"-- Drop all existing policies on system_settings first\nDROP POLICY IF EXISTS \\"Super admin can manage system settings\\" ON public.system_settings","DROP POLICY IF EXISTS \\"Super admins can manage system settings\\" ON public.system_settings","-- Create a new policy using the existing is_current_user_super_admin function\nCREATE POLICY \\"super_admin_system_settings_policy\\" \nON public.system_settings\nFOR ALL\nTO authenticated\nUSING (is_current_user_super_admin())"}	75e0b24a-5029-4dbb-b387-38cba884156b
20250720085757	{"-- Insert default system setting for subscription plans visibility (disabled by default)\nINSERT INTO public.system_settings (setting_key, setting_value, description)\nVALUES (\n  'show_subscription_plans',\n  '{\\"enabled\\": false}',\n  'Control visibility of subscription plans on landing page'\n)\nON CONFLICT (setting_key) DO UPDATE SET\n  setting_value = '{\\"enabled\\": false}',\n  description = 'Control visibility of subscription plans on landing page'"}	406fa8af-aca1-4885-ad77-b435d2a84bee
20250731231610	{"-- إنشاء جدول بنك معلومات الشات بوت\nCREATE TABLE public.chatbot_knowledge_base (\n  id UUID NOT NULL DEFAULT gen_random_uuid() PRIMARY KEY,\n  language TEXT NOT NULL CHECK (language IN ('ar', 'en')),\n  content_type TEXT NOT NULL CHECK (content_type IN ('company', 'services', 'sectors', 'integrations', 'features', 'stats', 'contact')),\n  title TEXT,\n  data JSONB NOT NULL DEFAULT '{}',\n  is_active BOOLEAN NOT NULL DEFAULT true,\n  display_order INTEGER DEFAULT 0,\n  created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(),\n  updated_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(),\n  created_by UUID,\n  updated_by UUID,\n  UNIQUE(language, content_type)\n)","-- تفعيل Row Level Security\nALTER TABLE public.chatbot_knowledge_base ENABLE ROW LEVEL SECURITY","-- السياسات للمدير الأعلى\nCREATE POLICY \\"Super admin can manage knowledge base\\"\nON public.chatbot_knowledge_base\nFOR ALL\nUSING (is_current_user_super_admin())","-- السياسات للعرض العام (للشات بوت)\nCREATE POLICY \\"Anyone can view active knowledge base\\"\nON public.chatbot_knowledge_base\nFOR SELECT\nUSING (is_active = true)","-- إنشاء trigger للتحديث التلقائي لـ updated_at\nCREATE TRIGGER update_chatbot_knowledge_base_updated_at\n  BEFORE UPDATE ON public.chatbot_knowledge_base\n  FOR EACH ROW\n  EXECUTE FUNCTION public.update_modified_column()","-- إدراج البيانات الحالية للنسخة العربية\nINSERT INTO public.chatbot_knowledge_base (language, content_type, title, data) VALUES \n-- معلومات الشركة\n('ar', 'company', 'معلومات الشركة', '{\n  \\"name\\": \\"Beyond Senses\\",\n  \\"description\\": \\"شركة متخصصة في تقنيات الذكاء الاصطناعي والحلول الذكية الرائدة في المملكة العربية السعودية\\",\n  \\"slogan\\": \\"صُنع في المملكة العربية السعودية\\",\n  \\"ceo\\": \\"م. فهد العواضي\\",\n  \\"ceo_title\\": \\"المدير التنفيذي\\",\n  \\"cto\\": \\"م. أشرف فريد\\",\n  \\"cto_title\\": \\"رئيس التطوير التقني\\",\n  \\"location\\": \\"الرياض، المملكة العربية السعودية\\",\n  \\"coordinates\\": \\"24.7106° شمال، 46.6941° شرق\\",\n  \\"address\\": \\"طريق الملك فهد، الرياض، المملكة العربية السعودية\\",\n  \\"mapLink\\": \\"https://maps.app.goo.gl/gbEdeXjvV7pHVgn46\\"\n}'),\n\n-- الخدمات\n('ar', 'services', 'خدماتنا', '{\n  \\"services\\": [\n    {\n      \\"title\\": \\"المساعد الذكي\\",\n      \\"subtitle\\": \\"BEYONDSENSES AGENT\\",\n      \\"description\\": \\"يقودك نحو المستقبل\\",\n      \\"fullDescription\\": \\"مساعد ذكي متطور يستخدم أحدث تقنيات الذكاء الاصطناعي لفهم احتياجاتك وتقديم حلول مخصصة\\",\n      \\"features\\": [\\"ذكاء اصطناعي متقدم\\", \\"حلول مخصصة\\", \\"فهم الاحتياجات\\", \\"تقنيات حديثة\\"]\n    },\n    {\n      \\"title\\": \\"الذكاء الاصطناعي والتعلم الآلي\\",\n      \\"subtitle\\": \\"AI LAB\\",\n      \\"description\\": \\"أنظمة ذكية\\",\n      \\"fullDescription\\": \\"حلول مصممة خصيصاً لتلبية احتياجات عملك الفريدة باستخدام خوارزميات التعلم العميق\\",\n      \\"features\\": [\\"خوارزميات متقدمة\\", \\"تعلم عميق\\", \\"حلول مخصصة\\", \\"أنظمة ذكية\\"]\n    },\n    {\n      \\"title\\": \\"نظام المبنى الذكي\\",\n      \\"subtitle\\": \\"BEYONDSENSES BUILDING\\",\n      \\"description\\": \\"إدارة وتحكم متطور\\",\n      \\"fullDescription\\": \\"نظام إدارة المباني الذكي الذي يتحكم في الإضاءة والتكييف والأمان والمراقبة بطريقة تلقائية، مما يوفر الطاقة ويحسن الراحة والأمان للمستخدمين\\",\n      \\"features\\": [\\"إدارة الإضاءة\\", \\"التحكم في التكييف\\", \\"الأمان المتقدم\\", \\"توفير الطاقة\\"]\n    },\n    {\n      \\"title\\": \\"كشف السرقة بالذكاء الاصطناعي\\",\n      \\"description\\": \\"نظام متقدم للكشف عن السرقة في الوقت الفعلي باستخدام تقنيات الرؤية الحاسوبية\\",\n      \\"features\\": [\\"كشف فوري\\", \\"دقة 99%\\", \\"تنبيهات ذكية\\", \\"تسجيل الأحداث\\", \\"مراقبة 24/7\\"]\n    },\n    {\n      \\"title\\": \\"المراقبة الذكية\\",\n      \\"description\\": \\"أنظمة مراقبة متطورة مدعومة بالذكاء الاصطناعي لتحليل السلوك والكشف عن الأنماط المشبوهة\\",\n      \\"features\\": [\\"تحليل السلوك\\", \\"كشف الأنماط\\", \\"تتبع الحركة\\", \\"تحليل الحشود\\"]\n    },\n    {\n      \\"title\\": \\"تحليل البيانات الذكي\\",\n      \\"description\\": \\"تحليل متقدم للبيانات باستخدام الذكاء الاصطناعي لاستخراج رؤى قيمة\\",\n      \\"features\\": [\\"تحليل الأنماط\\", \\"تقارير تفصيلية\\", \\"توقعات ذكية\\", \\"لوحات تحكم\\"]\n    }\n  ]\n}'),\n\n-- القطاعات\n('ar', 'sectors', 'قطاعاتنا', '{\n  \\"sectors\\": [\n    {\n      \\"name\\": \\"التجارة والمتاجر\\",\n      \\"description\\": \\"حلول ذكية لمراقبة المتاجر والمراكز التجارية لضمان الأمان ومنع السرقة\\",\n      \\"applications\\": [\\"كشف السرقة الفوري\\", \\"تحليل سلوك العملاء\\", \\"مراقبة المخزون\\", \\"تقارير مفصلة\\"]\n    },\n    {\n      \\"name\\": \\"الرعاية الصحية\\",\n      \\"description\\": \\"نظم مراقبة متطورة للمستشفيات والعيادات لضمان سلامة المرضى والطاقم الطبي\\",\n      \\"applications\\": [\\"مراقبة غرف العمليات\\", \\"كشف حالات الطوارئ\\", \\"تتبع المعدات الطبية\\", \\"حماية المرضى\\"]\n    },\n    {\n      \\"name\\": \\"الضيافة والفنادق\\",\n      \\"description\\": \\"حلول أمنية شاملة للفنادق والمنتجعات لضمان راحة وأمان النزلاء\\",\n      \\"applications\\": [\\"مراقبة اللوبي والممرات\\", \\"أمان المصاعد\\", \\"حماية المسابح\\", \\"كشف الأنشطة المشبوهة\\"]\n    },\n    {\n      \\"name\\": \\"المطاعم والمقاهي\\",\n      \\"description\\": \\"نظم مراقبة ذكية للمطاعم لضمان سلامة الطعام وأمان العملاء\\",\n      \\"applications\\": [\\"مراقبة المطبخ\\", \\"كشف الحوادث\\", \\"تحليل تدفق العملاء\\", \\"ضمان النظافة\\"]\n    },\n    {\n      \\"name\\": \\"الزراعة والمزارع\\",\n      \\"description\\": \\"تقنيات مراقبة متقدمة للمزارع والمنشآت الزراعية لحماية المحاصيل والماشية\\",\n      \\"applications\\": [\\"مراقبة المحاصيل\\", \\"كشف الآفات\\", \\"تتبع الماشية\\", \\"مراقبة البيئة\\"]\n    },\n    {\n      \\"name\\": \\"المرافق الرياضية\\",\n      \\"description\\": \\"حلول أمنية للملاعب والنوادي الرياضية لضمان سلامة الرياضيين والجماهير\\",\n      \\"applications\\": [\\"مراقبة الملاعب\\", \\"كشف الشغب\\", \\"أمان المدرجات\\", \\"تحليل الحشود\\"]\n    },\n    {\n      \\"name\\": \\"المستودعات والمخازن\\",\n      \\"description\\": \\"حماية المخزون من السرقة والاختلاس مع مراقبة العمال والمعدات\\",\n      \\"applications\\": [\\"حماية المخزون\\", \\"تتبع العمال\\", \\"مراقبة المعدات\\", \\"كشف النشاط المشبوه\\"]\n    }\n  ]\n}'),\n\n-- التكاملات\n('ar', 'integrations', 'تكاملاتنا', '{\n  \\"integrations\\": [\n    \\"Hikvision\\", \\"Axis\\", \\"Dahua\\", \\"Genetec\\", \\"Milestone\\", \\"Hanwha Vision\\",\n    \\"Eagle Eye\\", \\"Digital Watchdog\\", \\"Mobotix\\", \\"NetworkOptix\\", \\"Immix\\",\n    \\"Tyco ExacqVision\\", \\"Synectics\\", \\"SureView\\", \\"Monitor Computer Systems\\",\n    \\"Trackforce\\", \\"Patriot\\", \\"SafeStar\\", \\"Raptor\\", \\"Intrado\\", \\"Alertus\\",\n    \\"Kronos\\", \\"iViSEC\\"\n  ]\n}'),\n\n-- الميزات الرئيسية\n('ar', 'features', 'ميزاتنا الرئيسية', '{\n  \\"features\\": [\n    {\n      \\"title\\": \\"كشف السرقة في الوقت الفعلي\\",\n      \\"description\\": \\"مدعوم بالذكاء الاصطناعي لحماية متجرك من السرقة والاختلاس\\"\n    },\n    {\n      \\"title\\": \\"تحليل مستمر لتدفقات الفيديو\\",\n      \\"description\\": \\"برنامجنا يحلل بشكل مستمر تدفقات الفيديو الخاصة بك\\"\n    },\n    {\n      \\"title\\": \\"تنبيهات فورية\\",\n      \\"description\\": \\"احصل على تنبيهات في الوقت الفعلي عند اكتشاف النشاط المشبوه\\"\n    }\n  ]\n}'),\n\n-- الإحصائيات\n('ar', 'stats', 'إحصائياتنا', '{\n  \\"stats\\": [\n    {\\"number\\": \\"500+\\", \\"label\\": \\"مشروع منجز\\"},\n    {\\"number\\": \\"98%\\", \\"label\\": \\"رضا العملاء\\"},\n    {\\"number\\": \\"24/7\\", \\"label\\": \\"دعم فني\\"},\n    {\\"number\\": \\"50+\\", \\"label\\": \\"عميل سعيد\\"}\n  ]\n}'),\n\n-- معلومات الاتصال\n('ar', 'contact', 'تواصل معنا', '{\n  \\"phone\\": \\"+966544877622\\",\n  \\"email\\": \\"info@beyondsenses.sa\\",\n  \\"whatsapp\\": \\"+966544877622\\",\n  \\"website\\": \\"https://beyondsenses.sa\\",\n  \\"workHours\\": \\"الأحد - الخميس: 8:00 ص - 6:00 م\\"\n}')","-- إدراج البيانات للنسخة الإنجليزية\nINSERT INTO public.chatbot_knowledge_base (language, content_type, title, data) VALUES \n-- Company Info in English\n('en', 'company', 'Company Information', '{\n  \\"name\\": \\"Beyond Senses\\",\n  \\"description\\": \\"A leading company specializing in AI technologies and smart solutions in Saudi Arabia\\",\n  \\"slogan\\": \\"Made in Saudi Arabia\\",\n  \\"ceo\\": \\"Eng. Fahd Al-Awadi\\",\n  \\"ceo_title\\": \\"Chief Executive Officer\\",\n  \\"cto\\": \\"Eng. Ashraf Farid\\",\n  \\"cto_title\\": \\"Chief Technology Officer\\",\n  \\"location\\": \\"Riyadh, Saudi Arabia\\",\n  \\"coordinates\\": \\"24.7106° N, 46.6941° E\\",\n  \\"address\\": \\"King Fahd Road, Riyadh, Saudi Arabia\\",\n  \\"mapLink\\": \\"https://maps.app.goo.gl/gbEdeXjvV7pHVgn46\\"\n}'),\n\n-- Services in English\n('en', 'services', 'Our Services', '{\n  \\"services\\": [\n    {\n      \\"title\\": \\"AI Assistant\\",\n      \\"subtitle\\": \\"BEYONDSENSES AGENT\\",\n      \\"description\\": \\"Leading you to the future\\",\n      \\"fullDescription\\": \\"Advanced AI assistant using cutting-edge artificial intelligence to understand your needs and provide customized solutions\\",\n      \\"features\\": [\\"Advanced AI\\", \\"Custom solutions\\", \\"Need understanding\\", \\"Modern technologies\\"]\n    },\n    {\n      \\"title\\": \\"AI & Machine Learning\\",\n      \\"subtitle\\": \\"AI LAB\\",\n      \\"description\\": \\"Intelligent systems\\",\n      \\"fullDescription\\": \\"Solutions specifically designed to meet your unique business needs using deep learning algorithms\\",\n      \\"features\\": [\\"Advanced algorithms\\", \\"Deep learning\\", \\"Custom solutions\\", \\"Smart systems\\"]\n    },\n    {\n      \\"title\\": \\"Smart Building System\\",\n      \\"subtitle\\": \\"BEYONDSENSES BUILDING\\",\n      \\"description\\": \\"Advanced management and control\\",\n      \\"fullDescription\\": \\"Smart building management system that automatically controls lighting, HVAC, security, and monitoring, saving energy and improving comfort and safety\\",\n      \\"features\\": [\\"Lighting management\\", \\"HVAC control\\", \\"Advanced security\\", \\"Energy saving\\"]\n    }\n  ]\n}')","-- إنشاء فهرس للبحث السريع\nCREATE INDEX idx_chatbot_knowledge_language_type ON public.chatbot_knowledge_base(language, content_type)","CREATE INDEX idx_chatbot_knowledge_active ON public.chatbot_knowledge_base(is_active)"}	6b639ef8-5c3d-4b89-917d-9b599661c3ba
20250803180454	{"-- Create groups table for organizing users\nCREATE TABLE public.user_groups (\n  id UUID PRIMARY KEY DEFAULT gen_random_uuid(),\n  name TEXT NOT NULL,\n  description TEXT,\n  organization_id UUID REFERENCES public.organizations(id) ON DELETE CASCADE,\n  group_type TEXT NOT NULL DEFAULT 'custom', -- 'custom', 'branch', 'department'\n  metadata JSONB DEFAULT '{}',\n  created_by UUID,\n  created_at TIMESTAMPTZ DEFAULT now(),\n  updated_at TIMESTAMPTZ DEFAULT now()\n)","-- Create group members junction table\nCREATE TABLE public.user_group_members (\n  id UUID PRIMARY KEY DEFAULT gen_random_uuid(),\n  group_id UUID REFERENCES public.user_groups(id) ON DELETE CASCADE,\n  user_role_id UUID REFERENCES public.user_roles(id) ON DELETE CASCADE,\n  added_by UUID,\n  added_at TIMESTAMPTZ DEFAULT now(),\n  UNIQUE(group_id, user_role_id)\n)","-- Create form distribution settings table\nCREATE TABLE public.form_distribution_settings (\n  id UUID PRIMARY KEY DEFAULT gen_random_uuid(),\n  workflow_form_id UUID REFERENCES public.workflow_forms(id) ON DELETE CASCADE,\n  distribution_type TEXT NOT NULL, -- 'users', 'groups', 'both'\n  target_groups JSONB DEFAULT '[]', -- array of group IDs\n  target_users JSONB DEFAULT '[]', -- array of user_role IDs\n  schedule_type TEXT DEFAULT 'immediate', -- 'immediate', 'scheduled', 'recurring'\n  schedule_data JSONB DEFAULT '{}',\n  notification_settings JSONB DEFAULT '{\\"email\\": true, \\"push\\": true}',\n  created_by UUID,\n  created_at TIMESTAMPTZ DEFAULT now(),\n  updated_at TIMESTAMPTZ DEFAULT now()\n)","-- Enable RLS\nALTER TABLE public.user_groups ENABLE ROW LEVEL SECURITY","ALTER TABLE public.user_group_members ENABLE ROW LEVEL SECURITY","ALTER TABLE public.form_distribution_settings ENABLE ROW LEVEL SECURITY","-- RLS Policies for user_groups\nCREATE POLICY \\"Users can view groups in their organization\\"\nON public.user_groups FOR SELECT\nUSING (EXISTS (\n  SELECT 1 FROM user_roles ur \n  WHERE ur.user_id = auth.uid() \n  AND ur.organization_id = user_groups.organization_id\n))","CREATE POLICY \\"Admins and managers can manage groups\\"\nON public.user_groups FOR ALL\nUSING (EXISTS (\n  SELECT 1 FROM user_roles ur \n  WHERE ur.user_id = auth.uid() \n  AND ur.organization_id = user_groups.organization_id \n  AND ur.role IN ('admin', 'manager')\n))","-- RLS Policies for user_group_members\nCREATE POLICY \\"Users can view group members in their organization\\"\nON public.user_group_members FOR SELECT\nUSING (EXISTS (\n  SELECT 1 FROM user_groups ug\n  JOIN user_roles ur ON ur.organization_id = ug.organization_id\n  WHERE ug.id = user_group_members.group_id\n  AND ur.user_id = auth.uid()\n))","CREATE POLICY \\"Admins and managers can manage group members\\"\nON public.user_group_members FOR ALL\nUSING (EXISTS (\n  SELECT 1 FROM user_groups ug\n  JOIN user_roles ur ON ur.organization_id = ug.organization_id\n  WHERE ug.id = user_group_members.group_id\n  AND ur.user_id = auth.uid()\n  AND ur.role IN ('admin', 'manager')\n))","-- RLS Policies for form_distribution_settings\nCREATE POLICY \\"Users can view form distribution in their organization\\"\nON public.form_distribution_settings FOR SELECT\nUSING (EXISTS (\n  SELECT 1 FROM workflow_forms wf\n  WHERE wf.id = form_distribution_settings.workflow_form_id\n))","CREATE POLICY \\"Super admin can manage form distribution\\"\nON public.form_distribution_settings FOR ALL\nUSING (is_current_user_super_admin())","-- Add triggers for updated_at\nCREATE TRIGGER update_user_groups_updated_at\n  BEFORE UPDATE ON public.user_groups\n  FOR EACH ROW\n  EXECUTE FUNCTION public.update_modified_column()","CREATE TRIGGER update_form_distribution_settings_updated_at\n  BEFORE UPDATE ON public.form_distribution_settings\n  FOR EACH ROW\n  EXECUTE FUNCTION public.update_modified_column()"}	26b954ef-5112-4cd3-bded-f74d3412c50c
20250808003935	{"-- Allow users to mark events as reviewed only within their organization and restrict updates to the reviewed flag\n\n-- Create a trigger function to restrict updates\nCREATE OR REPLACE FUNCTION public.restrict_events_update()\nRETURNS trigger\nLANGUAGE plpgsql\nSECURITY DEFINER\nSET search_path = public\nAS $$\nBEGIN\n  -- Only allow setting reviewed to true\n  IF NEW.reviewed IS DISTINCT FROM TRUE THEN\n    RAISE EXCEPTION 'Only allowed to set reviewed=true';\n  END IF;\n  -- Prevent re-reviewing\n  IF OLD.reviewed = TRUE THEN\n    RAISE EXCEPTION 'Event already reviewed';\n  END IF;\n  -- Prevent modifications to other columns\n  IF NEW.id <> OLD.id OR\n     NEW.camera_id IS DISTINCT FROM OLD.camera_id OR\n     NEW.metadata IS DISTINCT FROM OLD.metadata OR\n     NEW.detected_at IS DISTINCT FROM OLD.detected_at OR\n     NEW.severity IS DISTINCT FROM OLD.severity OR\n     NEW.snapshot_url IS DISTINCT FROM OLD.snapshot_url OR\n     NEW.event_type IS DISTINCT FROM OLD.event_type THEN\n     RAISE EXCEPTION 'Only the reviewed field may be updated';\n  END IF;\n\n  RETURN NEW;\nEND;\n$$","-- Create or replace the trigger on events\nDROP TRIGGER IF EXISTS trg_restrict_events_update ON public.events","CREATE TRIGGER trg_restrict_events_update\nBEFORE UPDATE ON public.events\nFOR EACH ROW\nEXECUTE FUNCTION public.restrict_events_update()","-- RLS policy to allow users to set reviewed=true for events in their organization\nDROP POLICY IF EXISTS \\"Users can update event reviewed\\" ON public.events","CREATE POLICY \\"Users can update event reviewed\\"\nON public.events\nFOR UPDATE\nUSING (\n  EXISTS (\n    SELECT 1\n    FROM public.cameras c\n    JOIN public.branches b ON c.branch_id = b.id\n    JOIN public.user_roles ur ON ur.organization_id = b.organization_id\n    WHERE c.id = public.events.camera_id AND ur.user_id = auth.uid()\n  )\n)\nWITH CHECK (\n  reviewed = true\n)"}	2d0a5943-e976-4b65-b10e-f5b6470f1b81
20250808234405	{"-- Create Aman (Home Assistant) instances table for per-customer/branch SaaS integration\nCREATE TABLE IF NOT EXISTS public.aman_instances (\n  id uuid PRIMARY KEY DEFAULT gen_random_uuid(),\n  organization_id uuid NOT NULL,\n  branch_id uuid NULL,\n  name text NOT NULL,\n  base_url text NOT NULL,\n  access_token text NOT NULL,\n  active boolean NOT NULL DEFAULT true,\n  created_by uuid NULL,\n  created_at timestamptz NOT NULL DEFAULT now(),\n  updated_at timestamptz NOT NULL DEFAULT now()\n)","-- Enable Row Level Security\nALTER TABLE public.aman_instances ENABLE ROW LEVEL SECURITY","-- Trigger to keep updated_at in sync\nDO $$ BEGIN\n  IF NOT EXISTS (\n    SELECT 1 FROM pg_trigger WHERE tgname = 'update_aman_instances_updated_at'\n  ) THEN\n    CREATE TRIGGER update_aman_instances_updated_at\n    BEFORE UPDATE ON public.aman_instances\n    FOR EACH ROW EXECUTE FUNCTION public.update_modified_column();\n  END IF;\nEND $$","-- Policies: Admins & Managers of the organization can manage; all org users can view\nDROP POLICY IF EXISTS \\"Admins and managers can manage Aman instances\\" ON public.aman_instances","CREATE POLICY \\"Admins and managers can manage Aman instances\\"\nON public.aman_instances\nFOR ALL\nUSING (\n  EXISTS (\n    SELECT 1 FROM public.user_roles ur\n    WHERE ur.user_id = auth.uid()\n      AND ur.organization_id = aman_instances.organization_id\n      AND ur.role IN ('admin','manager')\n  )\n)\nWITH CHECK (\n  EXISTS (\n    SELECT 1 FROM public.user_roles ur\n    WHERE ur.user_id = auth.uid()\n      AND ur.organization_id = aman_instances.organization_id\n      AND ur.role IN ('admin','manager')\n  )\n)","DROP POLICY IF EXISTS \\"Users can view Aman instances in their organization\\" ON public.aman_instances","CREATE POLICY \\"Users can view Aman instances in their organization\\"\nON public.aman_instances\nFOR SELECT\nUSING (\n  EXISTS (\n    SELECT 1 FROM public.user_roles ur\n    WHERE ur.user_id = auth.uid()\n      AND ur.organization_id = aman_instances.organization_id\n  )\n)","-- Restrict column-level access so tokens are never exposed to clients\nREVOKE ALL ON TABLE public.aman_instances FROM anon, authenticated","GRANT INSERT, UPDATE, DELETE ON TABLE public.aman_instances TO authenticated","GRANT SELECT (id, organization_id, branch_id, name, base_url, active, created_by, created_at, updated_at)\n  ON public.aman_instances TO authenticated","-- Helpful indexes\nCREATE INDEX IF NOT EXISTS idx_aman_instances_org ON public.aman_instances(organization_id)","CREATE INDEX IF NOT EXISTS idx_aman_instances_branch ON public.aman_instances(branch_id)"}	6a6e4c48-c0ac-4b43-aef3-839490eab8a6
20250809015223	{"-- Add auth and dashboard path columns to aman_instances\nALTER TABLE public.aman_instances\n  ADD COLUMN IF NOT EXISTS username text,\n  ADD COLUMN IF NOT EXISTS password text,\n  ADD COLUMN IF NOT EXISTS dashboard_path text DEFAULT '/lovelace/default_view?kiosk'","-- Optional: index for lookups by organization/branch remains unchanged\n-- Note: RLS policies already exist and will continue to apply"}	2d3dde33-12ef-4bad-80b5-3b7f307ef341
20250809021800	{"-- 1) Ensure 'representative' value exists in user_role enum\nDO $$\nBEGIN\n  IF NOT EXISTS (\n    SELECT 1\n    FROM pg_type t\n    JOIN pg_enum e ON t.oid = e.enumtypid\n    WHERE t.typname = 'user_role' AND e.enumlabel = 'representative'\n  ) THEN\n    ALTER TYPE public.user_role ADD VALUE 'representative';\n  END IF;\nEND $$","-- 2) Create screen_permissions table for page-level access control\nCREATE TABLE IF NOT EXISTS public.screen_permissions (\n  id uuid PRIMARY KEY DEFAULT gen_random_uuid(),\n  screen_key text NOT NULL UNIQUE,       -- stable key e.g. \\"dashboard\\", \\"alerts\\", \\"organization-users\\"\n  path text NOT NULL,                    -- route path e.g. \\"/dashboard\\"\n  title_en text,\n  title_ar text,\n  description_en text,\n  description_ar text,\n  allowed_roles text[] NOT NULL DEFAULT '{}'::text[],\n  allow_super_admin boolean NOT NULL DEFAULT true,\n  is_active boolean NOT NULL DEFAULT true,\n  created_by uuid,\n  created_at timestamptz NOT NULL DEFAULT now(),\n  updated_at timestamptz NOT NULL DEFAULT now()\n)","-- 3) Enable Row Level Security\nALTER TABLE public.screen_permissions ENABLE ROW LEVEL SECURITY","-- 4) Policies\nDROP POLICY IF EXISTS \\"Super admin can manage screen permissions\\" ON public.screen_permissions","CREATE POLICY \\"Super admin can manage screen permissions\\"\nON public.screen_permissions\nFOR ALL\nUSING (is_current_user_super_admin())\nWITH CHECK (is_current_user_super_admin())","DROP POLICY IF EXISTS \\"Authenticated users can view active screen permissions\\" ON public.screen_permissions","CREATE POLICY \\"Authenticated users can view active screen permissions\\"\nON public.screen_permissions\nFOR SELECT\nUSING (is_active = true)","-- 5) Trigger to auto-update updated_at\nDROP TRIGGER IF EXISTS handle_screen_permissions_updated_at ON public.screen_permissions","CREATE TRIGGER handle_screen_permissions_updated_at\nBEFORE UPDATE ON public.screen_permissions\nFOR EACH ROW\nEXECUTE FUNCTION public.update_modified_column()"}	8602492f-1d66-4fa5-85cc-c8a2d75d9f30
20250809021851	{"-- Enable RLS on aman_instances table\nALTER TABLE public.aman_instances ENABLE ROW LEVEL SECURITY","-- Drop existing policies to avoid conflicts\nDO $$\nDECLARE r record;\nBEGIN\n  FOR r IN SELECT policyname FROM pg_policies WHERE tablename='aman_instances' AND schemaname='public' LOOP\n    EXECUTE format('DROP POLICY %I ON public.aman_instances', r.policyname);\n  END LOOP;\nEND $$","-- Create policies for aman_instances\nCREATE POLICY \\"aman_view_super_admin\\" ON public.aman_instances FOR SELECT TO authenticated\nUSING (EXISTS (SELECT 1 FROM public.user_roles WHERE user_id = auth.uid() AND role = 'super_admin'))","CREATE POLICY \\"aman_view_org_admin\\" ON public.aman_instances FOR SELECT TO authenticated\nUSING (organization_id IN (SELECT organization_id FROM public.user_roles WHERE user_id = auth.uid() AND role IN ('admin', 'manager')))","CREATE POLICY \\"aman_view_rep\\" ON public.aman_instances FOR SELECT TO authenticated\nUSING (branch_id IN (SELECT branch_id FROM public.user_roles WHERE user_id = auth.uid() AND role = 'representative'))","CREATE POLICY \\"aman_insert_super\\" ON public.aman_instances FOR INSERT TO authenticated\nWITH CHECK (EXISTS (SELECT 1 FROM public.user_roles WHERE user_id = auth.uid() AND role = 'super_admin'))","CREATE POLICY \\"aman_insert_org\\" ON public.aman_instances FOR INSERT TO authenticated\nWITH CHECK (organization_id IN (SELECT organization_id FROM public.user_roles WHERE user_id = auth.uid() AND role IN ('admin', 'manager')))","CREATE POLICY \\"aman_update_super\\" ON public.aman_instances FOR UPDATE TO authenticated\nUSING (EXISTS (SELECT 1 FROM public.user_roles WHERE user_id = auth.uid() AND role = 'super_admin'))","CREATE POLICY \\"aman_update_org\\" ON public.aman_instances FOR UPDATE TO authenticated\nUSING (organization_id IN (SELECT organization_id FROM public.user_roles WHERE user_id = auth.uid() AND role IN ('admin', 'manager')))","CREATE POLICY \\"aman_delete_super\\" ON public.aman_instances FOR DELETE TO authenticated\nUSING (EXISTS (SELECT 1 FROM public.user_roles WHERE user_id = auth.uid() AND role = 'super_admin'))","CREATE POLICY \\"aman_delete_org\\" ON public.aman_instances FOR DELETE TO authenticated\nUSING (organization_id IN (SELECT organization_id FROM public.user_roles WHERE user_id = auth.uid() AND role IN ('admin', 'manager')))"}	3f7d00cf-ae7b-4ad1-aa6e-9451bdfb3382
20250809021908	{"-- Fix RLS policies for aman_instances table to ensure proper access\n\n-- Drop existing policies\nDROP POLICY IF EXISTS \\"Admins and managers can manage Aman instances\\" ON aman_instances","DROP POLICY IF EXISTS \\"Users can view Aman instances in their organization\\" ON aman_instances","-- Create new policies with better organization access\nCREATE POLICY \\"Users can view Aman instances in their organization\\" \nON aman_instances \nFOR SELECT \nUSING (\n  EXISTS (\n    SELECT 1 FROM user_roles ur \n    WHERE ur.user_id = auth.uid() \n    AND ur.organization_id = aman_instances.organization_id\n  )\n)","CREATE POLICY \\"Admins and managers can manage Aman instances\\" \nON aman_instances \nFOR ALL \nUSING (\n  EXISTS (\n    SELECT 1 FROM user_roles ur \n    WHERE ur.user_id = auth.uid() \n    AND ur.organization_id = aman_instances.organization_id \n    AND ur.role = ANY(ARRAY['admin'::user_role, 'manager'::user_role])\n  )\n)\nWITH CHECK (\n  EXISTS (\n    SELECT 1 FROM user_roles ur \n    WHERE ur.user_id = auth.uid() \n    AND ur.organization_id = aman_instances.organization_id \n    AND ur.role = ANY(ARRAY['admin'::user_role, 'manager'::user_role])\n  )\n)","-- Also allow super admin access\nCREATE POLICY \\"Super admin can manage all Aman instances\\" \nON aman_instances \nFOR ALL \nUSING (is_current_user_super_admin())\nWITH CHECK (is_current_user_super_admin())"}	ab566ff6-aafe-47fc-83bb-01952fd3323b
20250809021933	{"-- Fix the RLS disabled errors by enabling RLS on the tables that need it\n\n-- Enable RLS on tables that have policies but RLS is disabled\nALTER TABLE public.alert_template_industries ENABLE ROW LEVEL SECURITY","ALTER TABLE public.industries ENABLE ROW LEVEL SECURITY"}	624d0315-d824-4fb8-88db-26a72b592742
20250809021951	{"-- Enable RLS on remaining tables that don't have it enabled\nALTER TABLE public.cameras ENABLE ROW LEVEL SECURITY","ALTER TABLE public.organizations ENABLE ROW LEVEL SECURITY"}	9c19f303-4918-4290-a876-763c18e65ad2
20250809022128	{"-- Enable real-time updates for aman_instances table\nALTER TABLE public.aman_instances REPLICA IDENTITY FULL","ALTER PUBLICATION supabase_realtime ADD TABLE public.aman_instances"}	cf1d7a1b-f2ed-40f7-8299-ff18ddfe3b4b
20250809022417	{"-- Ensure RLS is enabled and privileges are granted for aman_instances access\nALTER TABLE public.aman_instances ENABLE ROW LEVEL SECURITY","-- Grant CRUD privileges to authenticated users (RLS will still enforce row access)\nGRANT SELECT, INSERT, UPDATE, DELETE ON TABLE public.aman_instances TO authenticated","-- Ensure policies that reference user_roles can read the necessary rows\nGRANT SELECT ON TABLE public.user_roles TO authenticated"}	1d470035-a491-4cd8-8b67-56e0710b735b
20250809032618	{"-- Update Home Assistant access token for the test device instance\nUPDATE public.aman_instances\nSET access_token = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJlOWJhNWY4NzQ5MTI0N2EzYWI2NzIzZjg4Mjg5MmYxOCIsImlhdCI6MTc1NDcwOTg3NiwiZXhwIjoyMDcwMDY5ODc2fQ.01L7zA3lctgOj3BbBwpfwyVKmavVvm2eXRzSpfPkGfU',\n    updated_at = now()\nWHERE id = '67d3435a-3ac9-4e10-a5bc-d7777b492ba5'"}	0f5b3402-ff78-4f77-8c30-b6958d09f684
20250809045741	{"-- Skipped: requires pg_cron and pg_net extensions (not enabled in local dev)\n-- The original migration scheduled sync-frigate to run every minute via pg_cron"}	edec9d7d-886f-4003-9ca1-1ad94478726b
20250809051310	{"-- Add Aman API URL to aman_instances for Frigate proxy base\nALTER TABLE public.aman_instances\nADD COLUMN IF NOT EXISTS aman_api_url text"}	a9ec4fbe-2d88-4173-baa5-98961dc2c25a
20250809051952	{"-- Set search_path on functions (idempotent)\nDO $$ BEGIN\n  PERFORM 1;  -- placeholder, will be set per function below\nEND $$","-- Use the standard approach with explicit empty search_path\nALTER FUNCTION public.update_modified_column() SET search_path TO public","ALTER FUNCTION public.update_subscriber_activity() SET search_path TO public","ALTER FUNCTION public.handle_new_user() SET search_path TO public","ALTER FUNCTION public.is_super_admin(text) SET search_path TO public","ALTER FUNCTION public.is_current_user_super_admin() SET search_path TO public","ALTER FUNCTION public.get_user_role(uuid) SET search_path TO public"}	1ea34abd-ef8b-43ea-a8f5-483227d2dae0
20250809052802	{"-- Fix linter warning: set explicit search_path for functions\nALTER FUNCTION public.update_modified_column() SET search_path TO ''","ALTER FUNCTION public.update_subscriber_activity() SET search_path TO ''","ALTER FUNCTION public.update_modified_column() SET search_path TO ''","ALTER FUNCTION public.handle_new_user() SET search_path TO ''","ALTER FUNCTION public.is_super_admin(text) SET search_path TO ''","ALTER FUNCTION public.is_current_user_super_admin() SET search_path TO ''","ALTER FUNCTION public.get_user_role(uuid) SET search_path TO ''","ALTER FUNCTION public.restrict_events_update() SET search_path TO public"}	750fb5b5-eeaf-44d7-920e-3725da7644b4
20250809153117	{"-- Create pinned_dashboards table to store user-specific pinned dashboard layouts\nCREATE TABLE IF NOT EXISTS public.pinned_dashboards (\n  id UUID PRIMARY KEY DEFAULT gen_random_uuid(),\n  user_id UUID NOT NULL,\n  instance_id UUID NOT NULL,\n  name TEXT,\n  path TEXT NOT NULL DEFAULT '/lovelace/default_view?kiosk',\n  x INTEGER NOT NULL DEFAULT 0,\n  y INTEGER NOT NULL DEFAULT 0,\n  width INTEGER NOT NULL DEFAULT 600,\n  height INTEGER NOT NULL DEFAULT 400,\n  order_index INTEGER NOT NULL DEFAULT 0,\n  created_at TIMESTAMPTZ NOT NULL DEFAULT now(),\n  updated_at TIMESTAMPTZ NOT NULL DEFAULT now()\n)","-- Enable Row Level Security\nALTER TABLE public.pinned_dashboards ENABLE ROW LEVEL SECURITY","-- RLS Policies: users can manage only their own rows\nCREATE POLICY \\"Users can view their pinned dashboards\\"\n  ON public.pinned_dashboards\n  FOR SELECT\n  USING (auth.uid() = user_id)","CREATE POLICY \\"Users can insert their pinned dashboards\\"\n  ON public.pinned_dashboards\n  FOR INSERT\n  WITH CHECK (auth.uid() = user_id)","CREATE POLICY \\"Users can update their pinned dashboards\\"\n  ON public.pinned_dashboards\n  FOR UPDATE\n  USING (auth.uid() = user_id)","CREATE POLICY \\"Users can delete their pinned dashboards\\"\n  ON public.pinned_dashboards\n  FOR DELETE\n  USING (auth.uid() = user_id)","-- Updated-at trigger\nDO $$ BEGIN\n  IF NOT EXISTS (\n    SELECT 1 FROM pg_trigger WHERE tgname = 'update_pinned_dashboards_updated_at'\n  ) THEN\n    CREATE TRIGGER update_pinned_dashboards_updated_at\n    BEFORE UPDATE ON public.pinned_dashboards\n    FOR EACH ROW\n    EXECUTE FUNCTION public.update_modified_column();\n  END IF;\nEND $$","-- Helpful index\nCREATE INDEX IF NOT EXISTS idx_pinned_dashboards_user_id ON public.pinned_dashboards(user_id)"}	483ec14c-25ef-42c5-9e7b-60b48d5b4dae
20250809161414	{"-- 1) Add zoom to pinned_dashboards\nALTER TABLE public.pinned_dashboards\nADD COLUMN IF NOT EXISTS zoom NUMERIC NOT NULL DEFAULT 1.0","-- 2) Create labels table for canvas annotations\nCREATE TABLE IF NOT EXISTS public.pinned_labels (\n  id UUID PRIMARY KEY DEFAULT gen_random_uuid(),\n  user_id UUID NOT NULL,\n  text TEXT NOT NULL DEFAULT 'Label',\n  color TEXT NOT NULL DEFAULT '#111827',\n  font_size INTEGER NOT NULL DEFAULT 16,\n  x INTEGER NOT NULL DEFAULT 40,\n  y INTEGER NOT NULL DEFAULT 40,\n  created_at TIMESTAMPTZ NOT NULL DEFAULT now(),\n  updated_at TIMESTAMPTZ NOT NULL DEFAULT now()\n)","-- Enable RLS\nALTER TABLE public.pinned_labels ENABLE ROW LEVEL SECURITY","-- Drop existing policies\nDO $$\nDECLARE r record;\nBEGIN\n  FOR r IN SELECT policyname FROM pg_policies WHERE tablename='pinned_labels' AND schemaname='public' LOOP\n    EXECUTE format('DROP POLICY %I ON public.pinned_labels', r.policyname);\n  END LOOP;\nEND $$","-- Create policies\nCREATE POLICY \\"Labels: users can view their own\\"\nON public.pinned_labels FOR SELECT\nUSING (auth.uid() = user_id)","CREATE POLICY \\"Labels: users can insert their own\\"\nON public.pinned_labels FOR INSERT\nWITH CHECK (auth.uid() = user_id)","CREATE POLICY \\"Labels: users can update their own\\"\nON public.pinned_labels FOR UPDATE\nUSING (auth.uid() = user_id)","CREATE POLICY \\"Labels: users can delete their own\\"\nON public.pinned_labels FOR DELETE\nUSING (auth.uid() = user_id)","-- Trigger to keep updated_at fresh (uses existing update_modified_column function)\nDROP TRIGGER IF EXISTS trg_pinned_labels_updated_at ON public.pinned_labels","CREATE TRIGGER trg_pinned_labels_updated_at\nBEFORE UPDATE ON public.pinned_labels\nFOR EACH ROW EXECUTE FUNCTION public.update_modified_column()","-- Helpful index for user_id lookup\nCREATE INDEX IF NOT EXISTS idx_pinned_labels_user_id ON public.pinned_labels(user_id)"}	ac21667f-6a15-46a8-90f7-fa4394541e39
20250809161720	{"-- 1) Add zoom to pinned_dashboards\nALTER TABLE public.pinned_dashboards\nADD COLUMN IF NOT EXISTS zoom NUMERIC NOT NULL DEFAULT 1.0","-- 2) Create labels table for canvas annotations\nCREATE TABLE IF NOT EXISTS public.pinned_labels (\n  id UUID PRIMARY KEY DEFAULT gen_random_uuid(),\n  user_id UUID NOT NULL,\n  text TEXT NOT NULL DEFAULT 'Label',\n  color TEXT NOT NULL DEFAULT '#111827', -- neutral-900\n  font_size INTEGER NOT NULL DEFAULT 16,\n  x INTEGER NOT NULL DEFAULT 40,\n  y INTEGER NOT NULL DEFAULT 40,\n  created_at TIMESTAMPTZ NOT NULL DEFAULT now(),\n  updated_at TIMESTAMPTZ NOT NULL DEFAULT now()\n)","-- Enable RLS (idempotent)\nALTER TABLE public.pinned_labels ENABLE ROW LEVEL SECURITY","-- Policies: only owner can access their labels (idempotent via DO blocks)\nDO $$ BEGIN\n  IF NOT EXISTS (\n    SELECT 1 FROM pg_policies \n    WHERE schemaname = 'public' AND tablename = 'pinned_labels' AND policyname = 'Labels: users can view their own'\n  ) THEN\n    CREATE POLICY \\"Labels: users can view their own\\"\n    ON public.pinned_labels FOR SELECT\n    USING (auth.uid() = user_id);\n  END IF;\nEND $$","DO $$ BEGIN\n  IF NOT EXISTS (\n    SELECT 1 FROM pg_policies \n    WHERE schemaname = 'public' AND tablename = 'pinned_labels' AND policyname = 'Labels: users can insert their own'\n  ) THEN\n    CREATE POLICY \\"Labels: users can insert their own\\"\n    ON public.pinned_labels FOR INSERT\n    WITH CHECK (auth.uid() = user_id);\n  END IF;\nEND $$","DO $$ BEGIN\n  IF NOT EXISTS (\n    SELECT 1 FROM pg_policies \n    WHERE schemaname = 'public' AND tablename = 'pinned_labels' AND policyname = 'Labels: users can update their own'\n  ) THEN\n    CREATE POLICY \\"Labels: users can update their own\\"\n    ON public.pinned_labels FOR UPDATE\n    USING (auth.uid() = user_id);\n  END IF;\nEND $$","DO $$ BEGIN\n  IF NOT EXISTS (\n    SELECT 1 FROM pg_policies \n    WHERE schemaname = 'public' AND tablename = 'pinned_labels' AND policyname = 'Labels: users can delete their own'\n  ) THEN\n    CREATE POLICY \\"Labels: users can delete their own\\"\n    ON public.pinned_labels FOR DELETE\n    USING (auth.uid() = user_id);\n  END IF;\nEND $$","-- Trigger to keep updated_at fresh\nCREATE OR REPLACE FUNCTION public.update_modified_column()\nRETURNS TRIGGER AS $$\nBEGIN\n  NEW.updated_at = now();\n  RETURN NEW;\nEND; $$ LANGUAGE plpgsql","DROP TRIGGER IF EXISTS trg_pinned_labels_updated_at ON public.pinned_labels","CREATE TRIGGER trg_pinned_labels_updated_at\nBEFORE UPDATE ON public.pinned_labels\nFOR EACH ROW EXECUTE FUNCTION public.update_modified_column()","-- Helpful index for user_id lookup\nCREATE INDEX IF NOT EXISTS idx_pinned_labels_user_id ON public.pinned_labels(user_id)"}	92a094ea-9f6d-465d-9b2f-65145cf748db
20250809175738	{"-- Edited to remove CREATE POLICY (not valid syntax)\n-- Create a branch-level roles table to support branch manager visibility\nCREATE TABLE IF NOT EXISTS public.branch_roles (\n  id UUID PRIMARY KEY DEFAULT gen_random_uuid(),\n  user_id UUID NOT NULL REFERENCES auth.users(id) ON DELETE CASCADE,\n  branch_id UUID NOT NULL REFERENCES public.branches(id) ON DELETE CASCADE,\n  role TEXT NOT NULL CHECK (role IN ('branch_manager')),\n  created_at TIMESTAMPTZ NOT NULL DEFAULT now()\n)","-- Enable RLS on branch_roles\nALTER TABLE public.branch_roles ENABLE ROW LEVEL SECURITY","-- Allow users to view their own branch roles\nCREATE POLICY \\"Users can view their own branch roles\\"\nON public.branch_roles\nFOR SELECT\nUSING (user_id = auth.uid())","-- Allow super admin to manage branch roles\nCREATE POLICY \\"Super admin can manage branch roles\\"\nON public.branch_roles\nFOR ALL\nUSING (is_current_user_super_admin())\nWITH CHECK (is_current_user_super_admin())","-- Expand visibility for pinned_dashboards based on roles\n-- Super admin can view all pinned dashboards\nCREATE POLICY \\"Super admin can view all pinned dashboards\\"\nON public.pinned_dashboards\nFOR SELECT\nUSING (is_current_user_super_admin())","-- Org admins and managers can view all pinned dashboards in their organization\nCREATE POLICY \\"Org admins and managers can view org pinned dashboards\\"\nON public.pinned_dashboards\nFOR SELECT\nUSING (\n  EXISTS (\n    SELECT 1\n    FROM public.aman_instances ai\n    JOIN public.user_roles ur ON ur.organization_id = ai.organization_id\n    WHERE ai.id = pinned_dashboards.instance_id\n      AND ur.user_id = auth.uid()\n      AND ur.role IN ('admin', 'manager')\n  )\n)","-- Branch managers can view pinned dashboards for their branch only\nCREATE POLICY \\"Branch managers can view branch pinned dashboards\\"\nON public.pinned_dashboards\nFOR SELECT\nUSING (\n  EXISTS (\n    SELECT 1\n    FROM public.aman_instances ai\n    JOIN public.branch_roles br ON br.branch_id = ai.branch_id\n    WHERE ai.id = pinned_dashboards.instance_id\n      AND br.user_id = auth.uid()\n      AND br.role = 'branch_manager'\n  )\n)"}	0010a016-1378-4c42-add7-ed64640b81cb
20250809175815	{"-- Idempotent version: skip if already created\nDO $$\nBEGIN\n  IF NOT EXISTS (SELECT 1 FROM information_schema.tables WHERE table_schema='public' AND table_name='branch_roles') THEN\n    -- Create a branch-level roles table to support branch manager visibility\n    CREATE TABLE public.branch_roles (\n      id UUID PRIMARY KEY DEFAULT gen_random_uuid(),\n      user_id UUID NOT NULL REFERENCES auth.users(id) ON DELETE CASCADE,\n      branch_id UUID NOT NULL REFERENCES public.branches(id) ON DELETE CASCADE,\n      role TEXT NOT NULL CHECK (role IN ('branch_manager')),\n      created_at TIMESTAMPTZ NOT NULL DEFAULT now()\n    );\n\n    -- Enable RLS on branch_roles\n    ALTER TABLE public.branch_roles ENABLE ROW LEVEL SECURITY;\n\n    -- Allow users to view their own branch roles\n    CREATE POLICY \\"Users can view their own branch roles\\" ON public.branch_roles\n    FOR SELECT USING (user_id = auth.uid());\n\n    -- Allow super admin to manage branch roles\n    CREATE POLICY \\"Super admin can manage branch roles\\" ON public.branch_roles\n    FOR ALL USING (is_current_user_super_admin()) WITH CHECK (is_current_user_super_admin());\n  END IF;\nEND $$","-- Drop pinned_dashboards policies that conflict (recreated later)\nDO $$\nDECLARE r record;\nBEGIN\n  FOR r IN SELECT policyname FROM pg_policies WHERE tablename='pinned_dashboards' AND schemaname='public' LOOP\n    EXECUTE format('DROP POLICY %I ON public.pinned_dashboards', r.policyname);\n  END LOOP;\nEND $$","-- Expand visibility for pinned_dashboards based on roles\nCREATE POLICY \\"Super admin can view all pinned dashboards\\" ON public.pinned_dashboards\nFOR SELECT USING (is_current_user_super_admin())","CREATE POLICY \\"Org admins and managers can view org pinned dashboards\\" ON public.pinned_dashboards\nFOR SELECT USING (\n  EXISTS (\n    SELECT 1\n    FROM public.aman_instances ai\n    JOIN public.user_roles ur ON ur.organization_id = ai.organization_id\n    WHERE ai.id = pinned_dashboards.instance_id\n      AND ur.user_id = auth.uid()\n      AND ur.role IN ('admin', 'manager')\n  )\n)","CREATE POLICY \\"Branch managers can view branch pinned dashboards\\" ON public.pinned_dashboards\nFOR SELECT USING (\n  EXISTS (\n    SELECT 1\n    FROM public.aman_instances ai\n    JOIN public.branch_roles br ON br.branch_id = ai.branch_id\n    WHERE ai.id = pinned_dashboards.instance_id\n      AND br.user_id = auth.uid()\n      AND br.role = 'branch_manager'\n  )\n)"}	73bf57ab-8166-4652-8e2d-b9ee0d252af6
20250809221050	{"-- Finalized safe migration\n\n-- 1) Ensure 'representative' exists in user_role enum (idempotent)\nDO $$\nBEGIN\n  IF NOT EXISTS (\n    SELECT 1\n    FROM pg_type t\n    JOIN pg_enum e ON t.oid = e.enumtypid\n    WHERE t.typname = 'user_role' AND e.enumlabel = 'representative'\n  ) THEN\n    ALTER TYPE public.user_role ADD VALUE 'representative';\n  END IF;\nEND $$","-- 2) Create table if missing, with minimal required columns\nCREATE TABLE IF NOT EXISTS public.screen_permissions (\n  id uuid PRIMARY KEY DEFAULT gen_random_uuid(),\n  screen_key text NOT NULL UNIQUE,\n  path text NOT NULL,\n  created_at timestamptz NOT NULL DEFAULT now(),\n  updated_at timestamptz NOT NULL DEFAULT now()\n)","-- 3) Ensure all needed columns exist (idempotent)\nALTER TABLE public.screen_permissions ADD COLUMN IF NOT EXISTS title_en text","ALTER TABLE public.screen_permissions ADD COLUMN IF NOT EXISTS title_ar text","ALTER TABLE public.screen_permissions ADD COLUMN IF NOT EXISTS description_en text","ALTER TABLE public.screen_permissions ADD COLUMN IF NOT EXISTS description_ar text","ALTER TABLE public.screen_permissions ADD COLUMN IF NOT EXISTS allowed_roles text[]","ALTER TABLE public.screen_permissions ALTER COLUMN allowed_roles SET DEFAULT '{}'::text[]","ALTER TABLE public.screen_permissions ALTER COLUMN allowed_roles SET NOT NULL","ALTER TABLE public.screen_permissions ADD COLUMN IF NOT EXISTS allow_super_admin boolean","ALTER TABLE public.screen_permissions ALTER COLUMN allow_super_admin SET DEFAULT true","ALTER TABLE public.screen_permissions ALTER COLUMN allow_super_admin SET NOT NULL","ALTER TABLE public.screen_permissions ADD COLUMN IF NOT EXISTS is_active boolean","ALTER TABLE public.screen_permissions ALTER COLUMN is_active SET DEFAULT true","ALTER TABLE public.screen_permissions ALTER COLUMN is_active SET NOT NULL","ALTER TABLE public.screen_permissions ADD COLUMN IF NOT EXISTS created_by uuid","-- 4) Enable RLS\nALTER TABLE public.screen_permissions ENABLE ROW LEVEL SECURITY","-- 5) Policies (drop if exist, then create)\nDROP POLICY IF EXISTS \\"Super admin can manage screen permissions\\" ON public.screen_permissions","CREATE POLICY \\"Super admin can manage screen permissions\\"\nON public.screen_permissions\nFOR ALL\nUSING (is_current_user_super_admin())\nWITH CHECK (is_current_user_super_admin())","DROP POLICY IF EXISTS \\"Authenticated users can view active screen permissions\\" ON public.screen_permissions","CREATE POLICY \\"Authenticated users can view active screen permissions\\"\nON public.screen_permissions\nFOR SELECT\nUSING (COALESCE(public.screen_permissions.is_active, true) = true)","-- 6) Update trigger for updated_at\nDROP TRIGGER IF EXISTS handle_screen_permissions_updated_at ON public.screen_permissions","CREATE TRIGGER handle_screen_permissions_updated_at\nBEFORE UPDATE ON public.screen_permissions\nFOR EACH ROW\nEXECUTE FUNCTION public.update_modified_column()"}	867c8ff9-e04e-44d1-a654-303721ff16da
20250811195921	{BEGIN,"-- Helpful indexes for fast lookups\nCREATE INDEX IF NOT EXISTS idx_system_settings_key ON public.system_settings (setting_key)","CREATE INDEX IF NOT EXISTS idx_org_settings_org_key ON public.organization_settings (organization_id, setting_key)","-- Seed global (system) settings if they don't already exist\nDO $$\nBEGIN\n  IF NOT EXISTS (SELECT 1 FROM public.system_settings WHERE setting_key = 'messaging_global') THEN\n    INSERT INTO public.system_settings (id, setting_key, setting_value, description)\n    VALUES (\n      gen_random_uuid(),\n      'messaging_global',\n      jsonb_build_object(\n        'whatsapp_cloud', jsonb_build_object(\n          'enabled', true,\n          'business_phone_id', NULL,\n          'from_phone_number', NULL,\n          'access_token_secret', 'WHATSAPP_CLOUD_ACCESS_TOKEN'\n        ),\n        'twilio', jsonb_build_object(\n          'enabled', false,\n          'account_sid_secret', 'TWILIO_ACCOUNT_SID',\n          'auth_token_secret', 'TWILIO_AUTH_TOKEN',\n          'from_phone_number', NULL\n        )\n      ),\n      'Global messaging providers configuration managed by system admin'\n    );\n  END IF;\n\n  IF NOT EXISTS (SELECT 1 FROM public.system_settings WHERE setting_key = 'tts_global') THEN\n    INSERT INTO public.system_settings (id, setting_key, setting_value, description)\n    VALUES (\n      gen_random_uuid(),\n      'tts_global',\n      jsonb_build_object(\n        'free_tts', jsonb_build_object(\n          'enabled', true,\n          'default_voice', 'auto'\n        ),\n        'elevenlabs', jsonb_build_object(\n          'enabled', false,\n          'api_key_secret', 'ELEVENLABS_API_KEY',\n          'default_voice_id', 'TX3LPaxmHKxFdv7VOQHJ',\n          'model', 'eleven_turbo_v2_5'\n        ),\n        'default_provider', 'free_tts'\n      ),\n      'Global TTS providers configuration managed by system admin'\n    );\n  END IF;\nEND $$","-- Seed per-organization defaults so the system admin can toggle allowed providers per company\nDO $$\nDECLARE\n  org RECORD;\nBEGIN\n  FOR org IN SELECT id FROM public.organizations LOOP\n    -- Allowed messaging providers for this organization\n    IF NOT EXISTS (\n      SELECT 1 FROM public.organization_settings \n      WHERE organization_id = org.id AND setting_key = 'allowed_messaging'\n    ) THEN\n      INSERT INTO public.organization_settings (id, organization_id, setting_key, setting_value)\n      VALUES (\n        gen_random_uuid(),\n        org.id,\n        'allowed_messaging',\n        jsonb_build_object(\n          'whatsapp_cloud', true,\n          'twilio', false\n        )\n      );\n    END IF;\n\n    -- Allowed TTS providers for this organization (default to free_tts)\n    IF NOT EXISTS (\n      SELECT 1 FROM public.organization_settings \n      WHERE organization_id = org.id AND setting_key = 'allowed_tts'\n    ) THEN\n      INSERT INTO public.organization_settings (id, organization_id, setting_key, setting_value)\n      VALUES (\n        gen_random_uuid(),\n        org.id,\n        'allowed_tts',\n        jsonb_build_object(\n          'elevenlabs', false,\n          'free_tts', true,\n          'default_provider', 'free_tts'\n        )\n      );\n    END IF;\n  END LOOP;\nEND $$",COMMIT}	f9ae1056-68be-4027-b0e2-0fdf33734a7d
20250809223359	{"-- 1) Tables for chat system\n-- Create chat threads\nCREATE TABLE IF NOT EXISTS public.chat_threads (\n  id UUID PRIMARY KEY DEFAULT gen_random_uuid(),\n  organization_id UUID NOT NULL REFERENCES public.organizations(id) ON DELETE CASCADE,\n  created_by UUID,\n  name TEXT,\n  is_private BOOLEAN NOT NULL DEFAULT false,\n  created_at TIMESTAMPTZ NOT NULL DEFAULT now(),\n  updated_at TIMESTAMPTZ NOT NULL DEFAULT now()\n)","-- Create participants\nCREATE TABLE IF NOT EXISTS public.chat_thread_participants (\n  id UUID PRIMARY KEY DEFAULT gen_random_uuid(),\n  thread_id UUID NOT NULL REFERENCES public.chat_threads(id) ON DELETE CASCADE,\n  user_id UUID NOT NULL,\n  added_at TIMESTAMPTZ NOT NULL DEFAULT now(),\n  UNIQUE(thread_id, user_id)\n)","-- Create messages\nCREATE TABLE IF NOT EXISTS public.chat_messages (\n  id UUID PRIMARY KEY DEFAULT gen_random_uuid(),\n  thread_id UUID NOT NULL REFERENCES public.chat_threads(id) ON DELETE CASCADE,\n  organization_id UUID NOT NULL,\n  sender_id UUID NOT NULL,\n  content TEXT NOT NULL,\n  metadata JSONB NOT NULL DEFAULT '{}'::jsonb,\n  created_at TIMESTAMPTZ NOT NULL DEFAULT now()\n)","-- Indexes\nCREATE INDEX IF NOT EXISTS idx_chat_messages_thread_created ON public.chat_messages(thread_id, created_at)","CREATE INDEX IF NOT EXISTS idx_chat_participants_thread ON public.chat_thread_participants(thread_id)","CREATE INDEX IF NOT EXISTS idx_chat_threads_org ON public.chat_threads(organization_id)","-- Updated_at trigger for chat_threads\nCREATE OR REPLACE FUNCTION public.update_modified_column()\nRETURNS TRIGGER AS $$\nBEGIN\n  NEW.updated_at = now();\n  RETURN NEW;\nEND;\n$$ LANGUAGE plpgsql","DROP TRIGGER IF EXISTS trg_chat_threads_updated_at ON public.chat_threads","CREATE TRIGGER trg_chat_threads_updated_at\nBEFORE UPDATE ON public.chat_threads\nFOR EACH ROW\nEXECUTE FUNCTION public.update_modified_column()","-- Touch thread when a new message arrives\nCREATE OR REPLACE FUNCTION public.touch_chat_thread()\nRETURNS TRIGGER\nLANGUAGE plpgsql\nSECURITY DEFINER\nSET search_path TO ''\nAS $$\nBEGIN\n  UPDATE public.chat_threads SET updated_at = now() WHERE id = NEW.thread_id;\n  RETURN NEW;\nEND;\n$$","DROP TRIGGER IF EXISTS trg_touch_thread_after_message_insert ON public.chat_messages","CREATE TRIGGER trg_touch_thread_after_message_insert\nAFTER INSERT ON public.chat_messages\nFOR EACH ROW\nEXECUTE FUNCTION public.touch_chat_thread()","-- Enable RLS\nALTER TABLE public.chat_threads ENABLE ROW LEVEL SECURITY","ALTER TABLE public.chat_thread_participants ENABLE ROW LEVEL SECURITY","ALTER TABLE public.chat_messages ENABLE ROW LEVEL SECURITY","-- Policies for chat_threads\nDROP POLICY IF EXISTS \\"Super admin can manage all chat threads\\" ON public.chat_threads","CREATE POLICY \\"Super admin can manage all chat threads\\"\nON public.chat_threads\nFOR ALL\nUSING (is_current_user_super_admin())\nWITH CHECK (is_current_user_super_admin())","DROP POLICY IF EXISTS \\"Users can view threads they participate in\\" ON public.chat_threads","CREATE POLICY \\"Users can view threads they participate in\\"\nON public.chat_threads\nFOR SELECT\nUSING (\n  EXISTS (\n    SELECT 1 FROM public.chat_thread_participants p\n    WHERE p.thread_id = chat_threads.id AND p.user_id = auth.uid()\n  )\n)","DROP POLICY IF EXISTS \\"Org members can create threads in their org\\" ON public.chat_threads","CREATE POLICY \\"Org members can create threads in their org\\"\nON public.chat_threads\nFOR INSERT\nWITH CHECK (\n  organization_id IN (\n    SELECT ur.organization_id FROM public.user_roles ur WHERE ur.user_id = auth.uid()\n  )\n)","-- Policies for chat_thread_participants\nDROP POLICY IF EXISTS \\"Super admin can manage participants\\" ON public.chat_thread_participants","CREATE POLICY \\"Super admin can manage participants\\"\nON public.chat_thread_participants\nFOR ALL\nUSING (is_current_user_super_admin())\nWITH CHECK (is_current_user_super_admin())","DROP POLICY IF EXISTS \\"Participants can view participants of their threads\\" ON public.chat_thread_participants","CREATE POLICY \\"Participants can view participants of their threads\\"\nON public.chat_thread_participants\nFOR SELECT\nUSING (\n  EXISTS (\n    SELECT 1 FROM public.chat_thread_participants self\n    WHERE self.thread_id = chat_thread_participants.thread_id AND self.user_id = auth.uid()\n  )\n)","DROP POLICY IF EXISTS \\"Org members can add participants to their org threads\\" ON public.chat_thread_participants","CREATE POLICY \\"Org members can add participants to their org threads\\"\nON public.chat_thread_participants\nFOR INSERT\nWITH CHECK (\n  EXISTS (\n    SELECT 1 FROM public.chat_threads t\n    JOIN public.user_roles ur ON ur.organization_id = t.organization_id\n    WHERE t.id = chat_thread_participants.thread_id AND ur.user_id = auth.uid()\n  )\n)","-- Policies for chat_messages\nDROP POLICY IF EXISTS \\"Super admin can view and manage all messages\\" ON public.chat_messages","CREATE POLICY \\"Super admin can view and manage all messages\\"\nON public.chat_messages\nFOR ALL\nUSING (is_current_user_super_admin())\nWITH CHECK (is_current_user_super_admin())","DROP POLICY IF EXISTS \\"Participants can view messages in their threads\\" ON public.chat_messages","CREATE POLICY \\"Participants can view messages in their threads\\"\nON public.chat_messages\nFOR SELECT\nUSING (\n  EXISTS (\n    SELECT 1 FROM public.chat_thread_participants p\n    WHERE p.thread_id = chat_messages.thread_id AND p.user_id = auth.uid()\n  )\n)","DROP POLICY IF EXISTS \\"Participants can send messages to their threads\\" ON public.chat_messages","CREATE POLICY \\"Participants can send messages to their threads\\"\nON public.chat_messages\nFOR INSERT\nWITH CHECK (\n  sender_id = auth.uid()\n  AND EXISTS (\n    SELECT 1 FROM public.chat_thread_participants p\n    WHERE p.thread_id = chat_messages.thread_id AND p.user_id = auth.uid()\n  )\n  AND organization_id = (\n    SELECT t.organization_id FROM public.chat_threads t WHERE t.id = chat_messages.thread_id\n  )\n)"}	1c03228e-fdb5-405d-b9c7-c4cfaf2e7433
20250809224114	{"-- Fix linter: restore secure search_path on update_updated_at_column\nCREATE OR REPLACE FUNCTION public.update_modified_column()\nRETURNS TRIGGER\nLANGUAGE plpgsql\nSECURITY DEFINER\nSET search_path TO ''\nAS $$\nBEGIN\n  NEW.updated_at = now();\n  RETURN NEW;\nEND;\n$$"}	3c6c3ce5-6792-4ddb-914b-5e6aca1850b8
20250809230335	{"-- Chat system migration: threads, participants, and triggers\n\n-- 1) Create chat_threads table if it does not exist\nCREATE TABLE IF NOT EXISTS public.chat_threads (\n  id uuid PRIMARY KEY DEFAULT gen_random_uuid(),\n  organization_id uuid NOT NULL,\n  name text,\n  created_at timestamptz NOT NULL DEFAULT now(),\n  updated_at timestamptz NOT NULL DEFAULT now()\n)","-- Enable RLS on chat_threads\nALTER TABLE public.chat_threads ENABLE ROW LEVEL SECURITY","-- Super admin can manage all chat threads\nDROP POLICY IF EXISTS \\"Super admin can manage all chat threads\\" ON public.chat_threads","CREATE POLICY \\"Super admin can manage all chat threads\\"\nON public.chat_threads\nFOR ALL\nUSING (is_current_user_super_admin())\nWITH CHECK (is_current_user_super_admin())","-- Participants can view their threads\nDROP POLICY IF EXISTS \\"Participants can view their threads\\" ON public.chat_threads","CREATE POLICY \\"Participants can view their threads\\"\nON public.chat_threads\nFOR SELECT\nUSING (\n  EXISTS (\n    SELECT 1 FROM public.chat_thread_participants p\n    WHERE p.thread_id = chat_threads.id AND p.user_id = auth.uid()\n  )\n)","-- Org members can create threads in their org\nDROP POLICY IF EXISTS \\"Org members can create threads in their org\\" ON public.chat_threads","CREATE POLICY \\"Org members can create threads in their org\\"\nON public.chat_threads\nFOR INSERT\nWITH CHECK (\n  organization_id IN (\n    SELECT organization_id FROM public.user_roles WHERE user_id = auth.uid()\n  )\n)","-- Participants can update their threads (e.g., name)\nDROP POLICY IF EXISTS \\"Participants can update their threads\\" ON public.chat_threads","CREATE POLICY \\"Participants can update their threads\\"\nON public.chat_threads\nFOR UPDATE\nUSING (\n  EXISTS (\n    SELECT 1 FROM public.chat_thread_participants p\n    WHERE p.thread_id = chat_threads.id AND p.user_id = auth.uid()\n  )\n)","-- Auto-update updated_at on chat_threads\nDROP TRIGGER IF EXISTS set_updated_at_chat_threads ON public.chat_threads","CREATE TRIGGER set_updated_at_chat_threads\nBEFORE UPDATE ON public.chat_threads\nFOR EACH ROW\nEXECUTE FUNCTION public.update_modified_column()","-- 2) Create chat_thread_participants table if it does not exist\nCREATE TABLE IF NOT EXISTS public.chat_thread_participants (\n  id uuid PRIMARY KEY DEFAULT gen_random_uuid(),\n  thread_id uuid NOT NULL,\n  user_id uuid NOT NULL,\n  added_at timestamptz NOT NULL DEFAULT now()\n)","-- Indexes for performance\nCREATE INDEX IF NOT EXISTS idx_chat_participants_thread ON public.chat_thread_participants(thread_id)","CREATE INDEX IF NOT EXISTS idx_chat_participants_user ON public.chat_thread_participants(user_id)","-- Enable RLS on chat_thread_participants\nALTER TABLE public.chat_thread_participants ENABLE ROW LEVEL SECURITY","-- Super admin can manage all participants\nDROP POLICY IF EXISTS \\"Super admin can manage all participants\\" ON public.chat_thread_participants","CREATE POLICY \\"Super admin can manage all participants\\"\nON public.chat_thread_participants\nFOR ALL\nUSING (is_current_user_super_admin())\nWITH CHECK (is_current_user_super_admin())","-- Participants can view participants in their threads\nDROP POLICY IF EXISTS \\"Participants can view participants in their threads\\" ON public.chat_thread_participants","CREATE POLICY \\"Participants can view participants in their threads\\"\nON public.chat_thread_participants\nFOR SELECT\nUSING (\n  EXISTS (\n    SELECT 1 FROM public.chat_thread_participants p2\n    WHERE p2.thread_id = chat_thread_participants.thread_id AND p2.user_id = auth.uid()\n  )\n)","-- Org members can add participants to org threads (allows creator to add others)\nDROP POLICY IF EXISTS \\"Org members can add participants to org threads\\" ON public.chat_thread_participants","CREATE POLICY \\"Org members can add participants to org threads\\"\nON public.chat_thread_participants\nFOR INSERT\nWITH CHECK (\n  EXISTS (\n    SELECT 1\n    FROM public.chat_threads t\n    JOIN public.user_roles ur ON ur.organization_id = t.organization_id\n    WHERE t.id = chat_thread_participants.thread_id\n      AND ur.user_id = auth.uid()\n  )\n)","-- 3) Ensure trigger to bump thread.updated_at when a new message is inserted\nDROP TRIGGER IF EXISTS touch_thread_on_message_insert ON public.chat_messages","CREATE TRIGGER touch_thread_on_message_insert\nAFTER INSERT ON public.chat_messages\nFOR EACH ROW\nEXECUTE FUNCTION public.touch_chat_thread()"}	3d4c7375-0078-4cbf-ae9a-69b964c0437b
20250809230411	{"-- Fix RLS recursion by using SECURITY DEFINER helper functions\n\n-- 1) Helper: check if current user participates in a thread\nCREATE OR REPLACE FUNCTION public.user_is_thread_participant(thread_id uuid)\nRETURNS boolean\nLANGUAGE sql\nSECURITY DEFINER\nSET search_path TO ''\nAS $$\n  SELECT EXISTS (\n    SELECT 1 FROM public.chat_thread_participants p\n    WHERE p.thread_id = user_is_thread_participant.thread_id\n      AND p.user_id = auth.uid()\n  );\n$$","-- 2) Helper: check if current user is org member for thread's org\nCREATE OR REPLACE FUNCTION public.user_is_org_member_for_thread(thread_id uuid)\nRETURNS boolean\nLANGUAGE sql\nSECURITY DEFINER\nSET search_path TO ''\nAS $$\n  SELECT EXISTS (\n    SELECT 1\n    FROM public.chat_threads t\n    JOIN public.user_roles ur ON ur.organization_id = t.organization_id\n    WHERE t.id = user_is_org_member_for_thread.thread_id\n      AND ur.user_id = auth.uid()\n  );\n$$","-- 3) Update chat_threads policies to use helper functions\nDROP POLICY IF EXISTS \\"Participants can view their threads\\" ON public.chat_threads","CREATE POLICY \\"Participants can view their threads\\"\nON public.chat_threads\nFOR SELECT\nUSING (public.user_is_thread_participant(chat_threads.id))","DROP POLICY IF EXISTS \\"Participants can update their threads\\" ON public.chat_threads","CREATE POLICY \\"Participants can update their threads\\"\nON public.chat_threads\nFOR UPDATE\nUSING (public.user_is_thread_participant(chat_threads.id))","-- 4) Update chat_thread_participants policies to use helper functions\nDROP POLICY IF EXISTS \\"Participants can view participants in their threads\\" ON public.chat_thread_participants","CREATE POLICY \\"Participants can view participants in their threads\\"\nON public.chat_thread_participants\nFOR SELECT\nUSING (public.user_is_thread_participant(chat_thread_participants.thread_id))","DROP POLICY IF EXISTS \\"Org members can add participants to org threads\\" ON public.chat_thread_participants","CREATE POLICY \\"Org members can add participants to org threads\\"\nON public.chat_thread_participants\nFOR INSERT\nWITH CHECK (public.user_is_org_member_for_thread(chat_thread_participants.thread_id))"}	7659de39-be33-4a7b-a954-8f2acd55ef6f
20250809230534	{"-- Resolve recursion in chat_thread_participants SELECT policy\n\n-- Remove recursive policy\nDROP POLICY IF EXISTS \\"Participants can view participants in their threads\\" ON public.chat_thread_participants","-- New non-recursive policy: org members can view participants for threads in their org\nCREATE POLICY \\"Org members can view participants for org threads\\"\nON public.chat_thread_participants\nFOR SELECT\nUSING (\n  EXISTS (\n    SELECT 1\n    FROM public.chat_threads t\n    JOIN public.user_roles ur ON ur.organization_id = t.organization_id\n    WHERE t.id = chat_thread_participants.thread_id\n      AND ur.user_id = auth.uid()\n  )\n)"}	5df25453-3a15-4e67-8a25-af6e19316b38
20250809230733	{"-- Break policy cycle: make chat_threads policies org-based\n\n-- Remove participant-based policies on chat_threads\nDROP POLICY IF EXISTS \\"Participants can view their threads\\" ON public.chat_threads","DROP POLICY IF EXISTS \\"Participants can update their threads\\" ON public.chat_threads","-- Org members can view threads in their org\nCREATE POLICY \\"Org members can view org threads\\"\nON public.chat_threads\nFOR SELECT\nUSING (\n  EXISTS (\n    SELECT 1 FROM public.user_roles ur\n    WHERE ur.user_id = auth.uid()\n      AND ur.organization_id = chat_threads.organization_id\n  )\n)","-- Org members can update threads in their org\nCREATE POLICY \\"Org members can update org threads\\"\nON public.chat_threads\nFOR UPDATE\nUSING (\n  EXISTS (\n    SELECT 1 FROM public.user_roles ur\n    WHERE ur.user_id = auth.uid()\n      AND ur.organization_id = chat_threads.organization_id\n  )\n)"}	ceaad62a-6bf7-4c8f-b710-63e98d75428a
20250809230920	{"-- Clean up recursive and duplicate policies causing infinite recursion\n\n-- chat_thread_participants: drop self-referential SELECT policy\nDROP POLICY IF EXISTS \\"Participants can view participants of their threads\\" ON public.chat_thread_participants","-- chat_thread_participants: drop duplicate super admin policy\nDROP POLICY IF EXISTS \\"Super admin can manage participants\\" ON public.chat_thread_participants","-- chat_thread_participants: drop one of the duplicate INSERT policies (keep the explicit org-based one)\nDROP POLICY IF EXISTS \\"Org members can add participants to org threads\\" ON public.chat_thread_participants","-- chat_threads: drop participant-based SELECT policy to avoid cross-table recursion\nDROP POLICY IF EXISTS \\"Users can view threads they participate in\\" ON public.chat_threads"}	97f5d58a-4220-4496-bc97-52b8d3085b38
20250809235639	{"-- Add policies for viewing form submissions\n-- 1) Super admin full access (manage if needed, but at least SELECT)\nDO $$ BEGIN\n  IF NOT EXISTS (\n    SELECT 1 FROM pg_policies WHERE schemaname = 'public' AND tablename = 'form_submissions' AND policyname = 'Super admin can manage all form submissions'\n  ) THEN\n    CREATE POLICY \\"Super admin can manage all form submissions\\"\n    ON public.form_submissions\n    FOR ALL\n    USING (is_current_user_super_admin())\n    WITH CHECK (is_current_user_super_admin());\n  END IF;\nEND $$","-- 2) Branch managers can view submissions from representatives in their branches\nCREATE OR REPLACE FUNCTION public.branch_manager_can_view_submission(_submission_id uuid)\nRETURNS boolean\nLANGUAGE sql\nSTABLE\nSECURITY DEFINER\nSET search_path = ''\nAS $$\n  WITH fa AS (\n    SELECT fa.representative_id\n    FROM public.form_assignments fa\n    JOIN public.form_submissions fs ON fs.form_assignment_id = fa.id\n    WHERE fs.id = _submission_id\n  ),\n  manager_branches AS (\n    SELECT br.branch_id\n    FROM public.branch_roles br\n    WHERE br.user_id = auth.uid() AND br.role = 'branch_manager'\n  ),\n  rep_branches AS (\n    SELECT br.branch_id\n    FROM public.user_roles ur\n    JOIN public.branch_roles br ON br.user_id = ur.user_id\n    WHERE ur.id = (SELECT representative_id FROM fa)\n  )\n  SELECT EXISTS (\n    SELECT 1 FROM manager_branches mb\n    JOIN rep_branches rb ON rb.branch_id = mb.branch_id\n  );\n$$","DO $$ BEGIN\n  IF NOT EXISTS (\n    SELECT 1 FROM pg_policies WHERE schemaname = 'public' AND tablename = 'form_submissions' AND policyname = 'Branch managers can view branch form submissions'\n  ) THEN\n    CREATE POLICY \\"Branch managers can view branch form submissions\\"\n    ON public.form_submissions\n    FOR SELECT\n    USING (public.branch_manager_can_view_submission(id));\n  END IF;\nEND $$"}	c60120e2-c4ce-4c3c-878a-391bf003af22
20250810001621	{"-- Edited to remove CREATE POLICY (not valid syntax)\n-- Add Super Admin select access where missing\n-- 1) Allow super admin to view all form assignments\nCREATE POLICY \\"Super admin can view all form assignments\\"\nON public.form_assignments\nFOR SELECT\nUSING (is_current_user_super_admin())","-- 2) Allow super admin to view all branches\nCREATE POLICY \\"Super admin can view all branches\\"\nON public.branches\nFOR SELECT\nUSING (is_current_user_super_admin())"}	046183e5-5a32-4a75-afd0-bfbe4b3c9897
20250810001644	{"-- Safely create policies for super admin visibility\nDO $$\nBEGIN\n  IF NOT EXISTS (\n    SELECT 1 FROM pg_policies \n    WHERE schemaname = 'public' AND tablename = 'form_assignments' AND policyname = 'Super admin can view all form assignments'\n  ) THEN\n    CREATE POLICY \\"Super admin can view all form assignments\\"\n    ON public.form_assignments\n    FOR SELECT\n    USING (is_current_user_super_admin());\n  END IF;\n\n  IF NOT EXISTS (\n    SELECT 1 FROM pg_policies \n    WHERE schemaname = 'public' AND tablename = 'branches' AND policyname = 'Super admin can view all branches'\n  ) THEN\n    CREATE POLICY \\"Super admin can view all branches\\"\n    ON public.branches\n    FOR SELECT\n    USING (is_current_user_super_admin());\n  END IF;\nEND $$"}	090e5af4-bbb8-426b-8e1c-44d33eebbfd2
20250810002640	{"-- Helper functions to avoid recursive RLS lookups\nCREATE OR REPLACE FUNCTION public.current_user_is_org_admin_or_manager(org_id uuid)\nRETURNS boolean\nLANGUAGE sql\nSTABLE\nSECURITY DEFINER\nSET search_path TO ''\nAS $$\n  SELECT EXISTS (\n    SELECT 1 FROM public.user_roles ur\n    WHERE ur.user_id = auth.uid()\n      AND ur.organization_id = org_id\n      AND ur.role IN ('admin','manager')\n  );\n$$","CREATE OR REPLACE FUNCTION public.current_user_is_branch_manager_for_user(target_user_id uuid)\nRETURNS boolean\nLANGUAGE sql\nSTABLE\nSECURITY DEFINER\nSET search_path TO ''\nAS $$\n  SELECT EXISTS (\n    SELECT 1\n    FROM public.branch_roles br_mgr\n    JOIN public.branch_roles br_user ON br_user.branch_id = br_mgr.branch_id\n    WHERE br_mgr.user_id = auth.uid()\n      AND br_mgr.role = 'branch_manager'\n      AND br_user.user_id = target_user_id\n  );\n$$","-- Policies to allow managers to view user roles needed for filters\nDO $$\nBEGIN\n  IF NOT EXISTS (\n    SELECT 1 FROM pg_policies WHERE schemaname='public' AND tablename='user_roles' AND policyname='Org admins/managers can view org user roles'\n  ) THEN\n    CREATE POLICY \\"Org admins/managers can view org user roles\\"\n    ON public.user_roles\n    FOR SELECT\n    USING (public.current_user_is_org_admin_or_manager(user_roles.organization_id));\n  END IF;\n\n  IF NOT EXISTS (\n    SELECT 1 FROM pg_policies WHERE schemaname='public' AND tablename='user_roles' AND policyname='Branch managers can view branch user roles'\n  ) THEN\n    CREATE POLICY \\"Branch managers can view branch user roles\\"\n    ON public.user_roles\n    FOR SELECT\n    USING (public.current_user_is_branch_manager_for_user(user_roles.user_id));\n  END IF;\nEND $$"}	ceffedd3-22b7-40c9-bdb8-6a55e1db7924
20250810205640	{"-- Add status column to form_submissions for tracking manager-controlled status\nALTER TABLE public.form_submissions\nADD COLUMN IF NOT EXISTS status text NOT NULL DEFAULT 'in_progress'","-- RLS: Allow organization admins and managers to update submissions in their organization\nDO $$ BEGIN\n  IF NOT EXISTS (\n    SELECT 1 FROM pg_policies WHERE schemaname = 'public' AND tablename = 'form_submissions' AND policyname = 'Org admins/managers can update submissions' \n  ) THEN\n    CREATE POLICY \\"Org admins/managers can update submissions\\"\n    ON public.form_submissions\n    FOR UPDATE\n    USING (\n      EXISTS (\n        SELECT 1\n        FROM public.form_assignments fa\n        JOIN public.user_roles ur ON ur.organization_id = fa.organization_id\n        WHERE fa.id = form_submissions.form_assignment_id\n          AND ur.user_id = auth.uid()\n          AND ur.role = ANY (ARRAY['admin'::user_role, 'manager'::user_role])\n      )\n    )\n    WITH CHECK (\n      EXISTS (\n        SELECT 1\n        FROM public.form_assignments fa\n        JOIN public.user_roles ur ON ur.organization_id = fa.organization_id\n        WHERE fa.id = form_submissions.form_assignment_id\n          AND ur.user_id = auth.uid()\n          AND ur.role = ANY (ARRAY['admin'::user_role, 'manager'::user_role])\n      )\n    );\n  END IF;\nEND $$","-- RLS: Allow branch managers to update submissions they can view\nDO $$ BEGIN\n  IF NOT EXISTS (\n    SELECT 1 FROM pg_policies WHERE schemaname = 'public' AND tablename = 'form_submissions' AND policyname = 'Branch managers can update branch form submissions' \n  ) THEN\n    CREATE POLICY \\"Branch managers can update branch form submissions\\"\n    ON public.form_submissions\n    FOR UPDATE\n    USING (branch_manager_can_view_submission(id))\n    WITH CHECK (branch_manager_can_view_submission(id));\n  END IF;\nEND $$"}	7054550f-496a-46b1-acbf-4cedc78ead71
20250819055457	{"-- Allow system to insert cameras during sync\nCREATE POLICY \\"System can insert cameras during sync\\" ON public.cameras\nFOR INSERT \nWITH CHECK (\n  auth.jwt() ->> 'sub' IS NOT NULL \n  AND branch_id IS NOT NULL\n)","-- Allow system to insert frigate_recordings \nCREATE POLICY \\"System can insert frigate_recordings\\" ON public.frigate_recordings\nFOR INSERT \nWITH CHECK (auth.jwt() ->> 'sub' IS NOT NULL)","-- Allow system to insert frigate_previews\nCREATE POLICY \\"System can insert frigate_previews\\" ON public.frigate_previews  \nFOR INSERT\nWITH CHECK (auth.jwt() ->> 'sub' IS NOT NULL)","-- Allow system to insert frigate_reviews\nCREATE POLICY \\"System can insert frigate_reviews\\" ON public.frigate_reviews\nFOR INSERT \nWITH CHECK (auth.jwt() ->> 'sub' IS NOT NULL)","-- Allow system to insert frigate_timeline\nCREATE POLICY \\"System can insert frigate_timeline\\" ON public.frigate_timeline\nFOR INSERT\nWITH CHECK (auth.jwt() ->> 'sub' IS NOT NULL)"}	1880aaf5-1b54-4775-adba-2fad5944eacf
20250810211313	{"-- Ensure model-files bucket exists and is public\nINSERT INTO storage.buckets (id, name, public)\nVALUES ('model-files', 'model-files', true)\nON CONFLICT (id) DO NOTHING","-- Policy: Public read access to model-files\nDO $$ BEGIN\n  IF NOT EXISTS (\n    SELECT 1 FROM pg_policies WHERE policyname = 'Public can read model-files'\n  ) THEN\n    CREATE POLICY \\"Public can read model-files\\"\n    ON storage.objects\n    FOR SELECT\n    USING (bucket_id = 'model-files');\n  END IF;\nEND $$","-- Policy: Authenticated users can upload to model-files\nDO $$ BEGIN\n  IF NOT EXISTS (\n    SELECT 1 FROM pg_policies WHERE policyname = 'Authenticated users can upload to model-files'\n  ) THEN\n    CREATE POLICY \\"Authenticated users can upload to model-files\\"\n    ON storage.objects\n    FOR INSERT\n    TO authenticated\n    WITH CHECK (bucket_id = 'model-files');\n  END IF;\nEND $$","-- Policy: Authenticated users can update their uploads to model-files\nDO $$ BEGIN\n  IF NOT EXISTS (\n    SELECT 1 FROM pg_policies WHERE policyname = 'Authenticated users can update model-files'\n  ) THEN\n    CREATE POLICY \\"Authenticated users can update model-files\\"\n    ON storage.objects\n    FOR UPDATE\n    TO authenticated\n    USING (bucket_id = 'model-files')\n    WITH CHECK (bucket_id = 'model-files');\n  END IF;\nEND $$","-- Policy: Authenticated users can delete their uploads to model-files\nDO $$ BEGIN\n  IF NOT EXISTS (\n    SELECT 1 FROM pg_policies WHERE policyname = 'Authenticated users can delete model-files'\n  ) THEN\n    CREATE POLICY \\"Authenticated users can delete model-files\\"\n    ON storage.objects\n    FOR DELETE\n    TO authenticated\n    USING (bucket_id = 'model-files');\n  END IF;\nEND $$"}	d305cb9c-6126-4f16-8b18-66c3220d53bd
20250810211640	{"-- Ensure model-files bucket exists and is public\nINSERT INTO storage.buckets (id, name, public)\nVALUES ('model-files', 'model-files', true)\nON CONFLICT (id) DO NOTHING","-- Policy: Public read access to model-files\nDO $$ BEGIN\n  IF NOT EXISTS (\n    SELECT 1 FROM pg_policies WHERE policyname = 'Public can read model-files'\n  ) THEN\n    CREATE POLICY \\"Public can read model-files\\"\n    ON storage.objects\n    FOR SELECT\n    USING (bucket_id = 'model-files');\n  END IF;\nEND $$","-- Policy: Authenticated users can upload to model-files\nDO $$ BEGIN\n  IF NOT EXISTS (\n    SELECT 1 FROM pg_policies WHERE policyname = 'Authenticated users can upload to model-files'\n  ) THEN\n    CREATE POLICY \\"Authenticated users can upload to model-files\\"\n    ON storage.objects\n    FOR INSERT\n    TO authenticated\n    WITH CHECK (bucket_id = 'model-files');\n  END IF;\nEND $$","-- Policy: Authenticated users can update their uploads to model-files\nDO $$ BEGIN\n  IF NOT EXISTS (\n    SELECT 1 FROM pg_policies WHERE policyname = 'Authenticated users can update model-files'\n  ) THEN\n    CREATE POLICY \\"Authenticated users can update model-files\\"\n    ON storage.objects\n    FOR UPDATE\n    TO authenticated\n    USING (bucket_id = 'model-files')\n    WITH CHECK (bucket_id = 'model-files');\n  END IF;\nEND $$","-- Policy: Authenticated users can delete their uploads to model-files\nDO $$ BEGIN\n  IF NOT EXISTS (\n    SELECT 1 FROM pg_policies WHERE policyname = 'Authenticated users can delete model-files'\n  ) THEN\n    CREATE POLICY \\"Authenticated users can delete model-files\\"\n    ON storage.objects\n    FOR DELETE\n    TO authenticated\n    USING (bucket_id = 'model-files');\n  END IF;\nEND $$"}	42def55e-0aa7-41dd-b566-1e0a94a20830
20250810213647	{"-- Ensure the bucket exists (idempotent)\nINSERT INTO storage.buckets (id, name, public)\nVALUES ('form-attachments', 'form-attachments', true)\nON CONFLICT (id) DO NOTHING","-- Allow public read access to files in the form-attachments bucket (idempotent)\nDO $$\nBEGIN\n  IF NOT EXISTS (\n    SELECT 1 FROM pg_policies\n    WHERE schemaname = 'storage'\n      AND tablename = 'objects'\n      AND policyname = 'Public can view form attachments'\n  ) THEN\n    CREATE POLICY \\"Public can view form attachments\\"\n    ON storage.objects\n    FOR SELECT\n    USING (bucket_id = 'form-attachments');\n  END IF;\nEND $$","-- Allow authenticated users to upload to their own folder: <user_id>/...\nDO $$\nBEGIN\n  IF NOT EXISTS (\n    SELECT 1 FROM pg_policies\n    WHERE schemaname = 'storage'\n      AND tablename = 'objects'\n      AND policyname = 'Users can upload to their folder (form-attachments)'\n  ) THEN\n    CREATE POLICY \\"Users can upload to their folder (form-attachments)\\"\n    ON storage.objects\n    FOR INSERT\n    WITH CHECK (\n      bucket_id = 'form-attachments'\n      AND auth.uid()::text = (storage.foldername(name))[1]\n    );\n  END IF;\nEND $$","-- Allow authenticated users to update files in their own folder\nDO $$\nBEGIN\n  IF NOT EXISTS (\n    SELECT 1 FROM pg_policies\n    WHERE schemaname = 'storage'\n      AND tablename = 'objects'\n      AND policyname = 'Users can update their own files (form-attachments)'\n  ) THEN\n    CREATE POLICY \\"Users can update their own files (form-attachments)\\"\n    ON storage.objects\n    FOR UPDATE\n    USING (\n      bucket_id = 'form-attachments'\n      AND auth.uid()::text = (storage.foldername(name))[1]\n    );\n  END IF;\nEND $$","-- Allow authenticated users to delete files in their own folder\nDO $$\nBEGIN\n  IF NOT EXISTS (\n    SELECT 1 FROM pg_policies\n    WHERE schemaname = 'storage'\n      AND tablename = 'objects'\n      AND policyname = 'Users can delete their own files (form-attachments)'\n  ) THEN\n    CREATE POLICY \\"Users can delete their own files (form-attachments)\\"\n    ON storage.objects\n    FOR DELETE\n    USING (\n      bucket_id = 'form-attachments'\n      AND auth.uid()::text = (storage.foldername(name))[1]\n    );\n  END IF;\nEND $$"}	82210e53-5da6-46c7-9005-345ede277917
20250811190000	{"-- Create organization_settings table (referenced by later migration)\nCREATE TABLE IF NOT EXISTS public.organization_settings (\n  id UUID PRIMARY KEY DEFAULT gen_random_uuid(),\n  organization_id UUID NOT NULL REFERENCES public.organizations(id) ON DELETE CASCADE,\n  setting_key TEXT NOT NULL,\n  setting_value JSONB NOT NULL,\n  description TEXT,\n  created_at TIMESTAMPTZ NOT NULL DEFAULT now(),\n  updated_at TIMESTAMPTZ NOT NULL DEFAULT now(),\n  UNIQUE(organization_id, setting_key)\n)","-- Enable RLS\nALTER TABLE public.organization_settings ENABLE ROW LEVEL SECURITY","-- Drop existing policies to avoid conflicts\nDO $$\nDECLARE r record;\nBEGIN\n  FOR r IN SELECT policyname FROM pg_policies WHERE tablename='organization_settings' AND schemaname='public' LOOP\n    EXECUTE format('DROP POLICY %I ON public.organization_settings', r.policyname);\n  END LOOP;\nEND $$","-- RLS: users can view their org's settings, super_admin can manage all\nCREATE POLICY \\"org_settings_view\\" ON public.organization_settings FOR SELECT\nUSING (public.is_current_user_super_admin() OR organization_id IN\n  (SELECT organization_id FROM public.user_roles WHERE user_id = auth.uid()))","CREATE POLICY \\"org_settings_manage\\" ON public.organization_settings FOR ALL\nUSING (public.is_current_user_super_admin() OR organization_id IN\n  (SELECT organization_id FROM public.user_roles WHERE user_id = auth.uid() AND role IN ('admin', 'manager')))\nWITH CHECK (public.is_current_user_super_admin() OR organization_id IN\n  (SELECT organization_id FROM public.user_roles WHERE user_id = auth.uid() AND role IN ('admin', 'manager')))","-- Trigger\nDROP TRIGGER IF EXISTS update_organization_settings_updated_at ON public.organization_settings","CREATE TRIGGER update_organization_settings_updated_at\nBEFORE UPDATE ON public.organization_settings\nFOR EACH ROW EXECUTE FUNCTION public.update_modified_column()"}	create_organization_settings
20250811190810	{"-- Create table for notification labels used in alerts\nCREATE TABLE IF NOT EXISTS public.notification_labels (\n  id UUID PRIMARY KEY DEFAULT gen_random_uuid(),\n  type TEXT NOT NULL, -- e.g., 'audio', 'whatsapp', 'push', 'email'\n  name_ar TEXT NOT NULL,\n  name_en TEXT,\n  is_active BOOLEAN NOT NULL DEFAULT true,\n  created_at TIMESTAMPTZ NOT NULL DEFAULT now(),\n  updated_at TIMESTAMPTZ NOT NULL DEFAULT now(),\n  created_by UUID\n)","-- Enable RLS\nALTER TABLE public.notification_labels ENABLE ROW LEVEL SECURITY","-- Policies\nCREATE POLICY \\"Super admin can manage notification labels\\"\nON public.notification_labels\nAS PERMISSIVE\nFOR ALL\nTO PUBLIC\nUSING (is_current_user_super_admin())\nWITH CHECK (is_current_user_super_admin())","CREATE POLICY \\"Users can view active notification labels\\"\nON public.notification_labels\nAS PERMISSIVE\nFOR SELECT\nTO PUBLIC\nUSING (is_active = true)","-- Trigger to maintain updated_at\nDROP TRIGGER IF EXISTS update_notification_labels_updated_at ON public.notification_labels","CREATE TRIGGER update_notification_labels_updated_at\nBEFORE UPDATE ON public.notification_labels\nFOR EACH ROW\nEXECUTE FUNCTION public.update_modified_column()"}	7b2d5985-1b70-497a-a4ee-ba731f27ba87
20250819143254	{"-- Skipped: pg_cron and pg_net extensions not available in local dev\n-- The auto_sync_settings table is created in 20250819143355"}	91bb2f44-92a2-4829-99bb-677b8de072d5
20250811220610	{"-- Add UI and TTS language preferences per user\n-- 1) Add columns to user_preferences if not exist\nDO $$\nBEGIN\n  IF NOT EXISTS (\n    SELECT 1 FROM information_schema.columns \n    WHERE table_schema = 'public' AND table_name = 'user_preferences' AND column_name = 'ui_language'\n  ) THEN\n    ALTER TABLE public.user_preferences ADD COLUMN ui_language text;\n  END IF;\n  IF NOT EXISTS (\n    SELECT 1 FROM information_schema.columns \n    WHERE table_schema = 'public' AND table_name = 'user_preferences' AND column_name = 'tts_language'\n  ) THEN\n    ALTER TABLE public.user_preferences ADD COLUMN tts_language text;\n  END IF;\nEND $$","-- 2) Backfill from existing language column when new columns are null\nUPDATE public.user_preferences\nSET ui_language = COALESCE(ui_language, language),\n    tts_language = COALESCE(tts_language, language)\nWHERE (ui_language IS NULL OR tts_language IS NULL)","-- 3) Optional: set simple constraints for known language codes via trigger-free approach (no strict check to avoid migration failures)\n-- We avoid CHECK constraints to keep flexibility per guidelines."}	f00a5ded-c43f-4260-ac87-4ae91f0b2c91
20250812230051	{"-- Add api_provider column to alert_templates if it does not exist\nALTER TABLE public.alert_templates\nADD COLUMN IF NOT EXISTS api_provider text NULL","-- Optional: add a simple CHECK to constrain known values while allowing future ones via trigger later if needed\n-- We avoid strict CHECK to keep flexibility; validation can be handled in app/UI.\n-- No RLS changes needed since policies already operate at row level."}	
20250812232101	{"-- Edited to remove CREATE POLICY (not valid syntax)\n-- 1) Table to store AI analysis prompts/responses per camera\nCREATE TABLE IF NOT EXISTS public.ai_analysis_logs (\n  id uuid PRIMARY KEY DEFAULT gen_random_uuid(),\n  camera_id uuid NOT NULL REFERENCES public.cameras(id) ON DELETE CASCADE,\n  alert_template_id uuid REFERENCES public.alert_templates(id) ON DELETE SET NULL,\n  prompt text NOT NULL,\n  response_text text,\n  model text,\n  image_url text,\n  metadata jsonb DEFAULT '{}'::jsonb,\n  created_at timestamptz NOT NULL DEFAULT now()\n)","-- 2) Enable RLS\nALTER TABLE public.ai_analysis_logs ENABLE ROW LEVEL SECURITY","-- 3) Policies mirroring events visibility rules\n-- Users can view logs for cameras in their organization\nCREATE POLICY \\"Users can view AI analysis logs in their org\\"\nON public.ai_analysis_logs\nFOR SELECT\nUSING (\n  EXISTS (\n    SELECT 1\n    FROM public.cameras c\n    JOIN public.branches b ON c.branch_id = b.id\n    JOIN public.user_roles ur ON ur.organization_id = b.organization_id\n    WHERE c.id = ai_analysis_logs.camera_id AND ur.user_id = auth.uid()\n  )\n)","-- Users can insert logs for cameras in their organization\nCREATE POLICY \\"Users can insert AI analysis logs in their org\\"\nON public.ai_analysis_logs\nFOR INSERT\nWITH CHECK (\n  EXISTS (\n    SELECT 1\n    FROM public.cameras c\n    JOIN public.branches b ON c.branch_id = b.id\n    JOIN public.user_roles ur ON ur.organization_id = b.organization_id\n    WHERE c.id = ai_analysis_logs.camera_id AND ur.user_id = auth.uid()\n  )\n)","-- Optional: allow updates by org members (not strictly needed). We skip UPDATE/DELETE to keep immutable logs."}	
20250812232119	{"-- Create table for AI analysis logs (idempotent)\nDO $$\nBEGIN\n  IF NOT EXISTS (SELECT 1 FROM information_schema.tables WHERE table_schema='public' AND table_name='ai_analysis_logs') THEN\n    CREATE TABLE public.ai_analysis_logs (\n      id uuid PRIMARY KEY DEFAULT gen_random_uuid(),\n      camera_id uuid NOT NULL REFERENCES public.cameras(id) ON DELETE CASCADE,\n      alert_template_id uuid REFERENCES public.alert_templates(id) ON DELETE SET NULL,\n      prompt text NOT NULL,\n      response_text text,\n      model text,\n      image_url text,\n      metadata jsonb DEFAULT '{}'::jsonb,\n      created_at timestamptz NOT NULL DEFAULT now()\n    );\n\n    ALTER TABLE public.ai_analysis_logs ENABLE ROW LEVEL SECURITY;\n  END IF;\nEND $$","-- Drop existing policies\nDO $$\nDECLARE r record;\nBEGIN\n  FOR r IN SELECT policyname FROM pg_policies WHERE tablename='ai_analysis_logs' AND schemaname='public' LOOP\n    EXECUTE format('DROP POLICY %I ON public.ai_analysis_logs', r.policyname);\n  END LOOP;\nEND $$","-- Policies\nCREATE POLICY \\"Users can view AI analysis logs in their org\\" ON public.ai_analysis_logs\nFOR SELECT USING (\n  EXISTS (\n    SELECT 1\n    FROM public.cameras c\n    JOIN public.branches b ON c.branch_id = b.id\n    JOIN public.user_roles ur ON ur.organization_id = b.organization_id\n    WHERE c.id = ai_analysis_logs.camera_id AND ur.user_id = auth.uid()\n  )\n)","CREATE POLICY \\"Super admin can manage AI analysis logs\\" ON public.ai_analysis_logs\nFOR ALL USING (public.is_current_user_super_admin()) WITH CHECK (public.is_current_user_super_admin())"}	
20250813213744	{"-- Insert default AI analysis server setting (skipped: system_settings already exists with different schema)\n-- INSERT INTO public.system_settings (setting_key, setting_value, description) ..."}	5f2bb682-371a-459c-977c-dad09d8e9c16
20250813213759	{"-- Insert or update AI analysis server setting\nINSERT INTO public.system_settings (setting_key, setting_value, description) \nVALUES (\n  'ai_analysis_server_url',\n  '{\\"url\\": \\"https://203.161.35.97:11434\\"}',\n  'Server URL for AI analysis (e.g., Ollama server endpoint)'\n)\nON CONFLICT (setting_key) \nDO UPDATE SET \n  setting_value = EXCLUDED.setting_value,\n  updated_at = now()"}	dc35dcf9-1a59-46f9-85b3-e46339eef8d0
20250815062954	{"-- CRITICAL SECURITY FIX: Remove the dangerous policy that allows public access to all subscribers\nDROP POLICY IF EXISTS \\"Service role can manage all subscriptions\\" ON public.subscribers","DROP POLICY IF EXISTS \\"Public access to subscribers\\" ON public.subscribers","DROP POLICY IF EXISTS \\"Enable read access for all users\\" ON public.subscribers","-- Ensure RLS is enabled\nALTER TABLE public.subscribers ENABLE ROW LEVEL SECURITY","-- Create secure policy for organization admins to view subscribers in their org only\nCREATE POLICY \\"Org admins can view org subscribers\\" \nON public.subscribers \nFOR SELECT \nUSING (\n  EXISTS (\n    SELECT 1 FROM public.user_roles ur\n    WHERE ur.user_id = auth.uid() \n    AND ur.organization_id = subscribers.organization_id\n    AND ur.role = 'admin'::user_role\n  )\n)","-- Create policy for system operations (signup process) with proper constraints\nCREATE POLICY \\"System can insert new subscribers\\" \nON public.subscribers \nFOR INSERT \nWITH CHECK (auth.uid() = user_id)"}	f5008267-dd99-4a43-ace1-06200ae6e10d
20250815064501	{"-- حفظ رابط خادم AI الجديد في الإعدادات\nINSERT INTO public.system_settings (setting_key, setting_value, description, updated_by)\nVALUES (\n  'mistral_ai_server_url',\n  '{\\"url\\": \\"https://a0415b97b37d.ngrok-free.app/v1/chat/completions\\"}',\n  'رابط خادم Mistral AI للتحليل الذكي للصور',\n  auth.uid()\n)\nON CONFLICT (setting_key) \nDO UPDATE SET \n  setting_value = EXCLUDED.setting_value,\n  updated_at = now(),\n  updated_by = EXCLUDED.updated_by"}	80a39674-92a2-40ef-afab-8f89bf9adcb4
20250815105042	{"UPDATE cameras \nSET rtsp_url = 'http://85.196.146.82:3337/mjpg/video.mjpg',\n    config = jsonb_set(\n      config,\n      '{stream_id}',\n      '\\"http://85.196.146.82:3337/mjpg/video.mjpg\\"'\n    )\nWHERE id = '7f0c5c39-31d8-4308-92d9-53312dc2e7be'"}	213398f7-b94e-4cb4-868e-29f844ffee26
20250815190325	{"-- Enable Row Level Security on form_distribution_settings table\nALTER TABLE public.form_distribution_settings ENABLE ROW LEVEL SECURITY","-- Allow organization admins and managers to manage distribution settings\n-- Using form_assignments table as the bridge to get organization context\nCREATE POLICY \\"Org admins/managers can manage form distribution settings\\"\nON public.form_distribution_settings\nFOR ALL\nTO authenticated\nUSING (\n  EXISTS (\n    SELECT 1 FROM public.form_assignments fa\n    JOIN public.user_roles ur ON ur.organization_id = fa.organization_id\n    WHERE fa.workflow_form_id = form_distribution_settings.workflow_form_id\n    AND ur.user_id = auth.uid()\n    AND ur.role IN ('admin', 'manager')\n  )\n)\nWITH CHECK (\n  EXISTS (\n    SELECT 1 FROM public.form_assignments fa\n    JOIN public.user_roles ur ON ur.organization_id = fa.organization_id\n    WHERE fa.workflow_form_id = form_distribution_settings.workflow_form_id\n    AND ur.user_id = auth.uid()\n    AND ur.role IN ('admin', 'manager')\n  )\n)","-- Allow organization members to view distribution settings (read-only for regular users)\nCREATE POLICY \\"Org members can view form distribution settings\\"\nON public.form_distribution_settings\nFOR SELECT\nTO authenticated\nUSING (\n  EXISTS (\n    SELECT 1 FROM public.form_assignments fa\n    JOIN public.user_roles ur ON ur.organization_id = fa.organization_id\n    WHERE fa.workflow_form_id = form_distribution_settings.workflow_form_id\n    AND ur.user_id = auth.uid()\n  )\n)","-- Allow super admin to manage all distribution settings\nCREATE POLICY \\"Super admin can manage all form distribution settings\\"\nON public.form_distribution_settings\nFOR ALL\nTO authenticated\nUSING (public.is_current_user_super_admin())\nWITH CHECK (public.is_current_user_super_admin())"}	68167c42-c366-4930-91b2-3b8a9b72f935
20250815190416	{"-- Drop existing policies to recreate them properly\nDROP POLICY IF EXISTS \\"Org admins/managers can manage form distribution settings\\" ON public.form_distribution_settings","DROP POLICY IF EXISTS \\"Org members can view form distribution settings\\" ON public.form_distribution_settings","DROP POLICY IF EXISTS \\"Super admin can manage all form distribution settings\\" ON public.form_distribution_settings","-- Enable RLS if not already enabled\nALTER TABLE public.form_distribution_settings ENABLE ROW LEVEL SECURITY","-- Create proper RLS policies\n-- Allow organization admins and managers to manage distribution settings\nCREATE POLICY \\"Org admins/managers can manage form distribution settings\\"\nON public.form_distribution_settings\nFOR ALL\nTO authenticated\nUSING (\n  EXISTS (\n    SELECT 1 FROM public.form_assignments fa\n    JOIN public.user_roles ur ON ur.organization_id = fa.organization_id\n    WHERE fa.workflow_form_id = form_distribution_settings.workflow_form_id\n    AND ur.user_id = auth.uid()\n    AND ur.role IN ('admin', 'manager')\n  )\n)\nWITH CHECK (\n  EXISTS (\n    SELECT 1 FROM public.form_assignments fa\n    JOIN public.user_roles ur ON ur.organization_id = fa.organization_id\n    WHERE fa.workflow_form_id = form_distribution_settings.workflow_form_id\n    AND ur.user_id = auth.uid()\n    AND ur.role IN ('admin', 'manager')\n  )\n)","-- Allow organization members to view distribution settings (read-only access)\nCREATE POLICY \\"Org members can view form distribution settings\\"\nON public.form_distribution_settings\nFOR SELECT\nTO authenticated\nUSING (\n  EXISTS (\n    SELECT 1 FROM public.form_assignments fa\n    JOIN public.user_roles ur ON ur.organization_id = fa.organization_id\n    WHERE fa.workflow_form_id = form_distribution_settings.workflow_form_id\n    AND ur.user_id = auth.uid()\n  )\n)","-- Allow super admin full access\nCREATE POLICY \\"Super admin can manage all form distribution settings\\"\nON public.form_distribution_settings\nFOR ALL\nTO authenticated\nUSING (public.is_current_user_super_admin())\nWITH CHECK (public.is_current_user_super_admin())"}	e4d854ce-2d31-4693-b0ca-3244901af85c
20250815190504	{"-- Drop existing policies to recreate them correctly\nDROP POLICY IF EXISTS \\"Org admins/managers can manage form distribution settings\\" ON public.form_distribution_settings","DROP POLICY IF EXISTS \\"Org members can view form distribution settings\\" ON public.form_distribution_settings","DROP POLICY IF EXISTS \\"Super admin can manage all form distribution settings\\" ON public.form_distribution_settings","-- Enable RLS (in case it wasn't enabled)\nALTER TABLE public.form_distribution_settings ENABLE ROW LEVEL SECURITY","-- Create proper policies based on actual table relationships\n-- Allow organization admins and managers to manage distribution settings\nCREATE POLICY \\"Org admins/managers can manage form distribution settings\\"\nON public.form_distribution_settings\nFOR ALL\nTO authenticated\nUSING (\n  EXISTS (\n    SELECT 1 FROM public.form_assignments fa\n    JOIN public.user_roles ur ON ur.organization_id = fa.organization_id\n    WHERE fa.workflow_form_id = form_distribution_settings.workflow_form_id\n    AND ur.user_id = auth.uid()\n    AND ur.role IN ('admin', 'manager')\n  )\n)\nWITH CHECK (\n  EXISTS (\n    SELECT 1 FROM public.form_assignments fa\n    JOIN public.user_roles ur ON ur.organization_id = fa.organization_id\n    WHERE fa.workflow_form_id = form_distribution_settings.workflow_form_id\n    AND ur.user_id = auth.uid()\n    AND ur.role IN ('admin', 'manager')\n  )\n)","-- Allow organization members to view distribution settings\nCREATE POLICY \\"Org members can view form distribution settings\\"\nON public.form_distribution_settings\nFOR SELECT\nTO authenticated\nUSING (\n  EXISTS (\n    SELECT 1 FROM public.form_assignments fa\n    JOIN public.user_roles ur ON ur.organization_id = fa.organization_id\n    WHERE fa.workflow_form_id = form_distribution_settings.workflow_form_id\n    AND ur.user_id = auth.uid()\n  )\n)","-- Allow super admin to manage all distribution settings\nCREATE POLICY \\"Super admin can manage all form distribution settings\\"\nON public.form_distribution_settings\nFOR ALL\nTO authenticated\nUSING (public.is_current_user_super_admin())\nWITH CHECK (public.is_current_user_super_admin())"}	3c63d9e3-a858-4c12-934c-6678664012ba
20250815190531	{"-- Fix Function Search Path Security Issue\n-- Update all existing functions to have proper search_path\n\n-- Fix update_updated_at_column function\nCREATE OR REPLACE FUNCTION public.update_modified_column()\n RETURNS trigger\n LANGUAGE plpgsql\n SECURITY DEFINER\n SET search_path TO 'public'\nAS $function$\nBEGIN\n  NEW.updated_at = now();\n  RETURN NEW;\nEND;\n$function$","-- Fix handle_updated_at function\nCREATE OR REPLACE FUNCTION public.update_modified_column()\n RETURNS trigger\n LANGUAGE plpgsql\n SECURITY DEFINER\n SET search_path TO 'public'\nAS $function$\nBEGIN\n  NEW.updated_at = now();\n  RETURN NEW;\nEND;\n$function$","-- Fix update_subscriber_activity function\nCREATE OR REPLACE FUNCTION public.update_subscriber_activity()\n RETURNS trigger\n LANGUAGE plpgsql\n SECURITY DEFINER\n SET search_path TO 'public'\nAS $function$\nBEGIN\n    UPDATE public.subscribers \n    SET last_activity = now() \n    WHERE user_id = NEW.user_id OR user_id = OLD.user_id;\n    RETURN COALESCE(NEW, OLD);\nEND;\n$function$","-- Fix is_super_admin function\nCREATE OR REPLACE FUNCTION public.is_super_admin(user_email text)\n RETURNS boolean\n LANGUAGE sql\n SECURITY DEFINER\n SET search_path TO 'public'\nAS $function$\n  SELECT user_email = 'ashraffarid@gmail.com'\n$function$","-- Fix is_current_user_super_admin function\nCREATE OR REPLACE FUNCTION public.is_current_user_super_admin()\n RETURNS boolean\n LANGUAGE sql\n SECURITY DEFINER\n SET search_path TO 'public'\nAS $function$\n  SELECT public.is_super_admin((SELECT email FROM auth.users WHERE id = auth.uid()))\n$function$","-- Fix set_updated_at function\nCREATE OR REPLACE FUNCTION public.update_modified_column()\n RETURNS trigger\n LANGUAGE plpgsql\n SECURITY DEFINER\n SET search_path TO 'public'\nAS $function$\nBEGIN\n  NEW.updated_at = now();\n  RETURN NEW;\nEND; \n$function$","-- Fix touch_chat_thread function\nCREATE OR REPLACE FUNCTION public.touch_chat_thread()\n RETURNS trigger\n LANGUAGE plpgsql\n SECURITY DEFINER\n SET search_path TO 'public'\nAS $function$\nBEGIN\n  UPDATE public.chat_threads SET updated_at = now() WHERE id = NEW.thread_id;\n  RETURN NEW;\nEND;\n$function$","-- Fix user_is_thread_participant function\nCREATE OR REPLACE FUNCTION public.user_is_thread_participant(thread_id uuid)\n RETURNS boolean\n LANGUAGE sql\n SECURITY DEFINER\n SET search_path TO 'public'\nAS $function$\n  SELECT EXISTS (\n    SELECT 1 FROM public.chat_thread_participants p\n    WHERE p.thread_id = user_is_thread_participant.thread_id\n      AND p.user_id = auth.uid()\n  );\n$function$","-- Fix other functions with search_path\nCREATE OR REPLACE FUNCTION public.update_modified_column()\n RETURNS trigger\n LANGUAGE plpgsql\n SECURITY DEFINER\n SET search_path TO 'public'\nAS $function$\nBEGIN\n    NEW.updated_at = NOW();\n    RETURN NEW;\nEND;\n$function$"}	2c3e1632-1469-48e9-9f4e-2ebfb2a9b1b3
20250815190559	{"-- Drop existing policies to recreate them properly\nDROP POLICY IF EXISTS \\"Org admins/managers can manage form distribution settings\\" ON public.form_distribution_settings","DROP POLICY IF EXISTS \\"Org members can view form distribution settings\\" ON public.form_distribution_settings","DROP POLICY IF EXISTS \\"Super admin can manage all form distribution settings\\" ON public.form_distribution_settings","-- Enable RLS if not already enabled\nALTER TABLE public.form_distribution_settings ENABLE ROW LEVEL SECURITY","-- Create proper RLS policies\n-- Allow organization admins and managers to manage distribution settings\nCREATE POLICY \\"Org admins/managers can manage form distribution settings\\"\nON public.form_distribution_settings\nFOR ALL\nTO authenticated\nUSING (\n  EXISTS (\n    SELECT 1 FROM public.form_assignments fa\n    JOIN public.user_roles ur ON ur.organization_id = fa.organization_id\n    WHERE fa.workflow_form_id = form_distribution_settings.workflow_form_id\n    AND ur.user_id = auth.uid()\n    AND ur.role IN ('admin', 'manager')\n  )\n)\nWITH CHECK (\n  EXISTS (\n    SELECT 1 FROM public.form_assignments fa\n    JOIN public.user_roles ur ON ur.organization_id = fa.organization_id\n    WHERE fa.workflow_form_id = form_distribution_settings.workflow_form_id\n    AND ur.user_id = auth.uid()\n    AND ur.role IN ('admin', 'manager')\n  )\n)","-- Allow organization members to view distribution settings (read-only access)\nCREATE POLICY \\"Org members can view form distribution settings\\"\nON public.form_distribution_settings\nFOR SELECT\nTO authenticated\nUSING (\n  EXISTS (\n    SELECT 1 FROM public.form_assignments fa\n    JOIN public.user_roles ur ON ur.organization_id = fa.organization_id\n    WHERE fa.workflow_form_id = form_distribution_settings.workflow_form_id\n    AND ur.user_id = auth.uid()\n  )\n)","-- Allow super admin full access\nCREATE POLICY \\"Super admin can manage all form distribution settings\\"\nON public.form_distribution_settings\nFOR ALL\nTO authenticated\nUSING (public.is_current_user_super_admin())\nWITH CHECK (public.is_current_user_super_admin())"}	42617fc4-64c3-463f-b3e4-29058375fde1
20250816050328	{"-- Update the is_super_admin function to include the new demo user\nCREATE OR REPLACE FUNCTION public.is_super_admin(user_email text)\n RETURNS boolean\n LANGUAGE sql\n SECURITY DEFINER\n SET search_path TO 'public'\nAS $function$\n  SELECT user_email IN ('ashraffarid@gmail.com', 'demo@beyondsenses.ai')\n$function$"}	6db115ae-ffa3-4634-b870-a46935b3e713
20250816052437	{"-- Add RLS policies for subscribers table to allow super admin to update subscribers\nDROP POLICY IF EXISTS \\"Super admin can manage all subscribers\\" ON public.subscribers","DROP POLICY IF EXISTS \\"Users can view their own subscriptions\\" ON public.subscribers","DROP POLICY IF EXISTS \\"Users can create their own subscriptions\\" ON public.subscribers","DROP POLICY IF EXISTS \\"Users can update their own subscriptions\\" ON public.subscribers","-- Create comprehensive policies for subscribers\nCREATE POLICY \\"Super admin can manage all subscribers\\"\nON public.subscribers\nFOR ALL\nUSING (is_current_user_super_admin())\nWITH CHECK (is_current_user_super_admin())","CREATE POLICY \\"Users can view their own subscriptions\\"\nON public.subscribers\nFOR SELECT\nUSING (user_id = auth.uid())","CREATE POLICY \\"Users can create their own subscriptions\\"\nON public.subscribers\nFOR INSERT\nWITH CHECK (user_id = auth.uid())","CREATE POLICY \\"Users can update their own subscriptions\\"\nON public.subscribers\nFOR UPDATE\nUSING (user_id = auth.uid())\nWITH CHECK (user_id = auth.uid())","-- Add policy for admins to view all subscribers in their organization\nCREATE POLICY \\"Org admins can view all subscribers\\"\nON public.subscribers\nFOR SELECT\nUSING (\n  EXISTS (\n    SELECT 1 FROM user_roles ur\n    WHERE ur.user_id = auth.uid()\n    AND ur.role IN ('admin', 'manager')\n    AND ur.organization_id = subscribers.organization_id\n  )\n  OR is_current_user_super_admin()\n)","-- Add policy for admins to update subscribers in their organization\nCREATE POLICY \\"Org admins can update subscribers\\"\nON public.subscribers\nFOR UPDATE\nUSING (\n  EXISTS (\n    SELECT 1 FROM user_roles ur\n    WHERE ur.user_id = auth.uid()\n    AND ur.role IN ('admin', 'manager')\n    AND ur.organization_id = subscribers.organization_id\n  )\n  OR is_current_user_super_admin()\n)\nWITH CHECK (\n  EXISTS (\n    SELECT 1 FROM user_roles ur\n    WHERE ur.user_id = auth.uid()\n    AND ur.role IN ('admin', 'manager')\n    AND ur.organization_id = subscribers.organization_id\n  )\n  OR is_current_user_super_admin()\n)"}	548f8bf4-1609-41ae-a209-25fbed2152f5
20250816052626	{"-- First, let's see what policies exist and drop them properly\nDROP POLICY IF EXISTS \\"Org admins can view all subscribers\\" ON public.subscribers","DROP POLICY IF EXISTS \\"Org admins can update subscribers\\" ON public.subscribers","-- Update is_super_admin function to handle case sensitivity\nCREATE OR REPLACE FUNCTION public.is_super_admin(user_email text)\nRETURNS boolean\nLANGUAGE sql\nSECURITY DEFINER\nSET search_path TO ''\nAS $$\n  SELECT LOWER(user_email) IN ('ashraffarid@gmail.com', 'demo@beyondsenses.ai')\n$$","-- Add the missing policies\nCREATE POLICY \\"Org admins can view all subscribers\\"\nON public.subscribers\nFOR SELECT\nUSING (\n  is_current_user_super_admin() OR\n  EXISTS (\n    SELECT 1 FROM user_roles ur\n    WHERE ur.user_id = auth.uid()\n    AND ur.role IN ('admin', 'manager')\n  )\n)","CREATE POLICY \\"Org admins can update subscribers\\"\nON public.subscribers\nFOR UPDATE\nUSING (\n  is_current_user_super_admin() OR\n  EXISTS (\n    SELECT 1 FROM user_roles ur\n    WHERE ur.user_id = auth.uid()\n    AND ur.role IN ('admin', 'manager')\n  )\n)\nWITH CHECK (\n  is_current_user_super_admin() OR\n  EXISTS (\n    SELECT 1 FROM user_roles ur\n    WHERE ur.user_id = auth.uid()\n    AND ur.role IN ('admin', 'manager')\n  )\n)"}	ab28e1c1-1f24-4dbf-8ee0-c7f2ce2871bb
20250816054416	{"UPDATE public.subscribers \nSET \n  subscription_status = 'active',\n  approved_at = now(),\n  approved_by = (SELECT id FROM auth.users WHERE email = 'ashraffarid@gmail.com')\nWHERE email = 'demo@beyondsenses.ai'"}	37c00fb0-9416-4642-8a4c-96699a2832f2
20250817114756	{"-- Face recognition tables for Frigate 0.16\nCREATE TABLE public.frigate_faces (\n  id TEXT PRIMARY KEY,\n  camera_id UUID REFERENCES public.cameras(id) ON DELETE CASCADE,\n  embedding JSONB, -- Face embedding as JSON array\n  label TEXT, -- Person name/identifier\n  confidence FLOAT NOT NULL DEFAULT 0.0,\n  thumbnail_url TEXT,\n  created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(),\n  updated_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now()\n)","-- License plates table for Frigate 0.16  \nCREATE TABLE public.frigate_license_plates (\n  id TEXT PRIMARY KEY,\n  plate_number TEXT NOT NULL,\n  camera_id UUID REFERENCES public.cameras(id) ON DELETE CASCADE,\n  confidence FLOAT NOT NULL DEFAULT 0.0,\n  region TEXT, -- License plate region/state\n  vehicle_make TEXT,\n  vehicle_model TEXT,\n  vehicle_color TEXT,\n  thumbnail_url TEXT,\n  created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(),\n  updated_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now()\n)","-- Detection zones for Frigate cameras\nCREATE TABLE public.frigate_zones (\n  id UUID NOT NULL DEFAULT gen_random_uuid() PRIMARY KEY,\n  camera_id UUID REFERENCES public.cameras(id) ON DELETE CASCADE,\n  name TEXT NOT NULL,\n  coordinates JSONB NOT NULL, -- Array of [x,y] coordinates\n  zone_type TEXT NOT NULL DEFAULT 'detection', -- detection, activity, etc.\n  enabled BOOLEAN NOT NULL DEFAULT true,\n  color TEXT DEFAULT '#3b82f6',\n  created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(),\n  updated_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now()\n)","-- Enhanced events table with Frigate 0.16 attributes\nALTER TABLE public.events ADD COLUMN IF NOT EXISTS attributes JSONB DEFAULT '{}'","ALTER TABLE public.events ADD COLUMN IF NOT EXISTS face_id TEXT","ALTER TABLE public.events ADD COLUMN IF NOT EXISTS license_plate TEXT","ALTER TABLE public.events ADD COLUMN IF NOT EXISTS zones TEXT[]","-- Array of zone names\nALTER TABLE public.events ADD COLUMN IF NOT EXISTS sub_label TEXT","-- For more detailed categorization\nALTER TABLE public.events ADD COLUMN IF NOT EXISTS top_score FLOAT","-- Confidence score\nALTER TABLE public.events ADD COLUMN IF NOT EXISTS start_time TIMESTAMP WITH TIME ZONE","ALTER TABLE public.events ADD COLUMN IF NOT EXISTS end_time TIMESTAMP WITH TIME ZONE","ALTER TABLE public.events ADD COLUMN IF NOT EXISTS has_clip BOOLEAN DEFAULT false","ALTER TABLE public.events ADD COLUMN IF NOT EXISTS has_snapshot BOOLEAN DEFAULT false","ALTER TABLE public.events ADD COLUMN IF NOT EXISTS frigate_id TEXT","-- Original Frigate event ID\n\n-- Timeline segments for video scrubbing\nCREATE TABLE public.frigate_timeline (\n  id UUID NOT NULL DEFAULT gen_random_uuid() PRIMARY KEY,\n  camera_id UUID REFERENCES public.cameras(id) ON DELETE CASCADE,\n  start_time TIMESTAMP WITH TIME ZONE NOT NULL,\n  end_time TIMESTAMP WITH TIME ZONE NOT NULL,\n  segment_type TEXT NOT NULL DEFAULT 'recording', -- recording, motion, detection\n  file_path TEXT,\n  duration_seconds INTEGER,\n  created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now()\n)","-- Alert rules for enhanced notifications\nCREATE TABLE public.frigate_alert_rules (\n  id UUID NOT NULL DEFAULT gen_random_uuid() PRIMARY KEY,\n  camera_id UUID REFERENCES public.cameras(id) ON DELETE CASCADE,\n  rule_name TEXT NOT NULL,\n  object_types TEXT[] DEFAULT '{}', -- person, car, etc.\n  zones TEXT[] DEFAULT '{}', -- Zone names to monitor\n  min_confidence FLOAT DEFAULT 0.7,\n  cooldown_seconds INTEGER DEFAULT 60,\n  notification_methods JSONB DEFAULT '{\\"push\\": true, \\"email\\": false}',\n  enabled BOOLEAN NOT NULL DEFAULT true,\n  created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(),\n  updated_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now()\n)","-- Indexes for performance\nCREATE INDEX IF NOT EXISTS idx_frigate_faces_camera_id ON public.frigate_faces(camera_id)","CREATE INDEX IF NOT EXISTS idx_frigate_faces_label ON public.frigate_faces(label)","CREATE INDEX IF NOT EXISTS idx_frigate_license_plates_camera_id ON public.frigate_license_plates(camera_id)","CREATE INDEX IF NOT EXISTS idx_frigate_license_plates_plate_number ON public.frigate_license_plates(plate_number)","CREATE INDEX IF NOT EXISTS idx_frigate_zones_camera_id ON public.frigate_zones(camera_id)","CREATE INDEX IF NOT EXISTS idx_frigate_timeline_camera_id ON public.frigate_timeline(camera_id)","CREATE INDEX IF NOT EXISTS idx_frigate_timeline_time ON public.frigate_timeline(start_time, end_time)","CREATE INDEX IF NOT EXISTS idx_events_face_id ON public.events(face_id) WHERE face_id IS NOT NULL","CREATE INDEX IF NOT EXISTS idx_events_license_plate ON public.events(license_plate) WHERE license_plate IS NOT NULL","CREATE INDEX IF NOT EXISTS idx_events_frigate_id ON public.events(frigate_id) WHERE frigate_id IS NOT NULL","-- Enable RLS for new tables\nALTER TABLE public.frigate_faces ENABLE ROW LEVEL SECURITY","ALTER TABLE public.frigate_license_plates ENABLE ROW LEVEL SECURITY","ALTER TABLE public.frigate_zones ENABLE ROW LEVEL SECURITY","ALTER TABLE public.frigate_timeline ENABLE ROW LEVEL SECURITY","ALTER TABLE public.frigate_alert_rules ENABLE ROW LEVEL SECURITY","-- RLS policies for frigate_faces\nCREATE POLICY \\"Users can view faces in their organization cameras\\" ON public.frigate_faces\n  FOR SELECT USING (\n    EXISTS (\n      SELECT 1 FROM public.cameras c\n      JOIN public.branches b ON c.branch_id = b.id\n      JOIN public.user_roles ur ON ur.organization_id = b.organization_id\n      WHERE c.id = frigate_faces.camera_id AND ur.user_id = auth.uid()\n    )\n  )","CREATE POLICY \\"Admins can manage faces in their organization\\" ON public.frigate_faces\n  FOR ALL USING (\n    EXISTS (\n      SELECT 1 FROM public.cameras c\n      JOIN public.branches b ON c.branch_id = b.id\n      JOIN public.user_roles ur ON ur.organization_id = b.organization_id\n      WHERE c.id = frigate_faces.camera_id \n        AND ur.user_id = auth.uid() \n        AND ur.role IN ('admin', 'manager')\n    )\n  )","-- RLS policies for frigate_license_plates  \nCREATE POLICY \\"Users can view license plates in their organization cameras\\" ON public.frigate_license_plates\n  FOR SELECT USING (\n    EXISTS (\n      SELECT 1 FROM public.cameras c\n      JOIN public.branches b ON c.branch_id = b.id\n      JOIN public.user_roles ur ON ur.organization_id = b.organization_id\n      WHERE c.id = frigate_license_plates.camera_id AND ur.user_id = auth.uid()\n    )\n  )","-- RLS policies for frigate_zones\nCREATE POLICY \\"Users can view zones in their organization cameras\\" ON public.frigate_zones\n  FOR SELECT USING (\n    EXISTS (\n      SELECT 1 FROM public.cameras c\n      JOIN public.branches b ON c.branch_id = b.id\n      JOIN public.user_roles ur ON ur.organization_id = b.organization_id\n      WHERE c.id = frigate_zones.camera_id AND ur.user_id = auth.uid()\n    )\n  )","CREATE POLICY \\"Admins can manage zones in their organization cameras\\" ON public.frigate_zones\n  FOR ALL USING (\n    EXISTS (\n      SELECT 1 FROM public.cameras c\n      JOIN public.branches b ON c.branch_id = b.id\n      JOIN public.user_roles ur ON ur.organization_id = b.organization_id\n      WHERE c.id = frigate_zones.camera_id \n        AND ur.user_id = auth.uid() \n        AND ur.role IN ('admin', 'manager')\n    )\n  )","-- RLS policies for frigate_timeline\nCREATE POLICY \\"Users can view timeline in their organization cameras\\" ON public.frigate_timeline\n  FOR SELECT USING (\n    EXISTS (\n      SELECT 1 FROM public.cameras c\n      JOIN public.branches b ON c.branch_id = b.id  \n      JOIN public.user_roles ur ON ur.organization_id = b.organization_id\n      WHERE c.id = frigate_timeline.camera_id AND ur.user_id = auth.uid()\n    )\n  )","-- RLS policies for frigate_alert_rules\nCREATE POLICY \\"Users can view alert rules in their organization cameras\\" ON public.frigate_alert_rules\n  FOR SELECT USING (\n    EXISTS (\n      SELECT 1 FROM public.cameras c\n      JOIN public.branches b ON c.branch_id = b.id\n      JOIN public.user_roles ur ON ur.organization_id = b.organization_id\n      WHERE c.id = frigate_alert_rules.camera_id AND ur.user_id = auth.uid()\n    )\n  )","CREATE POLICY \\"Admins can manage alert rules in their organization cameras\\" ON public.frigate_alert_rules\n  FOR ALL USING (\n    EXISTS (\n      SELECT 1 FROM public.cameras c\n      JOIN public.branches b ON c.branch_id = b.id\n      JOIN public.user_roles ur ON ur.organization_id = b.organization_id\n      WHERE c.id = frigate_alert_rules.camera_id \n        AND ur.user_id = auth.uid() \n        AND ur.role IN ('admin', 'manager')\n    )\n  )","-- Super admin policies for all tables\nCREATE POLICY \\"Super admin can manage all frigate faces\\" ON public.frigate_faces\n  FOR ALL USING (is_current_user_super_admin())","CREATE POLICY \\"Super admin can manage all frigate license plates\\" ON public.frigate_license_plates\n  FOR ALL USING (is_current_user_super_admin())","CREATE POLICY \\"Super admin can manage all frigate zones\\" ON public.frigate_zones\n  FOR ALL USING (is_current_user_super_admin())","CREATE POLICY \\"Super admin can manage all frigate timeline\\" ON public.frigate_timeline\n  FOR ALL USING (is_current_user_super_admin())","CREATE POLICY \\"Super admin can manage all frigate alert rules\\" ON public.frigate_alert_rules\n  FOR ALL USING (is_current_user_super_admin())","-- Triggers for updated_at timestamps\nCREATE TRIGGER set_updated_at BEFORE UPDATE ON public.frigate_faces\n  FOR EACH ROW EXECUTE FUNCTION public.update_modified_column()","CREATE TRIGGER set_updated_at BEFORE UPDATE ON public.frigate_license_plates\n  FOR EACH ROW EXECUTE FUNCTION public.update_modified_column()","CREATE TRIGGER set_updated_at BEFORE UPDATE ON public.frigate_zones\n  FOR EACH ROW EXECUTE FUNCTION public.update_modified_column()","CREATE TRIGGER set_updated_at BEFORE UPDATE ON public.frigate_alert_rules\n  FOR EACH ROW EXECUTE FUNCTION public.update_modified_column()"}	56c5d57b-cd5a-4ce8-866f-075d0dae2897
20250817132004	{"-- Create frigate_instances table for managing multiple Frigate devices per branch\nCREATE TABLE public.frigate_instances (\n  id UUID NOT NULL DEFAULT gen_random_uuid() PRIMARY KEY,\n  branch_id UUID NOT NULL,\n  name TEXT NOT NULL,\n  description TEXT,\n  host_url TEXT NOT NULL,\n  api_key TEXT,\n  config_yaml TEXT,\n  enabled BOOLEAN NOT NULL DEFAULT true,\n  last_sync_at TIMESTAMP WITH TIME ZONE,\n  created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(),\n  updated_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(),\n  UNIQUE(branch_id, name)\n)","-- Enable RLS on frigate_instances\nALTER TABLE public.frigate_instances ENABLE ROW LEVEL SECURITY","-- Add frigate_instance_id to cameras table\nALTER TABLE public.cameras ADD COLUMN frigate_instance_id UUID REFERENCES public.frigate_instances(id)","-- Create RLS policies for frigate_instances\nCREATE POLICY \\"Super admin can manage all frigate instances\\" \nON public.frigate_instances \nFOR ALL \nUSING (is_current_user_super_admin())","CREATE POLICY \\"Org admins can manage frigate instances in their organization\\" \nON public.frigate_instances \nFOR ALL \nUSING (\n  EXISTS (\n    SELECT 1 FROM branches b\n    JOIN user_roles ur ON ur.organization_id = b.organization_id\n    WHERE b.id = frigate_instances.branch_id \n    AND ur.user_id = auth.uid() \n    AND ur.role IN ('admin', 'manager')\n  )\n)","CREATE POLICY \\"Users can view frigate instances in their organization\\" \nON public.frigate_instances \nFOR SELECT \nUSING (\n  EXISTS (\n    SELECT 1 FROM branches b\n    JOIN user_roles ur ON ur.organization_id = b.organization_id\n    WHERE b.id = frigate_instances.branch_id \n    AND ur.user_id = auth.uid()\n  )\n)","-- Create trigger for updated_at\nCREATE TRIGGER update_frigate_instances_updated_at\n  BEFORE UPDATE ON public.frigate_instances\n  FOR EACH ROW\n  EXECUTE FUNCTION public.update_modified_column()","-- Update existing cameras to link with frigate instances (optional - can be done manually)\n-- This is just a placeholder structure - actual linking would be done through the UI"}	9f1f8e1c-6ffd-4de4-8c9f-0cce8843ece7
20250817133315	{"-- Fix frigate_instances table by adding the missing foreign key constraint\nALTER TABLE public.frigate_instances \nADD CONSTRAINT frigate_instances_branch_id_fkey \nFOREIGN KEY (branch_id) REFERENCES public.branches(id) ON DELETE SET NULL"}	8bc68ea1-3edf-4178-959e-52ec94d14875
20250818135821	{"-- Drop the existing INSERT policy for cameras\nDROP POLICY IF EXISTS \\"Admins and managers can insert cameras\\" ON public.cameras","-- Create a better INSERT policy\nCREATE POLICY \\"Admins and managers can insert cameras in their organization\\"\nON public.cameras\nFOR INSERT\nWITH CHECK (\n  EXISTS (\n    SELECT 1\n    FROM public.branches b\n    JOIN public.user_roles ur ON ur.organization_id = b.organization_id\n    WHERE b.id = branch_id\n      AND ur.user_id = auth.uid()\n      AND ur.role IN ('admin', 'manager')\n  )\n)","-- Also add super admin policy for INSERT\nCREATE POLICY \\"Super admin can insert cameras\\"\nON public.cameras\nFOR INSERT\nWITH CHECK (is_current_user_super_admin())"}	bdd6b2f4-fdec-466e-8a6d-d03602e3b0ae
20250818140420	{"-- Drop existing policies to fix the permission issue\nDROP POLICY IF EXISTS \\"Admins and managers can insert cameras in their organization\\" ON public.cameras","DROP POLICY IF EXISTS \\"Super admin can insert cameras\\" ON public.cameras","-- Create a more permissive INSERT policy that handles authentication properly\nCREATE POLICY \\"Users with admin/manager role can insert cameras\\"\nON public.cameras\nFOR INSERT\nTO authenticated\nWITH CHECK (\n  -- Super admin can add cameras anywhere\n  is_current_user_super_admin() \n  OR\n  -- Regular admins/managers can add cameras in their organization\n  EXISTS (\n    SELECT 1\n    FROM public.user_roles ur\n    JOIN public.branches b ON b.organization_id = ur.organization_id\n    WHERE ur.user_id = auth.uid()\n      AND ur.role IN ('admin', 'manager')\n      AND b.id = branch_id\n  )\n)","-- Also update the SELECT policy to be more permissive for troubleshooting\nDROP POLICY IF EXISTS \\"Users can view cameras in their organization\\" ON public.cameras","CREATE POLICY \\"Users can view cameras in their organization\\"\nON public.cameras\nFOR SELECT\nTO authenticated\nUSING (\n  -- Super admin can view all\n  is_current_user_super_admin()\n  OR\n  -- Regular users can view cameras in their organization\n  EXISTS (\n    SELECT 1\n    FROM public.branches b\n    JOIN public.user_roles ur ON ur.organization_id = b.organization_id\n    WHERE b.id = cameras.branch_id\n      AND ur.user_id = auth.uid()\n  )\n)"}	00890a6a-a541-441b-86c9-090df723b431
20250818184814	{"-- Drop existing policies for model-files bucket if they exist\nDROP POLICY IF EXISTS \\"Allow authenticated users to upload model files\\" ON storage.objects","DROP POLICY IF EXISTS \\"Allow public access to model files\\" ON storage.objects","DROP POLICY IF EXISTS \\"Allow authenticated users to update their model files\\" ON storage.objects","DROP POLICY IF EXISTS \\"Allow authenticated users to delete their model files\\" ON storage.objects","-- Create new storage policies for the model-files bucket\nCREATE POLICY \\"Enable upload for authenticated users on model files\\" \nON storage.objects \nFOR INSERT \nTO authenticated\nWITH CHECK (bucket_id = 'model-files')","CREATE POLICY \\"Enable read for all users on model files\\" \nON storage.objects \nFOR SELECT \nTO public\nUSING (bucket_id = 'model-files')","CREATE POLICY \\"Enable update for authenticated users on model files\\" \nON storage.objects \nFOR UPDATE \nTO authenticated\nUSING (bucket_id = 'model-files')\nWITH CHECK (bucket_id = 'model-files')","CREATE POLICY \\"Enable delete for authenticated users on model files\\" \nON storage.objects \nFOR DELETE \nTO authenticated\nUSING (bucket_id = 'model-files')"}	76f1d8e9-8aaa-41d9-b0a8-071c6f0f6858
20250818185203	{"-- Create storage bucket for test uploads\nINSERT INTO storage.buckets (id, name, public) \nVALUES ('test-uploads', 'test-uploads', true)","-- Create storage policies for the test-uploads bucket\nCREATE POLICY \\"Enable upload for authenticated users on test uploads\\" \nON storage.objects \nFOR INSERT \nTO authenticated\nWITH CHECK (bucket_id = 'test-uploads')","CREATE POLICY \\"Enable read for all users on test uploads\\" \nON storage.objects \nFOR SELECT \nTO public\nUSING (bucket_id = 'test-uploads')","CREATE POLICY \\"Enable update for authenticated users on test uploads\\" \nON storage.objects \nFOR UPDATE \nTO authenticated\nUSING (bucket_id = 'test-uploads')\nWITH CHECK (bucket_id = 'test-uploads')","CREATE POLICY \\"Enable delete for authenticated users on test uploads\\" \nON storage.objects \nFOR DELETE \nTO authenticated\nUSING (bucket_id = 'test-uploads')"}	cab9c056-57e9-4e74-99ea-a300412c7506
20250819041417	{"-- Add sync_interval_seconds to frigate_instances table\nALTER TABLE frigate_instances \nADD COLUMN sync_interval_seconds INTEGER DEFAULT 300","-- Add comment to document the column\nCOMMENT ON COLUMN frigate_instances.sync_interval_seconds IS 'Synchronization interval in seconds for Frigate data sync'"}	3481dd17-97c6-45b5-8e0b-5bff2dfd4aa7
20250819044323	{"-- Create table for Frigate recordings (doesn't exist yet)\nCREATE TABLE IF NOT EXISTS public.frigate_recordings (\n    id UUID NOT NULL DEFAULT gen_random_uuid() PRIMARY KEY,\n    recording_id TEXT NOT NULL,\n    frigate_instance_id UUID NOT NULL,\n    camera TEXT NOT NULL,\n    start_time TIMESTAMP WITH TIME ZONE NOT NULL,\n    end_time TIMESTAMP WITH TIME ZONE NOT NULL,\n    duration INTEGER,\n    size BIGINT,\n    path TEXT,\n    url TEXT,\n    metadata JSONB,\n    created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(),\n    updated_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(),\n    UNIQUE(recording_id, frigate_instance_id)\n)","-- Create table for Frigate previews (doesn't exist yet)\nCREATE TABLE IF NOT EXISTS public.frigate_previews (\n    id UUID NOT NULL DEFAULT gen_random_uuid() PRIMARY KEY,\n    preview_id TEXT NOT NULL,\n    frigate_instance_id UUID NOT NULL,\n    camera TEXT NOT NULL,\n    start_time TIMESTAMP WITH TIME ZONE NOT NULL,\n    end_time TIMESTAMP WITH TIME ZONE NOT NULL,\n    path TEXT,\n    url TEXT,\n    metadata JSONB,\n    created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(),\n    updated_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(),\n    UNIQUE(preview_id, frigate_instance_id)\n)","-- Create table for Frigate exports (doesn't exist yet)\nCREATE TABLE IF NOT EXISTS public.frigate_exports (\n    id UUID NOT NULL DEFAULT gen_random_uuid() PRIMARY KEY,\n    export_id TEXT NOT NULL,\n    frigate_instance_id UUID NOT NULL,\n    camera TEXT NOT NULL,\n    start_time TIMESTAMP WITH TIME ZONE NOT NULL,\n    end_time TIMESTAMP WITH TIME ZONE NOT NULL,\n    path TEXT,\n    status TEXT,\n    url TEXT,\n    metadata JSONB,\n    created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(),\n    updated_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(),\n    UNIQUE(export_id, frigate_instance_id)\n)","-- Create table for Frigate reviews (doesn't exist yet)\nCREATE TABLE IF NOT EXISTS public.frigate_reviews (\n    id UUID NOT NULL DEFAULT gen_random_uuid() PRIMARY KEY,\n    review_id TEXT NOT NULL,\n    frigate_instance_id UUID NOT NULL,\n    camera TEXT NOT NULL,\n    start_time TIMESTAMP WITH TIME ZONE NOT NULL,\n    end_time TIMESTAMP WITH TIME ZONE NOT NULL,\n    severity TEXT,\n    has_been_reviewed BOOLEAN DEFAULT false,\n    data JSONB,\n    metadata JSONB,\n    created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(),\n    updated_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(),\n    UNIQUE(review_id, frigate_instance_id)\n)","-- Add new columns to existing frigate_timeline table to support our sync data\nALTER TABLE public.frigate_timeline \nADD COLUMN IF NOT EXISTS frigate_instance_id UUID,\nADD COLUMN IF NOT EXISTS class_type TEXT,\nADD COLUMN IF NOT EXISTS data JSONB,\nADD COLUMN IF NOT EXISTS metadata JSONB,\nADD COLUMN IF NOT EXISTS entry_id TEXT","-- Enable Row Level Security on new tables\nALTER TABLE public.frigate_recordings ENABLE ROW LEVEL SECURITY","ALTER TABLE public.frigate_previews ENABLE ROW LEVEL SECURITY","ALTER TABLE public.frigate_exports ENABLE ROW LEVEL SECURITY","ALTER TABLE public.frigate_reviews ENABLE ROW LEVEL SECURITY","-- Create policies for authenticated users to access all data\nCREATE POLICY \\"Users can view all frigate_recordings\\" ON public.frigate_recordings FOR SELECT USING (auth.role() = 'authenticated')","CREATE POLICY \\"Users can insert frigate_recordings\\" ON public.frigate_recordings FOR INSERT WITH CHECK (auth.role() = 'authenticated')","CREATE POLICY \\"Users can update frigate_recordings\\" ON public.frigate_recordings FOR UPDATE USING (auth.role() = 'authenticated')","CREATE POLICY \\"Users can delete frigate_recordings\\" ON public.frigate_recordings FOR DELETE USING (auth.role() = 'authenticated')","CREATE POLICY \\"Users can view all frigate_previews\\" ON public.frigate_previews FOR SELECT USING (auth.role() = 'authenticated')","CREATE POLICY \\"Users can insert frigate_previews\\" ON public.frigate_previews FOR INSERT WITH CHECK (auth.role() = 'authenticated')","CREATE POLICY \\"Users can update frigate_previews\\" ON public.frigate_previews FOR UPDATE USING (auth.role() = 'authenticated')","CREATE POLICY \\"Users can delete frigate_previews\\" ON public.frigate_previews FOR DELETE USING (auth.role() = 'authenticated')","CREATE POLICY \\"Users can view all frigate_exports\\" ON public.frigate_exports FOR SELECT USING (auth.role() = 'authenticated')","CREATE POLICY \\"Users can insert frigate_exports\\" ON public.frigate_exports FOR INSERT WITH CHECK (auth.role() = 'authenticated')","CREATE POLICY \\"Users can update frigate_exports\\" ON public.frigate_exports FOR UPDATE USING (auth.role() = 'authenticated')","CREATE POLICY \\"Users can delete frigate_exports\\" ON public.frigate_exports FOR DELETE USING (auth.role() = 'authenticated')","CREATE POLICY \\"Users can view all frigate_reviews\\" ON public.frigate_reviews FOR SELECT USING (auth.role() = 'authenticated')","CREATE POLICY \\"Users can insert frigate_reviews\\" ON public.frigate_reviews FOR INSERT WITH CHECK (auth.role() = 'authenticated')","CREATE POLICY \\"Users can update frigate_reviews\\" ON public.frigate_reviews FOR UPDATE USING (auth.role() = 'authenticated')","CREATE POLICY \\"Users can delete frigate_reviews\\" ON public.frigate_reviews FOR DELETE USING (auth.role() = 'authenticated')","-- Add foreign key constraints where tables don't already exist\nDO $$\nBEGIN\n    IF EXISTS (SELECT 1 FROM information_schema.tables WHERE table_name = 'frigate_recordings') THEN\n        ALTER TABLE public.frigate_recordings \n        ADD CONSTRAINT fk_frigate_recordings_instance \n        FOREIGN KEY (frigate_instance_id) REFERENCES public.frigate_instances(id) ON DELETE CASCADE;\n    END IF;\n\n    IF EXISTS (SELECT 1 FROM information_schema.tables WHERE table_name = 'frigate_previews') THEN\n        ALTER TABLE public.frigate_previews \n        ADD CONSTRAINT fk_frigate_previews_instance \n        FOREIGN KEY (frigate_instance_id) REFERENCES public.frigate_instances(id) ON DELETE CASCADE;\n    END IF;\n\n    IF EXISTS (SELECT 1 FROM information_schema.tables WHERE table_name = 'frigate_exports') THEN\n        ALTER TABLE public.frigate_exports \n        ADD CONSTRAINT fk_frigate_exports_instance \n        FOREIGN KEY (frigate_instance_id) REFERENCES public.frigate_instances(id) ON DELETE CASCADE;\n    END IF;\n\n    IF EXISTS (SELECT 1 FROM information_schema.tables WHERE table_name = 'frigate_reviews') THEN\n        ALTER TABLE public.frigate_reviews \n        ADD CONSTRAINT fk_frigate_reviews_instance \n        FOREIGN KEY (frigate_instance_id) REFERENCES public.frigate_instances(id) ON DELETE CASCADE;\n    END IF;\n\n    -- Add foreign key to existing timeline table if column was added\n    IF EXISTS (SELECT 1 FROM information_schema.columns WHERE table_name = 'frigate_timeline' AND column_name = 'frigate_instance_id') THEN\n        ALTER TABLE public.frigate_timeline \n        ADD CONSTRAINT fk_frigate_timeline_instance \n        FOREIGN KEY (frigate_instance_id) REFERENCES public.frigate_instances(id) ON DELETE CASCADE;\n    END IF;\nEND\n$$","-- Create indexes for better performance\nCREATE INDEX IF NOT EXISTS idx_frigate_recordings_instance_camera ON public.frigate_recordings(frigate_instance_id, camera)","CREATE INDEX IF NOT EXISTS idx_frigate_recordings_time ON public.frigate_recordings(start_time, end_time)","CREATE INDEX IF NOT EXISTS idx_frigate_previews_instance_camera ON public.frigate_previews(frigate_instance_id, camera)","CREATE INDEX IF NOT EXISTS idx_frigate_previews_time ON public.frigate_previews(start_time, end_time)","CREATE INDEX IF NOT EXISTS idx_frigate_exports_instance_camera ON public.frigate_exports(frigate_instance_id, camera)","CREATE INDEX IF NOT EXISTS idx_frigate_exports_status ON public.frigate_exports(status)","CREATE INDEX IF NOT EXISTS idx_frigate_reviews_instance_camera ON public.frigate_reviews(frigate_instance_id, camera)","CREATE INDEX IF NOT EXISTS idx_frigate_reviews_severity ON public.frigate_reviews(severity)","CREATE INDEX IF NOT EXISTS idx_frigate_reviews_reviewed ON public.frigate_reviews(has_been_reviewed)","-- Create triggers for updating timestamps\nCREATE OR REPLACE FUNCTION public.update_modified_column()\nRETURNS TRIGGER AS $$\nBEGIN\n    NEW.updated_at = now();\n    RETURN NEW;\nEND;\n$$ LANGUAGE plpgsql","DROP TRIGGER IF EXISTS update_frigate_recordings_updated_at ON public.frigate_recordings","CREATE TRIGGER update_frigate_recordings_updated_at\n    BEFORE UPDATE ON public.frigate_recordings\n    FOR EACH ROW\n    EXECUTE FUNCTION public.update_modified_column()","DROP TRIGGER IF EXISTS update_frigate_previews_updated_at ON public.frigate_previews","CREATE TRIGGER update_frigate_previews_updated_at\n    BEFORE UPDATE ON public.frigate_previews\n    FOR EACH ROW\n    EXECUTE FUNCTION public.update_modified_column()","DROP TRIGGER IF EXISTS update_frigate_exports_updated_at ON public.frigate_exports","CREATE TRIGGER update_frigate_exports_updated_at\n    BEFORE UPDATE ON public.frigate_exports\n    FOR EACH ROW\n    EXECUTE FUNCTION public.update_modified_column()","DROP TRIGGER IF EXISTS update_frigate_reviews_updated_at ON public.frigate_reviews","CREATE TRIGGER update_frigate_reviews_updated_at\n    BEFORE UPDATE ON public.frigate_reviews\n    FOR EACH ROW\n    EXECUTE FUNCTION public.update_modified_column()"}	014b7bf3-8898-4311-b884-7afb7721b5ff
20250819055242	{"-- Insert default Frigate sync settings if they don't exist\nINSERT INTO system_settings (setting_key, setting_value, description) VALUES\n('frigate_sync_minutes', '5', 'Minimum minutes between Frigate sync operations')\nON CONFLICT (setting_key) DO NOTHING","INSERT INTO system_settings (setting_key, setting_value, description) VALUES  \n('frigate_last_sync_at', 'null', 'Timestamp of last Frigate sync operation')\nON CONFLICT (setting_key) DO NOTHING"}	f1c842cd-b647-4c64-87f2-ad21ed58eafd
20250819055400	{"-- Allow sync functions to insert events\nCREATE POLICY \\"System can insert events during sync\\" ON public.events\nFOR INSERT \nWITH CHECK (\n  auth.jwt() ->> 'sub' IS NOT NULL \n  AND metadata->>'frigate_instance_id' IS NOT NULL\n)"}	5b19d1f4-da0d-4508-8dc3-12ad8696084e
20250819143355	{"-- Create a function to handle HTTP requests\nCREATE OR REPLACE FUNCTION public.trigger_auto_sync()\nRETURNS void\nLANGUAGE plpgsql\nSECURITY DEFINER\nAS $$\nBEGIN\n  -- Skipped: requires pg_net extension not enabled in local dev\n  -- In production, this function calls auto-sync-data edge function via pg_net\n  NULL;\nEND;\n$$","-- Create a function to manage the auto sync schedule (no-op in local dev)\nCREATE OR REPLACE FUNCTION public.manage_auto_sync_schedule(enabled boolean, interval_minutes integer DEFAULT 30)\nRETURNS void\nLANGUAGE plpgsql\nSECURITY DEFINER\nAS $$\nBEGIN\n  -- No-op: pg_cron not available in local dev\n  NULL;\nEND;\n$$","-- Create a table to store auto sync settings\nCREATE TABLE IF NOT EXISTS public.auto_sync_settings (\n    id UUID PRIMARY KEY DEFAULT gen_random_uuid(),\n    enabled BOOLEAN NOT NULL DEFAULT true,\n    interval_minutes INTEGER NOT NULL DEFAULT 30,\n    last_sync TIMESTAMP WITH TIME ZONE,\n    next_sync TIMESTAMP WITH TIME ZONE,\n    created_at TIMESTAMP WITH TIME ZONE DEFAULT now(),\n    updated_at TIMESTAMP WITH TIME ZONE DEFAULT now()\n)","-- Insert default settings\nINSERT INTO public.auto_sync_settings (enabled, interval_minutes)\nVALUES (true, 30)\nON CONFLICT DO NOTHING","-- Enable RLS\nALTER TABLE public.auto_sync_settings ENABLE ROW LEVEL SECURITY","-- Create policies for auto sync settings (only super admins can manage)\nCREATE POLICY \\"autosync_view\\" ON public.auto_sync_settings FOR SELECT\nUSING (public.is_current_user_super_admin())","CREATE POLICY \\"autosync_update\\" ON public.auto_sync_settings FOR UPDATE\nUSING (public.is_current_user_super_admin())","-- Create trigger for updated_at\nDROP TRIGGER IF EXISTS update_auto_sync_settings_updated_at ON public.auto_sync_settings","CREATE TRIGGER update_auto_sync_settings_updated_at\n    BEFORE UPDATE ON public.auto_sync_settings\n    FOR EACH ROW\n    EXECUTE FUNCTION public.update_modified_column()"}	1f9c742b-b516-47db-bf68-b75e6d9a658d
20250819183715	{"-- Skipped: pg_net and pg_cron not available in local dev\n-- The function trigger_auto_sync is defined in 20250819143355 (no-op for local)"}	ea9c2051-f42e-4c35-a1a4-ed0e74b277f2
20250819184158	{"-- Skipped: pg_net not available in local dev"}	787de401-d5be-4149-b1e2-5c80508a90e4
20260610999999	{"-- Disable RLS on all tables for local development\n-- (Production uses Supabase RLS; for local dev we disable to allow anon key access)\nDO $$\nDECLARE r record;\nBEGIN\n  FOR r IN SELECT tablename FROM pg_tables WHERE schemaname = 'public' LOOP\n    EXECUTE format('ALTER TABLE public.%I DISABLE ROW LEVEL SECURITY', r.tablename);\n  END LOOP;\nEND $$"}	disable_rls_all
\.


--
-- Data for Name: secrets; Type: TABLE DATA; Schema: vault; Owner: supabase_admin
--

COPY vault.secrets (id, name, description, secret, key_id, nonce, created_at, updated_at) FROM stdin;
\.


--
-- Name: refresh_tokens_id_seq; Type: SEQUENCE SET; Schema: auth; Owner: supabase_auth_admin
--

SELECT pg_catalog.setval('auth.refresh_tokens_id_seq', 58, true);


--
-- Name: subscription_id_seq; Type: SEQUENCE SET; Schema: realtime; Owner: supabase_admin
--

SELECT pg_catalog.setval('realtime.subscription_id_seq', 296, true);


--
-- Name: hooks_id_seq; Type: SEQUENCE SET; Schema: supabase_functions; Owner: supabase_functions_admin
--

SELECT pg_catalog.setval('supabase_functions.hooks_id_seq', 1, false);


--
-- Name: extensions extensions_pkey; Type: CONSTRAINT; Schema: _realtime; Owner: supabase_admin
--

ALTER TABLE ONLY _realtime.extensions
    ADD CONSTRAINT extensions_pkey PRIMARY KEY (id);


--
-- Name: feature_flags feature_flags_pkey; Type: CONSTRAINT; Schema: _realtime; Owner: supabase_admin
--

ALTER TABLE ONLY _realtime.feature_flags
    ADD CONSTRAINT feature_flags_pkey PRIMARY KEY (id);


--
-- Name: schema_migrations schema_migrations_pkey; Type: CONSTRAINT; Schema: _realtime; Owner: supabase_admin
--

ALTER TABLE ONLY _realtime.schema_migrations
    ADD CONSTRAINT schema_migrations_pkey PRIMARY KEY (version);


--
-- Name: tenants tenants_pkey; Type: CONSTRAINT; Schema: _realtime; Owner: supabase_admin
--

ALTER TABLE ONLY _realtime.tenants
    ADD CONSTRAINT tenants_pkey PRIMARY KEY (id);


--
-- Name: mfa_amr_claims amr_id_pk; Type: CONSTRAINT; Schema: auth; Owner: supabase_auth_admin
--

ALTER TABLE ONLY auth.mfa_amr_claims
    ADD CONSTRAINT amr_id_pk PRIMARY KEY (id);


--
-- Name: audit_log_entries audit_log_entries_pkey; Type: CONSTRAINT; Schema: auth; Owner: supabase_auth_admin
--

ALTER TABLE ONLY auth.audit_log_entries
    ADD CONSTRAINT audit_log_entries_pkey PRIMARY KEY (id);


--
-- Name: custom_oauth_providers custom_oauth_providers_identifier_key; Type: CONSTRAINT; Schema: auth; Owner: supabase_auth_admin
--

ALTER TABLE ONLY auth.custom_oauth_providers
    ADD CONSTRAINT custom_oauth_providers_identifier_key UNIQUE (identifier);


--
-- Name: custom_oauth_providers custom_oauth_providers_pkey; Type: CONSTRAINT; Schema: auth; Owner: supabase_auth_admin
--

ALTER TABLE ONLY auth.custom_oauth_providers
    ADD CONSTRAINT custom_oauth_providers_pkey PRIMARY KEY (id);


--
-- Name: flow_state flow_state_pkey; Type: CONSTRAINT; Schema: auth; Owner: supabase_auth_admin
--

ALTER TABLE ONLY auth.flow_state
    ADD CONSTRAINT flow_state_pkey PRIMARY KEY (id);


--
-- Name: identities identities_pkey; Type: CONSTRAINT; Schema: auth; Owner: supabase_auth_admin
--

ALTER TABLE ONLY auth.identities
    ADD CONSTRAINT identities_pkey PRIMARY KEY (id);


--
-- Name: identities identities_provider_id_provider_unique; Type: CONSTRAINT; Schema: auth; Owner: supabase_auth_admin
--

ALTER TABLE ONLY auth.identities
    ADD CONSTRAINT identities_provider_id_provider_unique UNIQUE (provider_id, provider);


--
-- Name: instances instances_pkey; Type: CONSTRAINT; Schema: auth; Owner: supabase_auth_admin
--

ALTER TABLE ONLY auth.instances
    ADD CONSTRAINT instances_pkey PRIMARY KEY (id);


--
-- Name: mfa_amr_claims mfa_amr_claims_session_id_authentication_method_pkey; Type: CONSTRAINT; Schema: auth; Owner: supabase_auth_admin
--

ALTER TABLE ONLY auth.mfa_amr_claims
    ADD CONSTRAINT mfa_amr_claims_session_id_authentication_method_pkey UNIQUE (session_id, authentication_method);


--
-- Name: mfa_challenges mfa_challenges_pkey; Type: CONSTRAINT; Schema: auth; Owner: supabase_auth_admin
--

ALTER TABLE ONLY auth.mfa_challenges
    ADD CONSTRAINT mfa_challenges_pkey PRIMARY KEY (id);


--
-- Name: mfa_factors mfa_factors_last_challenged_at_key; Type: CONSTRAINT; Schema: auth; Owner: supabase_auth_admin
--

ALTER TABLE ONLY auth.mfa_factors
    ADD CONSTRAINT mfa_factors_last_challenged_at_key UNIQUE (last_challenged_at);


--
-- Name: mfa_factors mfa_factors_pkey; Type: CONSTRAINT; Schema: auth; Owner: supabase_auth_admin
--

ALTER TABLE ONLY auth.mfa_factors
    ADD CONSTRAINT mfa_factors_pkey PRIMARY KEY (id);


--
-- Name: oauth_authorizations oauth_authorizations_authorization_code_key; Type: CONSTRAINT; Schema: auth; Owner: supabase_auth_admin
--

ALTER TABLE ONLY auth.oauth_authorizations
    ADD CONSTRAINT oauth_authorizations_authorization_code_key UNIQUE (authorization_code);


--
-- Name: oauth_authorizations oauth_authorizations_authorization_id_key; Type: CONSTRAINT; Schema: auth; Owner: supabase_auth_admin
--

ALTER TABLE ONLY auth.oauth_authorizations
    ADD CONSTRAINT oauth_authorizations_authorization_id_key UNIQUE (authorization_id);


--
-- Name: oauth_authorizations oauth_authorizations_pkey; Type: CONSTRAINT; Schema: auth; Owner: supabase_auth_admin
--

ALTER TABLE ONLY auth.oauth_authorizations
    ADD CONSTRAINT oauth_authorizations_pkey PRIMARY KEY (id);


--
-- Name: oauth_client_states oauth_client_states_pkey; Type: CONSTRAINT; Schema: auth; Owner: supabase_auth_admin
--

ALTER TABLE ONLY auth.oauth_client_states
    ADD CONSTRAINT oauth_client_states_pkey PRIMARY KEY (id);


--
-- Name: oauth_clients oauth_clients_pkey; Type: CONSTRAINT; Schema: auth; Owner: supabase_auth_admin
--

ALTER TABLE ONLY auth.oauth_clients
    ADD CONSTRAINT oauth_clients_pkey PRIMARY KEY (id);


--
-- Name: oauth_consents oauth_consents_pkey; Type: CONSTRAINT; Schema: auth; Owner: supabase_auth_admin
--

ALTER TABLE ONLY auth.oauth_consents
    ADD CONSTRAINT oauth_consents_pkey PRIMARY KEY (id);


--
-- Name: oauth_consents oauth_consents_user_client_unique; Type: CONSTRAINT; Schema: auth; Owner: supabase_auth_admin
--

ALTER TABLE ONLY auth.oauth_consents
    ADD CONSTRAINT oauth_consents_user_client_unique UNIQUE (user_id, client_id);


--
-- Name: one_time_tokens one_time_tokens_pkey; Type: CONSTRAINT; Schema: auth; Owner: supabase_auth_admin
--

ALTER TABLE ONLY auth.one_time_tokens
    ADD CONSTRAINT one_time_tokens_pkey PRIMARY KEY (id);


--
-- Name: refresh_tokens refresh_tokens_pkey; Type: CONSTRAINT; Schema: auth; Owner: supabase_auth_admin
--

ALTER TABLE ONLY auth.refresh_tokens
    ADD CONSTRAINT refresh_tokens_pkey PRIMARY KEY (id);


--
-- Name: refresh_tokens refresh_tokens_token_unique; Type: CONSTRAINT; Schema: auth; Owner: supabase_auth_admin
--

ALTER TABLE ONLY auth.refresh_tokens
    ADD CONSTRAINT refresh_tokens_token_unique UNIQUE (token);


--
-- Name: saml_providers saml_providers_entity_id_key; Type: CONSTRAINT; Schema: auth; Owner: supabase_auth_admin
--

ALTER TABLE ONLY auth.saml_providers
    ADD CONSTRAINT saml_providers_entity_id_key UNIQUE (entity_id);


--
-- Name: saml_providers saml_providers_pkey; Type: CONSTRAINT; Schema: auth; Owner: supabase_auth_admin
--

ALTER TABLE ONLY auth.saml_providers
    ADD CONSTRAINT saml_providers_pkey PRIMARY KEY (id);


--
-- Name: saml_relay_states saml_relay_states_pkey; Type: CONSTRAINT; Schema: auth; Owner: supabase_auth_admin
--

ALTER TABLE ONLY auth.saml_relay_states
    ADD CONSTRAINT saml_relay_states_pkey PRIMARY KEY (id);


--
-- Name: schema_migrations schema_migrations_pkey; Type: CONSTRAINT; Schema: auth; Owner: supabase_auth_admin
--

ALTER TABLE ONLY auth.schema_migrations
    ADD CONSTRAINT schema_migrations_pkey PRIMARY KEY (version);


--
-- Name: sessions sessions_pkey; Type: CONSTRAINT; Schema: auth; Owner: supabase_auth_admin
--

ALTER TABLE ONLY auth.sessions
    ADD CONSTRAINT sessions_pkey PRIMARY KEY (id);


--
-- Name: sso_domains sso_domains_pkey; Type: CONSTRAINT; Schema: auth; Owner: supabase_auth_admin
--

ALTER TABLE ONLY auth.sso_domains
    ADD CONSTRAINT sso_domains_pkey PRIMARY KEY (id);


--
-- Name: sso_providers sso_providers_pkey; Type: CONSTRAINT; Schema: auth; Owner: supabase_auth_admin
--

ALTER TABLE ONLY auth.sso_providers
    ADD CONSTRAINT sso_providers_pkey PRIMARY KEY (id);


--
-- Name: users users_phone_key; Type: CONSTRAINT; Schema: auth; Owner: supabase_auth_admin
--

ALTER TABLE ONLY auth.users
    ADD CONSTRAINT users_phone_key UNIQUE (phone);


--
-- Name: users users_pkey; Type: CONSTRAINT; Schema: auth; Owner: supabase_auth_admin
--

ALTER TABLE ONLY auth.users
    ADD CONSTRAINT users_pkey PRIMARY KEY (id);


--
-- Name: webauthn_challenges webauthn_challenges_pkey; Type: CONSTRAINT; Schema: auth; Owner: supabase_auth_admin
--

ALTER TABLE ONLY auth.webauthn_challenges
    ADD CONSTRAINT webauthn_challenges_pkey PRIMARY KEY (id);


--
-- Name: webauthn_credentials webauthn_credentials_pkey; Type: CONSTRAINT; Schema: auth; Owner: supabase_auth_admin
--

ALTER TABLE ONLY auth.webauthn_credentials
    ADD CONSTRAINT webauthn_credentials_pkey PRIMARY KEY (id);


--
-- Name: ai_analysis_logs ai_analysis_logs_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.ai_analysis_logs
    ADD CONSTRAINT ai_analysis_logs_pkey PRIMARY KEY (id);


--
-- Name: ai_models ai_models_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.ai_models
    ADD CONSTRAINT ai_models_pkey PRIMARY KEY (id);


--
-- Name: alert_template_events alert_template_events_alert_template_id_event_type_id_key; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.alert_template_events
    ADD CONSTRAINT alert_template_events_alert_template_id_event_type_id_key UNIQUE (alert_template_id, event_type_id);


--
-- Name: alert_template_events alert_template_events_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.alert_template_events
    ADD CONSTRAINT alert_template_events_pkey PRIMARY KEY (id);


--
-- Name: alert_template_industries alert_template_industries_alert_template_id_industry_id_key; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.alert_template_industries
    ADD CONSTRAINT alert_template_industries_alert_template_id_industry_id_key UNIQUE (alert_template_id, industry_id);


--
-- Name: alert_template_industries alert_template_industries_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.alert_template_industries
    ADD CONSTRAINT alert_template_industries_pkey PRIMARY KEY (id);


--
-- Name: alert_templates alert_templates_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.alert_templates
    ADD CONSTRAINT alert_templates_pkey PRIMARY KEY (id);


--
-- Name: aman_instances aman_instances_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.aman_instances
    ADD CONSTRAINT aman_instances_pkey PRIMARY KEY (id);


--
-- Name: auto_sync_settings auto_sync_settings_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.auto_sync_settings
    ADD CONSTRAINT auto_sync_settings_pkey PRIMARY KEY (id);


--
-- Name: branch_roles branch_roles_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.branch_roles
    ADD CONSTRAINT branch_roles_pkey PRIMARY KEY (id);


--
-- Name: branches branches_device_token_key; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.branches
    ADD CONSTRAINT branches_device_token_key UNIQUE (device_token);


--
-- Name: branches branches_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.branches
    ADD CONSTRAINT branches_pkey PRIMARY KEY (id);


--
-- Name: camera_alert_assignments camera_alert_assignments_camera_id_alert_template_id_key; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.camera_alert_assignments
    ADD CONSTRAINT camera_alert_assignments_camera_id_alert_template_id_key UNIQUE (camera_id, alert_template_id);


--
-- Name: camera_alert_assignments camera_alert_assignments_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.camera_alert_assignments
    ADD CONSTRAINT camera_alert_assignments_pkey PRIMARY KEY (id);


--
-- Name: camera_event_assignments camera_event_assignments_camera_id_event_type_id_key; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.camera_event_assignments
    ADD CONSTRAINT camera_event_assignments_camera_id_event_type_id_key UNIQUE (camera_id, event_type_id);


--
-- Name: camera_event_assignments camera_event_assignments_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.camera_event_assignments
    ADD CONSTRAINT camera_event_assignments_pkey PRIMARY KEY (id);


--
-- Name: camera_sources camera_sources_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.camera_sources
    ADD CONSTRAINT camera_sources_pkey PRIMARY KEY (id);


--
-- Name: cameras cameras_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.cameras
    ADD CONSTRAINT cameras_pkey PRIMARY KEY (id);


--
-- Name: chat_messages chat_messages_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.chat_messages
    ADD CONSTRAINT chat_messages_pkey PRIMARY KEY (id);


--
-- Name: chat_thread_participants chat_thread_participants_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.chat_thread_participants
    ADD CONSTRAINT chat_thread_participants_pkey PRIMARY KEY (id);


--
-- Name: chat_thread_participants chat_thread_participants_thread_id_user_id_key; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.chat_thread_participants
    ADD CONSTRAINT chat_thread_participants_thread_id_user_id_key UNIQUE (thread_id, user_id);


--
-- Name: chat_threads chat_threads_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.chat_threads
    ADD CONSTRAINT chat_threads_pkey PRIMARY KEY (id);


--
-- Name: chatbot_knowledge_base chatbot_knowledge_base_language_content_type_key; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.chatbot_knowledge_base
    ADD CONSTRAINT chatbot_knowledge_base_language_content_type_key UNIQUE (language, content_type);


--
-- Name: chatbot_knowledge_base chatbot_knowledge_base_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.chatbot_knowledge_base
    ADD CONSTRAINT chatbot_knowledge_base_pkey PRIMARY KEY (id);


--
-- Name: detection_rules detection_rules_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.detection_rules
    ADD CONSTRAINT detection_rules_pkey PRIMARY KEY (id);


--
-- Name: event_types event_types_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.event_types
    ADD CONSTRAINT event_types_pkey PRIMARY KEY (id);


--
-- Name: events events_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.events
    ADD CONSTRAINT events_pkey PRIMARY KEY (id);


--
-- Name: form_assignments form_assignments_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.form_assignments
    ADD CONSTRAINT form_assignments_pkey PRIMARY KEY (id);


--
-- Name: form_distribution_settings form_distribution_settings_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.form_distribution_settings
    ADD CONSTRAINT form_distribution_settings_pkey PRIMARY KEY (id);


--
-- Name: form_submissions form_submissions_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.form_submissions
    ADD CONSTRAINT form_submissions_pkey PRIMARY KEY (id);


--
-- Name: frigate_alert_rules frigate_alert_rules_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.frigate_alert_rules
    ADD CONSTRAINT frigate_alert_rules_pkey PRIMARY KEY (id);


--
-- Name: frigate_deployed_models frigate_deployed_models_frigate_instance_id_model_id_key; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.frigate_deployed_models
    ADD CONSTRAINT frigate_deployed_models_frigate_instance_id_model_id_key UNIQUE (frigate_instance_id, model_id);


--
-- Name: frigate_deployed_models frigate_deployed_models_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.frigate_deployed_models
    ADD CONSTRAINT frigate_deployed_models_pkey PRIMARY KEY (id);


--
-- Name: frigate_exports frigate_exports_export_id_frigate_instance_id_key; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.frigate_exports
    ADD CONSTRAINT frigate_exports_export_id_frigate_instance_id_key UNIQUE (export_id, frigate_instance_id);


--
-- Name: frigate_exports frigate_exports_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.frigate_exports
    ADD CONSTRAINT frigate_exports_pkey PRIMARY KEY (id);


--
-- Name: frigate_faces frigate_faces_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.frigate_faces
    ADD CONSTRAINT frigate_faces_pkey PRIMARY KEY (id);


--
-- Name: frigate_instances frigate_instances_branch_id_name_key; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.frigate_instances
    ADD CONSTRAINT frigate_instances_branch_id_name_key UNIQUE (branch_id, name);


--
-- Name: frigate_instances frigate_instances_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.frigate_instances
    ADD CONSTRAINT frigate_instances_pkey PRIMARY KEY (id);


--
-- Name: frigate_license_plates frigate_license_plates_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.frigate_license_plates
    ADD CONSTRAINT frigate_license_plates_pkey PRIMARY KEY (id);


--
-- Name: frigate_model_deployments frigate_model_deployments_model_id_frigate_instance_id_key; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.frigate_model_deployments
    ADD CONSTRAINT frigate_model_deployments_model_id_frigate_instance_id_key UNIQUE (model_id, frigate_instance_id);


--
-- Name: frigate_model_deployments frigate_model_deployments_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.frigate_model_deployments
    ADD CONSTRAINT frigate_model_deployments_pkey PRIMARY KEY (id);


--
-- Name: frigate_model_registry frigate_model_registry_model_id_key; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.frigate_model_registry
    ADD CONSTRAINT frigate_model_registry_model_id_key UNIQUE (model_id);


--
-- Name: frigate_model_registry frigate_model_registry_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.frigate_model_registry
    ADD CONSTRAINT frigate_model_registry_pkey PRIMARY KEY (id);


--
-- Name: frigate_model_sync_log frigate_model_sync_log_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.frigate_model_sync_log
    ADD CONSTRAINT frigate_model_sync_log_pkey PRIMARY KEY (id);


--
-- Name: frigate_previews frigate_previews_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.frigate_previews
    ADD CONSTRAINT frigate_previews_pkey PRIMARY KEY (id);


--
-- Name: frigate_previews frigate_previews_preview_id_frigate_instance_id_key; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.frigate_previews
    ADD CONSTRAINT frigate_previews_preview_id_frigate_instance_id_key UNIQUE (preview_id, frigate_instance_id);


--
-- Name: frigate_recordings frigate_recordings_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.frigate_recordings
    ADD CONSTRAINT frigate_recordings_pkey PRIMARY KEY (id);


--
-- Name: frigate_recordings frigate_recordings_recording_id_frigate_instance_id_key; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.frigate_recordings
    ADD CONSTRAINT frigate_recordings_recording_id_frigate_instance_id_key UNIQUE (recording_id, frigate_instance_id);


--
-- Name: frigate_reviews frigate_reviews_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.frigate_reviews
    ADD CONSTRAINT frigate_reviews_pkey PRIMARY KEY (id);


--
-- Name: frigate_reviews frigate_reviews_review_id_frigate_instance_id_key; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.frigate_reviews
    ADD CONSTRAINT frigate_reviews_review_id_frigate_instance_id_key UNIQUE (review_id, frigate_instance_id);


--
-- Name: frigate_stats_history frigate_stats_history_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.frigate_stats_history
    ADD CONSTRAINT frigate_stats_history_pkey PRIMARY KEY (id);


--
-- Name: frigate_sync_logs frigate_sync_logs_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.frigate_sync_logs
    ADD CONSTRAINT frigate_sync_logs_pkey PRIMARY KEY (id);


--
-- Name: frigate_timeline frigate_timeline_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.frigate_timeline
    ADD CONSTRAINT frigate_timeline_pkey PRIMARY KEY (id);


--
-- Name: frigate_triggers frigate_triggers_frigate_instance_id_camera_name_key; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.frigate_triggers
    ADD CONSTRAINT frigate_triggers_frigate_instance_id_camera_name_key UNIQUE (frigate_instance_id, camera, name);


--
-- Name: frigate_triggers frigate_triggers_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.frigate_triggers
    ADD CONSTRAINT frigate_triggers_pkey PRIMARY KEY (id);


--
-- Name: frigate_zones frigate_zones_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.frigate_zones
    ADD CONSTRAINT frigate_zones_pkey PRIMARY KEY (id);


--
-- Name: health_alerts health_alerts_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.health_alerts
    ADD CONSTRAINT health_alerts_pkey PRIMARY KEY (id);


--
-- Name: industries industries_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.industries
    ADD CONSTRAINT industries_pkey PRIMARY KEY (id);


--
-- Name: legal_documents legal_documents_document_type_key; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.legal_documents
    ADD CONSTRAINT legal_documents_document_type_key UNIQUE (document_type);


--
-- Name: legal_documents legal_documents_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.legal_documents
    ADD CONSTRAINT legal_documents_pkey PRIMARY KEY (id);


--
-- Name: network_scan_results network_scan_results_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.network_scan_results
    ADD CONSTRAINT network_scan_results_pkey PRIMARY KEY (id);


--
-- Name: notification_labels notification_labels_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.notification_labels
    ADD CONSTRAINT notification_labels_pkey PRIMARY KEY (id);


--
-- Name: notification_methods notification_methods_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.notification_methods
    ADD CONSTRAINT notification_methods_pkey PRIMARY KEY (id);


--
-- Name: organization_settings organization_settings_organization_id_setting_key_key; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.organization_settings
    ADD CONSTRAINT organization_settings_organization_id_setting_key_key UNIQUE (organization_id, setting_key);


--
-- Name: organization_settings organization_settings_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.organization_settings
    ADD CONSTRAINT organization_settings_pkey PRIMARY KEY (id);


--
-- Name: organizations organizations_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.organizations
    ADD CONSTRAINT organizations_pkey PRIMARY KEY (id);


--
-- Name: pinned_dashboards pinned_dashboards_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.pinned_dashboards
    ADD CONSTRAINT pinned_dashboards_pkey PRIMARY KEY (id);


--
-- Name: pinned_labels pinned_labels_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.pinned_labels
    ADD CONSTRAINT pinned_labels_pkey PRIMARY KEY (id);


--
-- Name: screen_permissions screen_permissions_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.screen_permissions
    ADD CONSTRAINT screen_permissions_pkey PRIMARY KEY (id);


--
-- Name: screen_permissions screen_permissions_screen_key_key; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.screen_permissions
    ADD CONSTRAINT screen_permissions_screen_key_key UNIQUE (screen_key);


--
-- Name: security_zones security_zones_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.security_zones
    ADD CONSTRAINT security_zones_pkey PRIMARY KEY (id);


--
-- Name: storage_configs storage_configs_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.storage_configs
    ADD CONSTRAINT storage_configs_pkey PRIMARY KEY (id);


--
-- Name: students students_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.students
    ADD CONSTRAINT students_pkey PRIMARY KEY (id);


--
-- Name: students students_wearable_id_key; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.students
    ADD CONSTRAINT students_wearable_id_key UNIQUE (wearable_id);


--
-- Name: subscribers subscribers_email_key; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.subscribers
    ADD CONSTRAINT subscribers_email_key UNIQUE (email);


--
-- Name: subscribers subscribers_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.subscribers
    ADD CONSTRAINT subscribers_pkey PRIMARY KEY (id);


--
-- Name: system_settings system_settings_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.system_settings
    ADD CONSTRAINT system_settings_pkey PRIMARY KEY (id);


--
-- Name: system_settings system_settings_setting_key_key; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.system_settings
    ADD CONSTRAINT system_settings_setting_key_key UNIQUE (setting_key);


--
-- Name: user_branch_access user_branch_access_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.user_branch_access
    ADD CONSTRAINT user_branch_access_pkey PRIMARY KEY (id);


--
-- Name: user_branch_access user_branch_access_user_id_branch_id_key; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.user_branch_access
    ADD CONSTRAINT user_branch_access_user_id_branch_id_key UNIQUE (user_id, branch_id);


--
-- Name: user_group_members user_group_members_group_id_user_role_id_key; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.user_group_members
    ADD CONSTRAINT user_group_members_group_id_user_role_id_key UNIQUE (group_id, user_role_id);


--
-- Name: user_group_members user_group_members_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.user_group_members
    ADD CONSTRAINT user_group_members_pkey PRIMARY KEY (id);


--
-- Name: user_groups user_groups_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.user_groups
    ADD CONSTRAINT user_groups_pkey PRIMARY KEY (id);


--
-- Name: user_preferences user_preferences_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.user_preferences
    ADD CONSTRAINT user_preferences_pkey PRIMARY KEY (id);


--
-- Name: user_preferences user_preferences_user_id_key; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.user_preferences
    ADD CONSTRAINT user_preferences_user_id_key UNIQUE (user_id);


--
-- Name: user_roles user_roles_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.user_roles
    ADD CONSTRAINT user_roles_pkey PRIMARY KEY (id);


--
-- Name: user_roles user_roles_user_id_organization_id_key; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.user_roles
    ADD CONSTRAINT user_roles_user_id_organization_id_key UNIQUE (user_id, organization_id);


--
-- Name: workflow_forms workflow_forms_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.workflow_forms
    ADD CONSTRAINT workflow_forms_pkey PRIMARY KEY (id);


--
-- Name: messages messages_pkey; Type: CONSTRAINT; Schema: realtime; Owner: supabase_realtime_admin
--

ALTER TABLE ONLY realtime.messages
    ADD CONSTRAINT messages_pkey PRIMARY KEY (id, inserted_at);


--
-- Name: messages_2026_07_02 messages_2026_07_02_pkey; Type: CONSTRAINT; Schema: realtime; Owner: supabase_admin
--

ALTER TABLE ONLY realtime.messages_2026_07_02
    ADD CONSTRAINT messages_2026_07_02_pkey PRIMARY KEY (id, inserted_at);


--
-- Name: messages_2026_07_03 messages_2026_07_03_pkey; Type: CONSTRAINT; Schema: realtime; Owner: supabase_admin
--

ALTER TABLE ONLY realtime.messages_2026_07_03
    ADD CONSTRAINT messages_2026_07_03_pkey PRIMARY KEY (id, inserted_at);


--
-- Name: messages_2026_07_04 messages_2026_07_04_pkey; Type: CONSTRAINT; Schema: realtime; Owner: supabase_admin
--

ALTER TABLE ONLY realtime.messages_2026_07_04
    ADD CONSTRAINT messages_2026_07_04_pkey PRIMARY KEY (id, inserted_at);


--
-- Name: messages_2026_07_05 messages_2026_07_05_pkey; Type: CONSTRAINT; Schema: realtime; Owner: supabase_admin
--

ALTER TABLE ONLY realtime.messages_2026_07_05
    ADD CONSTRAINT messages_2026_07_05_pkey PRIMARY KEY (id, inserted_at);


--
-- Name: messages_2026_07_06 messages_2026_07_06_pkey; Type: CONSTRAINT; Schema: realtime; Owner: supabase_admin
--

ALTER TABLE ONLY realtime.messages_2026_07_06
    ADD CONSTRAINT messages_2026_07_06_pkey PRIMARY KEY (id, inserted_at);


--
-- Name: messages_2026_07_07 messages_2026_07_07_pkey; Type: CONSTRAINT; Schema: realtime; Owner: supabase_admin
--

ALTER TABLE ONLY realtime.messages_2026_07_07
    ADD CONSTRAINT messages_2026_07_07_pkey PRIMARY KEY (id, inserted_at);


--
-- Name: messages_2026_07_08 messages_2026_07_08_pkey; Type: CONSTRAINT; Schema: realtime; Owner: supabase_admin
--

ALTER TABLE ONLY realtime.messages_2026_07_08
    ADD CONSTRAINT messages_2026_07_08_pkey PRIMARY KEY (id, inserted_at);


--
-- Name: messages messages_payload_exclusive; Type: CHECK CONSTRAINT; Schema: realtime; Owner: supabase_realtime_admin
--

ALTER TABLE realtime.messages
    ADD CONSTRAINT messages_payload_exclusive CHECK (((payload IS NULL) OR (binary_payload IS NULL))) NOT VALID;


--
-- Name: subscription pk_subscription; Type: CONSTRAINT; Schema: realtime; Owner: supabase_admin
--

ALTER TABLE ONLY realtime.subscription
    ADD CONSTRAINT pk_subscription PRIMARY KEY (id);


--
-- Name: schema_migrations schema_migrations_pkey; Type: CONSTRAINT; Schema: realtime; Owner: supabase_admin
--

ALTER TABLE ONLY realtime.schema_migrations
    ADD CONSTRAINT schema_migrations_pkey PRIMARY KEY (version);


--
-- Name: buckets_analytics buckets_analytics_pkey; Type: CONSTRAINT; Schema: storage; Owner: supabase_storage_admin
--

ALTER TABLE ONLY storage.buckets_analytics
    ADD CONSTRAINT buckets_analytics_pkey PRIMARY KEY (id);


--
-- Name: buckets buckets_pkey; Type: CONSTRAINT; Schema: storage; Owner: supabase_storage_admin
--

ALTER TABLE ONLY storage.buckets
    ADD CONSTRAINT buckets_pkey PRIMARY KEY (id);


--
-- Name: buckets_vectors buckets_vectors_pkey; Type: CONSTRAINT; Schema: storage; Owner: supabase_storage_admin
--

ALTER TABLE ONLY storage.buckets_vectors
    ADD CONSTRAINT buckets_vectors_pkey PRIMARY KEY (id);


--
-- Name: iceberg_namespaces iceberg_namespaces_pkey; Type: CONSTRAINT; Schema: storage; Owner: supabase_storage_admin
--

ALTER TABLE ONLY storage.iceberg_namespaces
    ADD CONSTRAINT iceberg_namespaces_pkey PRIMARY KEY (id);


--
-- Name: iceberg_tables iceberg_tables_pkey; Type: CONSTRAINT; Schema: storage; Owner: supabase_storage_admin
--

ALTER TABLE ONLY storage.iceberg_tables
    ADD CONSTRAINT iceberg_tables_pkey PRIMARY KEY (id);


--
-- Name: migrations migrations_name_key; Type: CONSTRAINT; Schema: storage; Owner: supabase_storage_admin
--

ALTER TABLE ONLY storage.migrations
    ADD CONSTRAINT migrations_name_key UNIQUE (name);


--
-- Name: migrations migrations_pkey; Type: CONSTRAINT; Schema: storage; Owner: supabase_storage_admin
--

ALTER TABLE ONLY storage.migrations
    ADD CONSTRAINT migrations_pkey PRIMARY KEY (id);


--
-- Name: objects objects_pkey; Type: CONSTRAINT; Schema: storage; Owner: supabase_storage_admin
--

ALTER TABLE ONLY storage.objects
    ADD CONSTRAINT objects_pkey PRIMARY KEY (id);


--
-- Name: s3_multipart_uploads_parts s3_multipart_uploads_parts_pkey; Type: CONSTRAINT; Schema: storage; Owner: supabase_storage_admin
--

ALTER TABLE ONLY storage.s3_multipart_uploads_parts
    ADD CONSTRAINT s3_multipart_uploads_parts_pkey PRIMARY KEY (id);


--
-- Name: s3_multipart_uploads s3_multipart_uploads_pkey; Type: CONSTRAINT; Schema: storage; Owner: supabase_storage_admin
--

ALTER TABLE ONLY storage.s3_multipart_uploads
    ADD CONSTRAINT s3_multipart_uploads_pkey PRIMARY KEY (id);


--
-- Name: vector_indexes vector_indexes_pkey; Type: CONSTRAINT; Schema: storage; Owner: supabase_storage_admin
--

ALTER TABLE ONLY storage.vector_indexes
    ADD CONSTRAINT vector_indexes_pkey PRIMARY KEY (id);


--
-- Name: hooks hooks_pkey; Type: CONSTRAINT; Schema: supabase_functions; Owner: supabase_functions_admin
--

ALTER TABLE ONLY supabase_functions.hooks
    ADD CONSTRAINT hooks_pkey PRIMARY KEY (id);


--
-- Name: migrations migrations_pkey; Type: CONSTRAINT; Schema: supabase_functions; Owner: supabase_functions_admin
--

ALTER TABLE ONLY supabase_functions.migrations
    ADD CONSTRAINT migrations_pkey PRIMARY KEY (version);


--
-- Name: schema_migrations schema_migrations_pkey; Type: CONSTRAINT; Schema: supabase_migrations; Owner: postgres
--

ALTER TABLE ONLY supabase_migrations.schema_migrations
    ADD CONSTRAINT schema_migrations_pkey PRIMARY KEY (version);


--
-- Name: extensions_tenant_external_id_index; Type: INDEX; Schema: _realtime; Owner: supabase_admin
--

CREATE INDEX extensions_tenant_external_id_index ON _realtime.extensions USING btree (tenant_external_id);


--
-- Name: extensions_tenant_external_id_type_index; Type: INDEX; Schema: _realtime; Owner: supabase_admin
--

CREATE UNIQUE INDEX extensions_tenant_external_id_type_index ON _realtime.extensions USING btree (tenant_external_id, type);


--
-- Name: feature_flags_name_index; Type: INDEX; Schema: _realtime; Owner: supabase_admin
--

CREATE UNIQUE INDEX feature_flags_name_index ON _realtime.feature_flags USING btree (name);


--
-- Name: tenants_external_id_index; Type: INDEX; Schema: _realtime; Owner: supabase_admin
--

CREATE UNIQUE INDEX tenants_external_id_index ON _realtime.tenants USING btree (external_id);


--
-- Name: audit_logs_instance_id_idx; Type: INDEX; Schema: auth; Owner: supabase_auth_admin
--

CREATE INDEX audit_logs_instance_id_idx ON auth.audit_log_entries USING btree (instance_id);


--
-- Name: confirmation_token_idx; Type: INDEX; Schema: auth; Owner: supabase_auth_admin
--

CREATE UNIQUE INDEX confirmation_token_idx ON auth.users USING btree (confirmation_token) WHERE ((confirmation_token)::text !~ '^[0-9 ]*$'::text);


--
-- Name: custom_oauth_providers_created_at_idx; Type: INDEX; Schema: auth; Owner: supabase_auth_admin
--

CREATE INDEX custom_oauth_providers_created_at_idx ON auth.custom_oauth_providers USING btree (created_at);


--
-- Name: custom_oauth_providers_enabled_idx; Type: INDEX; Schema: auth; Owner: supabase_auth_admin
--

CREATE INDEX custom_oauth_providers_enabled_idx ON auth.custom_oauth_providers USING btree (enabled);


--
-- Name: custom_oauth_providers_identifier_idx; Type: INDEX; Schema: auth; Owner: supabase_auth_admin
--

CREATE INDEX custom_oauth_providers_identifier_idx ON auth.custom_oauth_providers USING btree (identifier);


--
-- Name: custom_oauth_providers_provider_type_idx; Type: INDEX; Schema: auth; Owner: supabase_auth_admin
--

CREATE INDEX custom_oauth_providers_provider_type_idx ON auth.custom_oauth_providers USING btree (provider_type);


--
-- Name: email_change_token_current_idx; Type: INDEX; Schema: auth; Owner: supabase_auth_admin
--

CREATE UNIQUE INDEX email_change_token_current_idx ON auth.users USING btree (email_change_token_current) WHERE ((email_change_token_current)::text !~ '^[0-9 ]*$'::text);


--
-- Name: email_change_token_new_idx; Type: INDEX; Schema: auth; Owner: supabase_auth_admin
--

CREATE UNIQUE INDEX email_change_token_new_idx ON auth.users USING btree (email_change_token_new) WHERE ((email_change_token_new)::text !~ '^[0-9 ]*$'::text);


--
-- Name: factor_id_created_at_idx; Type: INDEX; Schema: auth; Owner: supabase_auth_admin
--

CREATE INDEX factor_id_created_at_idx ON auth.mfa_factors USING btree (user_id, created_at);


--
-- Name: flow_state_created_at_idx; Type: INDEX; Schema: auth; Owner: supabase_auth_admin
--

CREATE INDEX flow_state_created_at_idx ON auth.flow_state USING btree (created_at DESC);


--
-- Name: identities_email_idx; Type: INDEX; Schema: auth; Owner: supabase_auth_admin
--

CREATE INDEX identities_email_idx ON auth.identities USING btree (email text_pattern_ops);


--
-- Name: INDEX identities_email_idx; Type: COMMENT; Schema: auth; Owner: supabase_auth_admin
--

COMMENT ON INDEX auth.identities_email_idx IS 'Auth: Ensures indexed queries on the email column';


--
-- Name: identities_user_id_idx; Type: INDEX; Schema: auth; Owner: supabase_auth_admin
--

CREATE INDEX identities_user_id_idx ON auth.identities USING btree (user_id);


--
-- Name: idx_auth_code; Type: INDEX; Schema: auth; Owner: supabase_auth_admin
--

CREATE INDEX idx_auth_code ON auth.flow_state USING btree (auth_code);


--
-- Name: idx_oauth_client_states_created_at; Type: INDEX; Schema: auth; Owner: supabase_auth_admin
--

CREATE INDEX idx_oauth_client_states_created_at ON auth.oauth_client_states USING btree (created_at);


--
-- Name: idx_user_id_auth_method; Type: INDEX; Schema: auth; Owner: supabase_auth_admin
--

CREATE INDEX idx_user_id_auth_method ON auth.flow_state USING btree (user_id, authentication_method);


--
-- Name: mfa_challenge_created_at_idx; Type: INDEX; Schema: auth; Owner: supabase_auth_admin
--

CREATE INDEX mfa_challenge_created_at_idx ON auth.mfa_challenges USING btree (created_at DESC);


--
-- Name: mfa_factors_user_friendly_name_unique; Type: INDEX; Schema: auth; Owner: supabase_auth_admin
--

CREATE UNIQUE INDEX mfa_factors_user_friendly_name_unique ON auth.mfa_factors USING btree (friendly_name, user_id) WHERE (TRIM(BOTH FROM friendly_name) <> ''::text);


--
-- Name: mfa_factors_user_id_idx; Type: INDEX; Schema: auth; Owner: supabase_auth_admin
--

CREATE INDEX mfa_factors_user_id_idx ON auth.mfa_factors USING btree (user_id);


--
-- Name: oauth_auth_pending_exp_idx; Type: INDEX; Schema: auth; Owner: supabase_auth_admin
--

CREATE INDEX oauth_auth_pending_exp_idx ON auth.oauth_authorizations USING btree (expires_at) WHERE (status = 'pending'::auth.oauth_authorization_status);


--
-- Name: oauth_clients_deleted_at_idx; Type: INDEX; Schema: auth; Owner: supabase_auth_admin
--

CREATE INDEX oauth_clients_deleted_at_idx ON auth.oauth_clients USING btree (deleted_at);


--
-- Name: oauth_consents_active_client_idx; Type: INDEX; Schema: auth; Owner: supabase_auth_admin
--

CREATE INDEX oauth_consents_active_client_idx ON auth.oauth_consents USING btree (client_id) WHERE (revoked_at IS NULL);


--
-- Name: oauth_consents_active_user_client_idx; Type: INDEX; Schema: auth; Owner: supabase_auth_admin
--

CREATE INDEX oauth_consents_active_user_client_idx ON auth.oauth_consents USING btree (user_id, client_id) WHERE (revoked_at IS NULL);


--
-- Name: oauth_consents_user_order_idx; Type: INDEX; Schema: auth; Owner: supabase_auth_admin
--

CREATE INDEX oauth_consents_user_order_idx ON auth.oauth_consents USING btree (user_id, granted_at DESC);


--
-- Name: one_time_tokens_relates_to_hash_idx; Type: INDEX; Schema: auth; Owner: supabase_auth_admin
--

CREATE INDEX one_time_tokens_relates_to_hash_idx ON auth.one_time_tokens USING hash (relates_to);


--
-- Name: one_time_tokens_token_hash_hash_idx; Type: INDEX; Schema: auth; Owner: supabase_auth_admin
--

CREATE INDEX one_time_tokens_token_hash_hash_idx ON auth.one_time_tokens USING hash (token_hash);


--
-- Name: one_time_tokens_user_id_token_type_key; Type: INDEX; Schema: auth; Owner: supabase_auth_admin
--

CREATE UNIQUE INDEX one_time_tokens_user_id_token_type_key ON auth.one_time_tokens USING btree (user_id, token_type);


--
-- Name: reauthentication_token_idx; Type: INDEX; Schema: auth; Owner: supabase_auth_admin
--

CREATE UNIQUE INDEX reauthentication_token_idx ON auth.users USING btree (reauthentication_token) WHERE ((reauthentication_token)::text !~ '^[0-9 ]*$'::text);


--
-- Name: recovery_token_idx; Type: INDEX; Schema: auth; Owner: supabase_auth_admin
--

CREATE UNIQUE INDEX recovery_token_idx ON auth.users USING btree (recovery_token) WHERE ((recovery_token)::text !~ '^[0-9 ]*$'::text);


--
-- Name: refresh_tokens_instance_id_idx; Type: INDEX; Schema: auth; Owner: supabase_auth_admin
--

CREATE INDEX refresh_tokens_instance_id_idx ON auth.refresh_tokens USING btree (instance_id);


--
-- Name: refresh_tokens_instance_id_user_id_idx; Type: INDEX; Schema: auth; Owner: supabase_auth_admin
--

CREATE INDEX refresh_tokens_instance_id_user_id_idx ON auth.refresh_tokens USING btree (instance_id, user_id);


--
-- Name: refresh_tokens_parent_idx; Type: INDEX; Schema: auth; Owner: supabase_auth_admin
--

CREATE INDEX refresh_tokens_parent_idx ON auth.refresh_tokens USING btree (parent);


--
-- Name: refresh_tokens_session_id_revoked_idx; Type: INDEX; Schema: auth; Owner: supabase_auth_admin
--

CREATE INDEX refresh_tokens_session_id_revoked_idx ON auth.refresh_tokens USING btree (session_id, revoked);


--
-- Name: refresh_tokens_updated_at_idx; Type: INDEX; Schema: auth; Owner: supabase_auth_admin
--

CREATE INDEX refresh_tokens_updated_at_idx ON auth.refresh_tokens USING btree (updated_at DESC);


--
-- Name: saml_providers_sso_provider_id_idx; Type: INDEX; Schema: auth; Owner: supabase_auth_admin
--

CREATE INDEX saml_providers_sso_provider_id_idx ON auth.saml_providers USING btree (sso_provider_id);


--
-- Name: saml_relay_states_created_at_idx; Type: INDEX; Schema: auth; Owner: supabase_auth_admin
--

CREATE INDEX saml_relay_states_created_at_idx ON auth.saml_relay_states USING btree (created_at DESC);


--
-- Name: saml_relay_states_for_email_idx; Type: INDEX; Schema: auth; Owner: supabase_auth_admin
--

CREATE INDEX saml_relay_states_for_email_idx ON auth.saml_relay_states USING btree (for_email);


--
-- Name: saml_relay_states_sso_provider_id_idx; Type: INDEX; Schema: auth; Owner: supabase_auth_admin
--

CREATE INDEX saml_relay_states_sso_provider_id_idx ON auth.saml_relay_states USING btree (sso_provider_id);


--
-- Name: sessions_not_after_idx; Type: INDEX; Schema: auth; Owner: supabase_auth_admin
--

CREATE INDEX sessions_not_after_idx ON auth.sessions USING btree (not_after DESC);


--
-- Name: sessions_oauth_client_id_idx; Type: INDEX; Schema: auth; Owner: supabase_auth_admin
--

CREATE INDEX sessions_oauth_client_id_idx ON auth.sessions USING btree (oauth_client_id);


--
-- Name: sessions_user_id_idx; Type: INDEX; Schema: auth; Owner: supabase_auth_admin
--

CREATE INDEX sessions_user_id_idx ON auth.sessions USING btree (user_id);


--
-- Name: sso_domains_domain_idx; Type: INDEX; Schema: auth; Owner: supabase_auth_admin
--

CREATE UNIQUE INDEX sso_domains_domain_idx ON auth.sso_domains USING btree (lower(domain));


--
-- Name: sso_domains_sso_provider_id_idx; Type: INDEX; Schema: auth; Owner: supabase_auth_admin
--

CREATE INDEX sso_domains_sso_provider_id_idx ON auth.sso_domains USING btree (sso_provider_id);


--
-- Name: sso_providers_resource_id_idx; Type: INDEX; Schema: auth; Owner: supabase_auth_admin
--

CREATE UNIQUE INDEX sso_providers_resource_id_idx ON auth.sso_providers USING btree (lower(resource_id));


--
-- Name: sso_providers_resource_id_pattern_idx; Type: INDEX; Schema: auth; Owner: supabase_auth_admin
--

CREATE INDEX sso_providers_resource_id_pattern_idx ON auth.sso_providers USING btree (resource_id text_pattern_ops);


--
-- Name: unique_phone_factor_per_user; Type: INDEX; Schema: auth; Owner: supabase_auth_admin
--

CREATE UNIQUE INDEX unique_phone_factor_per_user ON auth.mfa_factors USING btree (user_id, phone);


--
-- Name: user_id_created_at_idx; Type: INDEX; Schema: auth; Owner: supabase_auth_admin
--

CREATE INDEX user_id_created_at_idx ON auth.sessions USING btree (user_id, created_at);


--
-- Name: users_email_partial_key; Type: INDEX; Schema: auth; Owner: supabase_auth_admin
--

CREATE UNIQUE INDEX users_email_partial_key ON auth.users USING btree (email) WHERE (is_sso_user = false);


--
-- Name: INDEX users_email_partial_key; Type: COMMENT; Schema: auth; Owner: supabase_auth_admin
--

COMMENT ON INDEX auth.users_email_partial_key IS 'Auth: A partial unique index that applies only when is_sso_user is false';


--
-- Name: users_instance_id_email_idx; Type: INDEX; Schema: auth; Owner: supabase_auth_admin
--

CREATE INDEX users_instance_id_email_idx ON auth.users USING btree (instance_id, lower((email)::text));


--
-- Name: users_instance_id_idx; Type: INDEX; Schema: auth; Owner: supabase_auth_admin
--

CREATE INDEX users_instance_id_idx ON auth.users USING btree (instance_id);


--
-- Name: users_is_anonymous_idx; Type: INDEX; Schema: auth; Owner: supabase_auth_admin
--

CREATE INDEX users_is_anonymous_idx ON auth.users USING btree (is_anonymous);


--
-- Name: webauthn_challenges_expires_at_idx; Type: INDEX; Schema: auth; Owner: supabase_auth_admin
--

CREATE INDEX webauthn_challenges_expires_at_idx ON auth.webauthn_challenges USING btree (expires_at);


--
-- Name: webauthn_challenges_user_id_idx; Type: INDEX; Schema: auth; Owner: supabase_auth_admin
--

CREATE INDEX webauthn_challenges_user_id_idx ON auth.webauthn_challenges USING btree (user_id);


--
-- Name: webauthn_credentials_credential_id_key; Type: INDEX; Schema: auth; Owner: supabase_auth_admin
--

CREATE UNIQUE INDEX webauthn_credentials_credential_id_key ON auth.webauthn_credentials USING btree (credential_id);


--
-- Name: webauthn_credentials_user_id_idx; Type: INDEX; Schema: auth; Owner: supabase_auth_admin
--

CREATE INDEX webauthn_credentials_user_id_idx ON auth.webauthn_credentials USING btree (user_id);


--
-- Name: idx_aman_instances_branch; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX idx_aman_instances_branch ON public.aman_instances USING btree (branch_id);


--
-- Name: idx_aman_instances_org; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX idx_aman_instances_org ON public.aman_instances USING btree (organization_id);


--
-- Name: idx_cameras_branch_id; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX idx_cameras_branch_id ON public.cameras USING btree (branch_id);


--
-- Name: idx_chat_messages_thread_created; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX idx_chat_messages_thread_created ON public.chat_messages USING btree (thread_id, created_at);


--
-- Name: idx_chat_participants_thread; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX idx_chat_participants_thread ON public.chat_thread_participants USING btree (thread_id);


--
-- Name: idx_chat_participants_user; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX idx_chat_participants_user ON public.chat_thread_participants USING btree (user_id);


--
-- Name: idx_chat_threads_org; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX idx_chat_threads_org ON public.chat_threads USING btree (organization_id);


--
-- Name: idx_chatbot_knowledge_active; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX idx_chatbot_knowledge_active ON public.chatbot_knowledge_base USING btree (is_active);


--
-- Name: idx_chatbot_knowledge_language_type; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX idx_chatbot_knowledge_language_type ON public.chatbot_knowledge_base USING btree (language, content_type);


--
-- Name: idx_event_types_feature_key; Type: INDEX; Schema: public; Owner: postgres
--

CREATE UNIQUE INDEX idx_event_types_feature_key ON public.event_types USING btree (feature_key) WHERE (feature_key IS NOT NULL);


--
-- Name: idx_events_camera_id; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX idx_events_camera_id ON public.events USING btree (camera_id);


--
-- Name: idx_events_detected_at; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX idx_events_detected_at ON public.events USING btree (detected_at);


--
-- Name: idx_events_face_id; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX idx_events_face_id ON public.events USING btree (face_id) WHERE (face_id IS NOT NULL);


--
-- Name: idx_events_frigate_id; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX idx_events_frigate_id ON public.events USING btree (frigate_id) WHERE (frigate_id IS NOT NULL);


--
-- Name: idx_events_license_plate; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX idx_events_license_plate ON public.events USING btree (license_plate) WHERE (license_plate IS NOT NULL);


--
-- Name: idx_frigate_deployed_models_category; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX idx_frigate_deployed_models_category ON public.frigate_deployed_models USING btree (category);


--
-- Name: idx_frigate_deployed_models_instance; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX idx_frigate_deployed_models_instance ON public.frigate_deployed_models USING btree (frigate_instance_id);


--
-- Name: idx_frigate_deployed_models_status; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX idx_frigate_deployed_models_status ON public.frigate_deployed_models USING btree (status);


--
-- Name: idx_frigate_exports_instance_camera; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX idx_frigate_exports_instance_camera ON public.frigate_exports USING btree (frigate_instance_id, camera);


--
-- Name: idx_frigate_exports_status; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX idx_frigate_exports_status ON public.frigate_exports USING btree (status);


--
-- Name: idx_frigate_faces_camera_id; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX idx_frigate_faces_camera_id ON public.frigate_faces USING btree (camera_id);


--
-- Name: idx_frigate_faces_label; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX idx_frigate_faces_label ON public.frigate_faces USING btree (label);


--
-- Name: idx_frigate_license_plates_camera_id; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX idx_frigate_license_plates_camera_id ON public.frigate_license_plates USING btree (camera_id);


--
-- Name: idx_frigate_license_plates_instance; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX idx_frigate_license_plates_instance ON public.frigate_license_plates USING btree (frigate_instance_id) WHERE (frigate_instance_id IS NOT NULL);


--
-- Name: idx_frigate_license_plates_plate_number; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX idx_frigate_license_plates_plate_number ON public.frigate_license_plates USING btree (plate_number);


--
-- Name: idx_frigate_license_plates_watch; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX idx_frigate_license_plates_watch ON public.frigate_license_plates USING btree (is_watchlisted) WHERE (is_watchlisted = true);


--
-- Name: idx_frigate_previews_instance_camera; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX idx_frigate_previews_instance_camera ON public.frigate_previews USING btree (frigate_instance_id, camera);


--
-- Name: idx_frigate_previews_time; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX idx_frigate_previews_time ON public.frigate_previews USING btree (start_time, end_time);


--
-- Name: idx_frigate_recordings_instance_camera; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX idx_frigate_recordings_instance_camera ON public.frigate_recordings USING btree (frigate_instance_id, camera);


--
-- Name: idx_frigate_recordings_time; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX idx_frigate_recordings_time ON public.frigate_recordings USING btree (start_time, end_time);


--
-- Name: idx_frigate_reviews_instance_camera; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX idx_frigate_reviews_instance_camera ON public.frigate_reviews USING btree (frigate_instance_id, camera);


--
-- Name: idx_frigate_reviews_reviewed; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX idx_frigate_reviews_reviewed ON public.frigate_reviews USING btree (has_been_reviewed);


--
-- Name: idx_frigate_reviews_reviewed_new; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX idx_frigate_reviews_reviewed_new ON public.frigate_reviews USING btree (reviewed);


--
-- Name: idx_frigate_reviews_severity; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX idx_frigate_reviews_severity ON public.frigate_reviews USING btree (severity);


--
-- Name: idx_frigate_stats_history_instance; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX idx_frigate_stats_history_instance ON public.frigate_stats_history USING btree (frigate_instance_id);


--
-- Name: idx_frigate_stats_history_recorded; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX idx_frigate_stats_history_recorded ON public.frigate_stats_history USING btree (recorded_at DESC);


--
-- Name: idx_frigate_sync_logs_instance; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX idx_frigate_sync_logs_instance ON public.frigate_sync_logs USING btree (frigate_instance_id);


--
-- Name: idx_frigate_sync_logs_started; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX idx_frigate_sync_logs_started ON public.frigate_sync_logs USING btree (started_at DESC);


--
-- Name: idx_frigate_timeline_camera_id; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX idx_frigate_timeline_camera_id ON public.frigate_timeline USING btree (camera_id);


--
-- Name: idx_frigate_timeline_time; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX idx_frigate_timeline_time ON public.frigate_timeline USING btree (start_time, end_time);


--
-- Name: idx_frigate_triggers_instance; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX idx_frigate_triggers_instance ON public.frigate_triggers USING btree (frigate_instance_id);


--
-- Name: idx_frigate_zones_camera_id; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX idx_frigate_zones_camera_id ON public.frigate_zones USING btree (camera_id);


--
-- Name: idx_health_alerts_student; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX idx_health_alerts_student ON public.health_alerts USING btree (student_id);


--
-- Name: idx_health_alerts_time; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX idx_health_alerts_time ON public.health_alerts USING btree (detected_at DESC);


--
-- Name: idx_model_deployments_instance; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX idx_model_deployments_instance ON public.frigate_model_deployments USING btree (frigate_instance_id);


--
-- Name: idx_model_deployments_model; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX idx_model_deployments_model ON public.frigate_model_deployments USING btree (model_id);


--
-- Name: idx_model_deployments_status; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX idx_model_deployments_status ON public.frigate_model_deployments USING btree (deployment_status);


--
-- Name: idx_model_registry_category; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX idx_model_registry_category ON public.frigate_model_registry USING btree (category);


--
-- Name: idx_model_registry_status; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX idx_model_registry_status ON public.frigate_model_registry USING btree (status);


--
-- Name: idx_org_settings_org_key; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX idx_org_settings_org_key ON public.organization_settings USING btree (organization_id, setting_key);


--
-- Name: idx_pinned_dashboards_user_id; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX idx_pinned_dashboards_user_id ON public.pinned_dashboards USING btree (user_id);


--
-- Name: idx_pinned_labels_user_id; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX idx_pinned_labels_user_id ON public.pinned_labels USING btree (user_id);


--
-- Name: idx_security_zones_active; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX idx_security_zones_active ON public.security_zones USING btree (active);


--
-- Name: idx_sync_log_instance; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX idx_sync_log_instance ON public.frigate_model_sync_log USING btree (frigate_instance_id);


--
-- Name: idx_sync_log_started; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX idx_sync_log_started ON public.frigate_model_sync_log USING btree (started_at DESC);


--
-- Name: idx_system_settings_key; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX idx_system_settings_key ON public.system_settings USING btree (setting_key);


--
-- Name: ix_realtime_subscription_entity; Type: INDEX; Schema: realtime; Owner: supabase_admin
--

CREATE INDEX ix_realtime_subscription_entity ON realtime.subscription USING btree (entity);


--
-- Name: messages_inserted_at_topic_index; Type: INDEX; Schema: realtime; Owner: supabase_realtime_admin
--

CREATE INDEX messages_inserted_at_topic_index ON ONLY realtime.messages USING btree (inserted_at DESC, topic) WHERE ((extension = 'broadcast'::text) AND (private IS TRUE));


--
-- Name: messages_2026_07_02_inserted_at_topic_idx; Type: INDEX; Schema: realtime; Owner: supabase_admin
--

CREATE INDEX messages_2026_07_02_inserted_at_topic_idx ON realtime.messages_2026_07_02 USING btree (inserted_at DESC, topic) WHERE ((extension = 'broadcast'::text) AND (private IS TRUE));


--
-- Name: messages_2026_07_03_inserted_at_topic_idx; Type: INDEX; Schema: realtime; Owner: supabase_admin
--

CREATE INDEX messages_2026_07_03_inserted_at_topic_idx ON realtime.messages_2026_07_03 USING btree (inserted_at DESC, topic) WHERE ((extension = 'broadcast'::text) AND (private IS TRUE));


--
-- Name: messages_2026_07_04_inserted_at_topic_idx; Type: INDEX; Schema: realtime; Owner: supabase_admin
--

CREATE INDEX messages_2026_07_04_inserted_at_topic_idx ON realtime.messages_2026_07_04 USING btree (inserted_at DESC, topic) WHERE ((extension = 'broadcast'::text) AND (private IS TRUE));


--
-- Name: messages_2026_07_05_inserted_at_topic_idx; Type: INDEX; Schema: realtime; Owner: supabase_admin
--

CREATE INDEX messages_2026_07_05_inserted_at_topic_idx ON realtime.messages_2026_07_05 USING btree (inserted_at DESC, topic) WHERE ((extension = 'broadcast'::text) AND (private IS TRUE));


--
-- Name: messages_2026_07_06_inserted_at_topic_idx; Type: INDEX; Schema: realtime; Owner: supabase_admin
--

CREATE INDEX messages_2026_07_06_inserted_at_topic_idx ON realtime.messages_2026_07_06 USING btree (inserted_at DESC, topic) WHERE ((extension = 'broadcast'::text) AND (private IS TRUE));


--
-- Name: messages_2026_07_07_inserted_at_topic_idx; Type: INDEX; Schema: realtime; Owner: supabase_admin
--

CREATE INDEX messages_2026_07_07_inserted_at_topic_idx ON realtime.messages_2026_07_07 USING btree (inserted_at DESC, topic) WHERE ((extension = 'broadcast'::text) AND (private IS TRUE));


--
-- Name: messages_2026_07_08_inserted_at_topic_idx; Type: INDEX; Schema: realtime; Owner: supabase_admin
--

CREATE INDEX messages_2026_07_08_inserted_at_topic_idx ON realtime.messages_2026_07_08 USING btree (inserted_at DESC, topic) WHERE ((extension = 'broadcast'::text) AND (private IS TRUE));


--
-- Name: subscription_subscription_id_entity_filters_action_filter_selec; Type: INDEX; Schema: realtime; Owner: supabase_admin
--

CREATE UNIQUE INDEX subscription_subscription_id_entity_filters_action_filter_selec ON realtime.subscription USING btree (subscription_id, entity, filters, action_filter, COALESCE(selected_columns, '{}'::text[]));


--
-- Name: bname; Type: INDEX; Schema: storage; Owner: supabase_storage_admin
--

CREATE UNIQUE INDEX bname ON storage.buckets USING btree (name);


--
-- Name: bucketid_objname; Type: INDEX; Schema: storage; Owner: supabase_storage_admin
--

CREATE UNIQUE INDEX bucketid_objname ON storage.objects USING btree (bucket_id, name);


--
-- Name: buckets_analytics_unique_name_idx; Type: INDEX; Schema: storage; Owner: supabase_storage_admin
--

CREATE UNIQUE INDEX buckets_analytics_unique_name_idx ON storage.buckets_analytics USING btree (name) WHERE (deleted_at IS NULL);


--
-- Name: idx_iceberg_namespaces_bucket_id; Type: INDEX; Schema: storage; Owner: supabase_storage_admin
--

CREATE UNIQUE INDEX idx_iceberg_namespaces_bucket_id ON storage.iceberg_namespaces USING btree (catalog_id, name);


--
-- Name: idx_iceberg_tables_location; Type: INDEX; Schema: storage; Owner: supabase_storage_admin
--

CREATE UNIQUE INDEX idx_iceberg_tables_location ON storage.iceberg_tables USING btree (location);


--
-- Name: idx_iceberg_tables_namespace_id; Type: INDEX; Schema: storage; Owner: supabase_storage_admin
--

CREATE UNIQUE INDEX idx_iceberg_tables_namespace_id ON storage.iceberg_tables USING btree (catalog_id, namespace_id, name);


--
-- Name: idx_multipart_uploads_list; Type: INDEX; Schema: storage; Owner: supabase_storage_admin
--

CREATE INDEX idx_multipart_uploads_list ON storage.s3_multipart_uploads USING btree (bucket_id, key, created_at);


--
-- Name: idx_objects_bucket_id_name; Type: INDEX; Schema: storage; Owner: supabase_storage_admin
--

CREATE INDEX idx_objects_bucket_id_name ON storage.objects USING btree (bucket_id, name COLLATE "C");


--
-- Name: idx_objects_bucket_id_name_lower; Type: INDEX; Schema: storage; Owner: supabase_storage_admin
--

CREATE INDEX idx_objects_bucket_id_name_lower ON storage.objects USING btree (bucket_id, lower(name) COLLATE "C");


--
-- Name: name_prefix_search; Type: INDEX; Schema: storage; Owner: supabase_storage_admin
--

CREATE INDEX name_prefix_search ON storage.objects USING btree (name text_pattern_ops);


--
-- Name: vector_indexes_name_bucket_id_idx; Type: INDEX; Schema: storage; Owner: supabase_storage_admin
--

CREATE UNIQUE INDEX vector_indexes_name_bucket_id_idx ON storage.vector_indexes USING btree (name, bucket_id);


--
-- Name: supabase_functions_hooks_h_table_id_h_name_idx; Type: INDEX; Schema: supabase_functions; Owner: supabase_functions_admin
--

CREATE INDEX supabase_functions_hooks_h_table_id_h_name_idx ON supabase_functions.hooks USING btree (hook_table_id, hook_name);


--
-- Name: supabase_functions_hooks_request_id_idx; Type: INDEX; Schema: supabase_functions; Owner: supabase_functions_admin
--

CREATE INDEX supabase_functions_hooks_request_id_idx ON supabase_functions.hooks USING btree (request_id);


--
-- Name: messages_2026_07_02_inserted_at_topic_idx; Type: INDEX ATTACH; Schema: realtime; Owner: supabase_realtime_admin
--

ALTER INDEX realtime.messages_inserted_at_topic_index ATTACH PARTITION realtime.messages_2026_07_02_inserted_at_topic_idx;


--
-- Name: messages_2026_07_02_pkey; Type: INDEX ATTACH; Schema: realtime; Owner: supabase_realtime_admin
--

ALTER INDEX realtime.messages_pkey ATTACH PARTITION realtime.messages_2026_07_02_pkey;


--
-- Name: messages_2026_07_03_inserted_at_topic_idx; Type: INDEX ATTACH; Schema: realtime; Owner: supabase_realtime_admin
--

ALTER INDEX realtime.messages_inserted_at_topic_index ATTACH PARTITION realtime.messages_2026_07_03_inserted_at_topic_idx;


--
-- Name: messages_2026_07_03_pkey; Type: INDEX ATTACH; Schema: realtime; Owner: supabase_realtime_admin
--

ALTER INDEX realtime.messages_pkey ATTACH PARTITION realtime.messages_2026_07_03_pkey;


--
-- Name: messages_2026_07_04_inserted_at_topic_idx; Type: INDEX ATTACH; Schema: realtime; Owner: supabase_realtime_admin
--

ALTER INDEX realtime.messages_inserted_at_topic_index ATTACH PARTITION realtime.messages_2026_07_04_inserted_at_topic_idx;


--
-- Name: messages_2026_07_04_pkey; Type: INDEX ATTACH; Schema: realtime; Owner: supabase_realtime_admin
--

ALTER INDEX realtime.messages_pkey ATTACH PARTITION realtime.messages_2026_07_04_pkey;


--
-- Name: messages_2026_07_05_inserted_at_topic_idx; Type: INDEX ATTACH; Schema: realtime; Owner: supabase_realtime_admin
--

ALTER INDEX realtime.messages_inserted_at_topic_index ATTACH PARTITION realtime.messages_2026_07_05_inserted_at_topic_idx;


--
-- Name: messages_2026_07_05_pkey; Type: INDEX ATTACH; Schema: realtime; Owner: supabase_realtime_admin
--

ALTER INDEX realtime.messages_pkey ATTACH PARTITION realtime.messages_2026_07_05_pkey;


--
-- Name: messages_2026_07_06_inserted_at_topic_idx; Type: INDEX ATTACH; Schema: realtime; Owner: supabase_realtime_admin
--

ALTER INDEX realtime.messages_inserted_at_topic_index ATTACH PARTITION realtime.messages_2026_07_06_inserted_at_topic_idx;


--
-- Name: messages_2026_07_06_pkey; Type: INDEX ATTACH; Schema: realtime; Owner: supabase_realtime_admin
--

ALTER INDEX realtime.messages_pkey ATTACH PARTITION realtime.messages_2026_07_06_pkey;


--
-- Name: messages_2026_07_07_inserted_at_topic_idx; Type: INDEX ATTACH; Schema: realtime; Owner: supabase_realtime_admin
--

ALTER INDEX realtime.messages_inserted_at_topic_index ATTACH PARTITION realtime.messages_2026_07_07_inserted_at_topic_idx;


--
-- Name: messages_2026_07_07_pkey; Type: INDEX ATTACH; Schema: realtime; Owner: supabase_realtime_admin
--

ALTER INDEX realtime.messages_pkey ATTACH PARTITION realtime.messages_2026_07_07_pkey;


--
-- Name: messages_2026_07_08_inserted_at_topic_idx; Type: INDEX ATTACH; Schema: realtime; Owner: supabase_realtime_admin
--

ALTER INDEX realtime.messages_inserted_at_topic_index ATTACH PARTITION realtime.messages_2026_07_08_inserted_at_topic_idx;


--
-- Name: messages_2026_07_08_pkey; Type: INDEX ATTACH; Schema: realtime; Owner: supabase_realtime_admin
--

ALTER INDEX realtime.messages_pkey ATTACH PARTITION realtime.messages_2026_07_08_pkey;


--
-- Name: users on_auth_user_created; Type: TRIGGER; Schema: auth; Owner: supabase_auth_admin
--

CREATE TRIGGER on_auth_user_created AFTER INSERT ON auth.users FOR EACH ROW EXECUTE FUNCTION public.handle_new_user();


--
-- Name: sessions update_subscriber_activity_trigger; Type: TRIGGER; Schema: auth; Owner: supabase_auth_admin
--

CREATE TRIGGER update_subscriber_activity_trigger AFTER INSERT OR UPDATE ON auth.sessions FOR EACH ROW EXECUTE FUNCTION public.update_subscriber_activity();


--
-- Name: screen_permissions handle_screen_permissions_updated_at; Type: TRIGGER; Schema: public; Owner: postgres
--

CREATE TRIGGER handle_screen_permissions_updated_at BEFORE UPDATE ON public.screen_permissions FOR EACH ROW EXECUTE FUNCTION public.update_modified_column();


--
-- Name: frigate_alert_rules set_updated_at; Type: TRIGGER; Schema: public; Owner: postgres
--

CREATE TRIGGER set_updated_at BEFORE UPDATE ON public.frigate_alert_rules FOR EACH ROW EXECUTE FUNCTION public.update_modified_column();


--
-- Name: frigate_faces set_updated_at; Type: TRIGGER; Schema: public; Owner: postgres
--

CREATE TRIGGER set_updated_at BEFORE UPDATE ON public.frigate_faces FOR EACH ROW EXECUTE FUNCTION public.update_modified_column();


--
-- Name: frigate_license_plates set_updated_at; Type: TRIGGER; Schema: public; Owner: postgres
--

CREATE TRIGGER set_updated_at BEFORE UPDATE ON public.frigate_license_plates FOR EACH ROW EXECUTE FUNCTION public.update_modified_column();


--
-- Name: frigate_zones set_updated_at; Type: TRIGGER; Schema: public; Owner: postgres
--

CREATE TRIGGER set_updated_at BEFORE UPDATE ON public.frigate_zones FOR EACH ROW EXECUTE FUNCTION public.update_modified_column();


--
-- Name: chat_threads set_updated_at_chat_threads; Type: TRIGGER; Schema: public; Owner: postgres
--

CREATE TRIGGER set_updated_at_chat_threads BEFORE UPDATE ON public.chat_threads FOR EACH ROW EXECUTE FUNCTION public.update_modified_column();


--
-- Name: chat_messages touch_thread_on_message_insert; Type: TRIGGER; Schema: public; Owner: postgres
--

CREATE TRIGGER touch_thread_on_message_insert AFTER INSERT ON public.chat_messages FOR EACH ROW EXECUTE FUNCTION public.touch_chat_thread();


--
-- Name: chat_threads trg_chat_threads_updated_at; Type: TRIGGER; Schema: public; Owner: postgres
--

CREATE TRIGGER trg_chat_threads_updated_at BEFORE UPDATE ON public.chat_threads FOR EACH ROW EXECUTE FUNCTION public.update_modified_column();


--
-- Name: frigate_model_deployments trg_deployments_updated; Type: TRIGGER; Schema: public; Owner: postgres
--

CREATE TRIGGER trg_deployments_updated BEFORE UPDATE ON public.frigate_model_deployments FOR EACH ROW EXECUTE FUNCTION public.trg_touch_updated_at();


--
-- Name: pinned_labels trg_pinned_labels_updated_at; Type: TRIGGER; Schema: public; Owner: postgres
--

CREATE TRIGGER trg_pinned_labels_updated_at BEFORE UPDATE ON public.pinned_labels FOR EACH ROW EXECUTE FUNCTION public.update_modified_column();


--
-- Name: frigate_model_registry trg_registry_updated; Type: TRIGGER; Schema: public; Owner: postgres
--

CREATE TRIGGER trg_registry_updated BEFORE UPDATE ON public.frigate_model_registry FOR EACH ROW EXECUTE FUNCTION public.trg_touch_updated_at();


--
-- Name: events trg_restrict_events_update; Type: TRIGGER; Schema: public; Owner: postgres
--

CREATE TRIGGER trg_restrict_events_update BEFORE UPDATE ON public.events FOR EACH ROW EXECUTE FUNCTION public.restrict_events_update();


--
-- Name: chat_messages trg_touch_thread_after_message_insert; Type: TRIGGER; Schema: public; Owner: postgres
--

CREATE TRIGGER trg_touch_thread_after_message_insert AFTER INSERT ON public.chat_messages FOR EACH ROW EXECUTE FUNCTION public.touch_chat_thread();


--
-- Name: camera_event_assignments trg_veedon_bump_assignments; Type: TRIGGER; Schema: public; Owner: postgres
--

CREATE TRIGGER trg_veedon_bump_assignments AFTER INSERT OR DELETE OR UPDATE ON public.camera_event_assignments FOR EACH ROW EXECUTE FUNCTION public.veedon_bump_branch_config();


--
-- Name: cameras trg_veedon_bump_cameras; Type: TRIGGER; Schema: public; Owner: postgres
--

CREATE TRIGGER trg_veedon_bump_cameras AFTER INSERT OR DELETE OR UPDATE ON public.cameras FOR EACH ROW EXECUTE FUNCTION public.veedon_bump_branch_config();


--
-- Name: alert_templates update_alert_templates_updated_at; Type: TRIGGER; Schema: public; Owner: postgres
--

CREATE TRIGGER update_alert_templates_updated_at BEFORE UPDATE ON public.alert_templates FOR EACH ROW EXECUTE FUNCTION public.update_modified_column();


--
-- Name: aman_instances update_aman_instances_updated_at; Type: TRIGGER; Schema: public; Owner: postgres
--

CREATE TRIGGER update_aman_instances_updated_at BEFORE UPDATE ON public.aman_instances FOR EACH ROW EXECUTE FUNCTION public.update_modified_column();


--
-- Name: auto_sync_settings update_auto_sync_settings_updated_at; Type: TRIGGER; Schema: public; Owner: postgres
--

CREATE TRIGGER update_auto_sync_settings_updated_at BEFORE UPDATE ON public.auto_sync_settings FOR EACH ROW EXECUTE FUNCTION public.update_modified_column();


--
-- Name: camera_sources update_camera_sources_updated_at; Type: TRIGGER; Schema: public; Owner: postgres
--

CREATE TRIGGER update_camera_sources_updated_at BEFORE UPDATE ON public.camera_sources FOR EACH ROW EXECUTE FUNCTION public.update_modified_column();


--
-- Name: cameras update_cameras_updated_at; Type: TRIGGER; Schema: public; Owner: postgres
--

CREATE TRIGGER update_cameras_updated_at BEFORE UPDATE ON public.cameras FOR EACH ROW EXECUTE FUNCTION public.update_modified_column();


--
-- Name: chatbot_knowledge_base update_chatbot_knowledge_base_updated_at; Type: TRIGGER; Schema: public; Owner: postgres
--

CREATE TRIGGER update_chatbot_knowledge_base_updated_at BEFORE UPDATE ON public.chatbot_knowledge_base FOR EACH ROW EXECUTE FUNCTION public.update_modified_column();


--
-- Name: event_types update_event_types_updated_at; Type: TRIGGER; Schema: public; Owner: postgres
--

CREATE TRIGGER update_event_types_updated_at BEFORE UPDATE ON public.event_types FOR EACH ROW EXECUTE FUNCTION public.update_modified_column();


--
-- Name: form_assignments update_form_assignments_updated_at; Type: TRIGGER; Schema: public; Owner: postgres
--

CREATE TRIGGER update_form_assignments_updated_at BEFORE UPDATE ON public.form_assignments FOR EACH ROW EXECUTE FUNCTION public.update_modified_column();


--
-- Name: form_distribution_settings update_form_distribution_settings_updated_at; Type: TRIGGER; Schema: public; Owner: postgres
--

CREATE TRIGGER update_form_distribution_settings_updated_at BEFORE UPDATE ON public.form_distribution_settings FOR EACH ROW EXECUTE FUNCTION public.update_modified_column();


--
-- Name: frigate_exports update_frigate_exports_updated_at; Type: TRIGGER; Schema: public; Owner: postgres
--

CREATE TRIGGER update_frigate_exports_updated_at BEFORE UPDATE ON public.frigate_exports FOR EACH ROW EXECUTE FUNCTION public.update_modified_column();


--
-- Name: frigate_instances update_frigate_instances_updated_at; Type: TRIGGER; Schema: public; Owner: postgres
--

CREATE TRIGGER update_frigate_instances_updated_at BEFORE UPDATE ON public.frigate_instances FOR EACH ROW EXECUTE FUNCTION public.update_modified_column();


--
-- Name: frigate_previews update_frigate_previews_updated_at; Type: TRIGGER; Schema: public; Owner: postgres
--

CREATE TRIGGER update_frigate_previews_updated_at BEFORE UPDATE ON public.frigate_previews FOR EACH ROW EXECUTE FUNCTION public.update_modified_column();


--
-- Name: frigate_recordings update_frigate_recordings_updated_at; Type: TRIGGER; Schema: public; Owner: postgres
--

CREATE TRIGGER update_frigate_recordings_updated_at BEFORE UPDATE ON public.frigate_recordings FOR EACH ROW EXECUTE FUNCTION public.update_modified_column();


--
-- Name: frigate_reviews update_frigate_reviews_updated_at; Type: TRIGGER; Schema: public; Owner: postgres
--

CREATE TRIGGER update_frigate_reviews_updated_at BEFORE UPDATE ON public.frigate_reviews FOR EACH ROW EXECUTE FUNCTION public.update_modified_column();


--
-- Name: industries update_industries_updated_at; Type: TRIGGER; Schema: public; Owner: postgres
--

CREATE TRIGGER update_industries_updated_at BEFORE UPDATE ON public.industries FOR EACH ROW EXECUTE FUNCTION public.update_modified_column();


--
-- Name: legal_documents update_legal_documents_updated_at; Type: TRIGGER; Schema: public; Owner: postgres
--

CREATE TRIGGER update_legal_documents_updated_at BEFORE UPDATE ON public.legal_documents FOR EACH ROW EXECUTE FUNCTION public.update_modified_column();


--
-- Name: notification_labels update_notification_labels_updated_at; Type: TRIGGER; Schema: public; Owner: postgres
--

CREATE TRIGGER update_notification_labels_updated_at BEFORE UPDATE ON public.notification_labels FOR EACH ROW EXECUTE FUNCTION public.update_modified_column();


--
-- Name: notification_methods update_notification_methods_updated_at; Type: TRIGGER; Schema: public; Owner: postgres
--

CREATE TRIGGER update_notification_methods_updated_at BEFORE UPDATE ON public.notification_methods FOR EACH ROW EXECUTE FUNCTION public.update_modified_column();


--
-- Name: organization_settings update_organization_settings_updated_at; Type: TRIGGER; Schema: public; Owner: postgres
--

CREATE TRIGGER update_organization_settings_updated_at BEFORE UPDATE ON public.organization_settings FOR EACH ROW EXECUTE FUNCTION public.update_modified_column();


--
-- Name: organizations update_organizations_modtime; Type: TRIGGER; Schema: public; Owner: postgres
--

CREATE TRIGGER update_organizations_modtime BEFORE UPDATE ON public.organizations FOR EACH ROW EXECUTE FUNCTION public.update_modified_column();


--
-- Name: pinned_dashboards update_pinned_dashboards_updated_at; Type: TRIGGER; Schema: public; Owner: postgres
--

CREATE TRIGGER update_pinned_dashboards_updated_at BEFORE UPDATE ON public.pinned_dashboards FOR EACH ROW EXECUTE FUNCTION public.update_modified_column();


--
-- Name: security_zones update_security_zones_updated_at; Type: TRIGGER; Schema: public; Owner: postgres
--

CREATE TRIGGER update_security_zones_updated_at BEFORE UPDATE ON public.security_zones FOR EACH ROW EXECUTE FUNCTION public.update_modified_column();


--
-- Name: storage_configs update_storage_configs_updated_at; Type: TRIGGER; Schema: public; Owner: postgres
--

CREATE TRIGGER update_storage_configs_updated_at BEFORE UPDATE ON public.storage_configs FOR EACH ROW EXECUTE FUNCTION public.update_modified_column();


--
-- Name: subscribers update_subscribers_updated_at; Type: TRIGGER; Schema: public; Owner: postgres
--

CREATE TRIGGER update_subscribers_updated_at BEFORE UPDATE ON public.subscribers FOR EACH ROW EXECUTE FUNCTION public.update_modified_column();


--
-- Name: system_settings update_system_settings_updated_at; Type: TRIGGER; Schema: public; Owner: postgres
--

CREATE TRIGGER update_system_settings_updated_at BEFORE UPDATE ON public.system_settings FOR EACH ROW EXECUTE FUNCTION public.update_modified_column();


--
-- Name: user_groups update_user_groups_updated_at; Type: TRIGGER; Schema: public; Owner: postgres
--

CREATE TRIGGER update_user_groups_updated_at BEFORE UPDATE ON public.user_groups FOR EACH ROW EXECUTE FUNCTION public.update_modified_column();


--
-- Name: user_preferences update_user_preferences_updated_at; Type: TRIGGER; Schema: public; Owner: postgres
--

CREATE TRIGGER update_user_preferences_updated_at BEFORE UPDATE ON public.user_preferences FOR EACH ROW EXECUTE FUNCTION public.update_modified_column();


--
-- Name: workflow_forms update_workflow_forms_updated_at; Type: TRIGGER; Schema: public; Owner: postgres
--

CREATE TRIGGER update_workflow_forms_updated_at BEFORE UPDATE ON public.workflow_forms FOR EACH ROW EXECUTE FUNCTION public.update_modified_column();


--
-- Name: subscription tr_check_filters; Type: TRIGGER; Schema: realtime; Owner: supabase_admin
--

CREATE TRIGGER tr_check_filters BEFORE INSERT OR UPDATE ON realtime.subscription FOR EACH ROW EXECUTE FUNCTION realtime.subscription_check_filters();


--
-- Name: buckets enforce_bucket_name_length_trigger; Type: TRIGGER; Schema: storage; Owner: supabase_storage_admin
--

CREATE TRIGGER enforce_bucket_name_length_trigger BEFORE INSERT OR UPDATE OF name ON storage.buckets FOR EACH ROW EXECUTE FUNCTION storage.enforce_bucket_name_length();


--
-- Name: buckets protect_buckets_delete; Type: TRIGGER; Schema: storage; Owner: supabase_storage_admin
--

CREATE TRIGGER protect_buckets_delete BEFORE DELETE ON storage.buckets FOR EACH STATEMENT EXECUTE FUNCTION storage.protect_delete();


--
-- Name: objects protect_objects_delete; Type: TRIGGER; Schema: storage; Owner: supabase_storage_admin
--

CREATE TRIGGER protect_objects_delete BEFORE DELETE ON storage.objects FOR EACH STATEMENT EXECUTE FUNCTION storage.protect_delete();


--
-- Name: objects update_objects_updated_at; Type: TRIGGER; Schema: storage; Owner: supabase_storage_admin
--

CREATE TRIGGER update_objects_updated_at BEFORE UPDATE ON storage.objects FOR EACH ROW EXECUTE FUNCTION storage.update_updated_at_column();


--
-- Name: extensions extensions_tenant_external_id_fkey; Type: FK CONSTRAINT; Schema: _realtime; Owner: supabase_admin
--

ALTER TABLE ONLY _realtime.extensions
    ADD CONSTRAINT extensions_tenant_external_id_fkey FOREIGN KEY (tenant_external_id) REFERENCES _realtime.tenants(external_id) ON DELETE CASCADE;


--
-- Name: identities identities_user_id_fkey; Type: FK CONSTRAINT; Schema: auth; Owner: supabase_auth_admin
--

ALTER TABLE ONLY auth.identities
    ADD CONSTRAINT identities_user_id_fkey FOREIGN KEY (user_id) REFERENCES auth.users(id) ON DELETE CASCADE;


--
-- Name: mfa_amr_claims mfa_amr_claims_session_id_fkey; Type: FK CONSTRAINT; Schema: auth; Owner: supabase_auth_admin
--

ALTER TABLE ONLY auth.mfa_amr_claims
    ADD CONSTRAINT mfa_amr_claims_session_id_fkey FOREIGN KEY (session_id) REFERENCES auth.sessions(id) ON DELETE CASCADE;


--
-- Name: mfa_challenges mfa_challenges_auth_factor_id_fkey; Type: FK CONSTRAINT; Schema: auth; Owner: supabase_auth_admin
--

ALTER TABLE ONLY auth.mfa_challenges
    ADD CONSTRAINT mfa_challenges_auth_factor_id_fkey FOREIGN KEY (factor_id) REFERENCES auth.mfa_factors(id) ON DELETE CASCADE;


--
-- Name: mfa_factors mfa_factors_user_id_fkey; Type: FK CONSTRAINT; Schema: auth; Owner: supabase_auth_admin
--

ALTER TABLE ONLY auth.mfa_factors
    ADD CONSTRAINT mfa_factors_user_id_fkey FOREIGN KEY (user_id) REFERENCES auth.users(id) ON DELETE CASCADE;


--
-- Name: oauth_authorizations oauth_authorizations_client_id_fkey; Type: FK CONSTRAINT; Schema: auth; Owner: supabase_auth_admin
--

ALTER TABLE ONLY auth.oauth_authorizations
    ADD CONSTRAINT oauth_authorizations_client_id_fkey FOREIGN KEY (client_id) REFERENCES auth.oauth_clients(id) ON DELETE CASCADE;


--
-- Name: oauth_authorizations oauth_authorizations_user_id_fkey; Type: FK CONSTRAINT; Schema: auth; Owner: supabase_auth_admin
--

ALTER TABLE ONLY auth.oauth_authorizations
    ADD CONSTRAINT oauth_authorizations_user_id_fkey FOREIGN KEY (user_id) REFERENCES auth.users(id) ON DELETE CASCADE;


--
-- Name: oauth_consents oauth_consents_client_id_fkey; Type: FK CONSTRAINT; Schema: auth; Owner: supabase_auth_admin
--

ALTER TABLE ONLY auth.oauth_consents
    ADD CONSTRAINT oauth_consents_client_id_fkey FOREIGN KEY (client_id) REFERENCES auth.oauth_clients(id) ON DELETE CASCADE;


--
-- Name: oauth_consents oauth_consents_user_id_fkey; Type: FK CONSTRAINT; Schema: auth; Owner: supabase_auth_admin
--

ALTER TABLE ONLY auth.oauth_consents
    ADD CONSTRAINT oauth_consents_user_id_fkey FOREIGN KEY (user_id) REFERENCES auth.users(id) ON DELETE CASCADE;


--
-- Name: one_time_tokens one_time_tokens_user_id_fkey; Type: FK CONSTRAINT; Schema: auth; Owner: supabase_auth_admin
--

ALTER TABLE ONLY auth.one_time_tokens
    ADD CONSTRAINT one_time_tokens_user_id_fkey FOREIGN KEY (user_id) REFERENCES auth.users(id) ON DELETE CASCADE;


--
-- Name: refresh_tokens refresh_tokens_session_id_fkey; Type: FK CONSTRAINT; Schema: auth; Owner: supabase_auth_admin
--

ALTER TABLE ONLY auth.refresh_tokens
    ADD CONSTRAINT refresh_tokens_session_id_fkey FOREIGN KEY (session_id) REFERENCES auth.sessions(id) ON DELETE CASCADE;


--
-- Name: saml_providers saml_providers_sso_provider_id_fkey; Type: FK CONSTRAINT; Schema: auth; Owner: supabase_auth_admin
--

ALTER TABLE ONLY auth.saml_providers
    ADD CONSTRAINT saml_providers_sso_provider_id_fkey FOREIGN KEY (sso_provider_id) REFERENCES auth.sso_providers(id) ON DELETE CASCADE;


--
-- Name: saml_relay_states saml_relay_states_flow_state_id_fkey; Type: FK CONSTRAINT; Schema: auth; Owner: supabase_auth_admin
--

ALTER TABLE ONLY auth.saml_relay_states
    ADD CONSTRAINT saml_relay_states_flow_state_id_fkey FOREIGN KEY (flow_state_id) REFERENCES auth.flow_state(id) ON DELETE CASCADE;


--
-- Name: saml_relay_states saml_relay_states_sso_provider_id_fkey; Type: FK CONSTRAINT; Schema: auth; Owner: supabase_auth_admin
--

ALTER TABLE ONLY auth.saml_relay_states
    ADD CONSTRAINT saml_relay_states_sso_provider_id_fkey FOREIGN KEY (sso_provider_id) REFERENCES auth.sso_providers(id) ON DELETE CASCADE;


--
-- Name: sessions sessions_oauth_client_id_fkey; Type: FK CONSTRAINT; Schema: auth; Owner: supabase_auth_admin
--

ALTER TABLE ONLY auth.sessions
    ADD CONSTRAINT sessions_oauth_client_id_fkey FOREIGN KEY (oauth_client_id) REFERENCES auth.oauth_clients(id) ON DELETE CASCADE;


--
-- Name: sessions sessions_user_id_fkey; Type: FK CONSTRAINT; Schema: auth; Owner: supabase_auth_admin
--

ALTER TABLE ONLY auth.sessions
    ADD CONSTRAINT sessions_user_id_fkey FOREIGN KEY (user_id) REFERENCES auth.users(id) ON DELETE CASCADE;


--
-- Name: sso_domains sso_domains_sso_provider_id_fkey; Type: FK CONSTRAINT; Schema: auth; Owner: supabase_auth_admin
--

ALTER TABLE ONLY auth.sso_domains
    ADD CONSTRAINT sso_domains_sso_provider_id_fkey FOREIGN KEY (sso_provider_id) REFERENCES auth.sso_providers(id) ON DELETE CASCADE;


--
-- Name: webauthn_challenges webauthn_challenges_user_id_fkey; Type: FK CONSTRAINT; Schema: auth; Owner: supabase_auth_admin
--

ALTER TABLE ONLY auth.webauthn_challenges
    ADD CONSTRAINT webauthn_challenges_user_id_fkey FOREIGN KEY (user_id) REFERENCES auth.users(id) ON DELETE CASCADE;


--
-- Name: webauthn_credentials webauthn_credentials_user_id_fkey; Type: FK CONSTRAINT; Schema: auth; Owner: supabase_auth_admin
--

ALTER TABLE ONLY auth.webauthn_credentials
    ADD CONSTRAINT webauthn_credentials_user_id_fkey FOREIGN KEY (user_id) REFERENCES auth.users(id) ON DELETE CASCADE;


--
-- Name: ai_analysis_logs ai_analysis_logs_alert_template_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.ai_analysis_logs
    ADD CONSTRAINT ai_analysis_logs_alert_template_id_fkey FOREIGN KEY (alert_template_id) REFERENCES public.alert_templates(id) ON DELETE SET NULL;


--
-- Name: ai_analysis_logs ai_analysis_logs_camera_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.ai_analysis_logs
    ADD CONSTRAINT ai_analysis_logs_camera_id_fkey FOREIGN KEY (camera_id) REFERENCES public.cameras(id) ON DELETE CASCADE;


--
-- Name: alert_template_events alert_template_events_alert_template_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.alert_template_events
    ADD CONSTRAINT alert_template_events_alert_template_id_fkey FOREIGN KEY (alert_template_id) REFERENCES public.alert_templates(id) ON DELETE CASCADE;


--
-- Name: alert_template_events alert_template_events_event_type_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.alert_template_events
    ADD CONSTRAINT alert_template_events_event_type_id_fkey FOREIGN KEY (event_type_id) REFERENCES public.event_types(id) ON DELETE CASCADE;


--
-- Name: alert_template_industries alert_template_industries_alert_template_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.alert_template_industries
    ADD CONSTRAINT alert_template_industries_alert_template_id_fkey FOREIGN KEY (alert_template_id) REFERENCES public.alert_templates(id) ON DELETE CASCADE;


--
-- Name: alert_template_industries alert_template_industries_industry_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.alert_template_industries
    ADD CONSTRAINT alert_template_industries_industry_id_fkey FOREIGN KEY (industry_id) REFERENCES public.industries(id) ON DELETE CASCADE;


--
-- Name: alert_templates alert_templates_created_by_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.alert_templates
    ADD CONSTRAINT alert_templates_created_by_fkey FOREIGN KEY (created_by) REFERENCES auth.users(id);


--
-- Name: branch_roles branch_roles_branch_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.branch_roles
    ADD CONSTRAINT branch_roles_branch_id_fkey FOREIGN KEY (branch_id) REFERENCES public.branches(id) ON DELETE CASCADE;


--
-- Name: branch_roles branch_roles_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.branch_roles
    ADD CONSTRAINT branch_roles_user_id_fkey FOREIGN KEY (user_id) REFERENCES auth.users(id) ON DELETE CASCADE;


--
-- Name: branches branches_organization_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.branches
    ADD CONSTRAINT branches_organization_id_fkey FOREIGN KEY (organization_id) REFERENCES public.organizations(id) ON DELETE CASCADE;


--
-- Name: camera_alert_assignments camera_alert_assignments_alert_template_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.camera_alert_assignments
    ADD CONSTRAINT camera_alert_assignments_alert_template_id_fkey FOREIGN KEY (alert_template_id) REFERENCES public.alert_templates(id) ON DELETE CASCADE;


--
-- Name: camera_sources camera_sources_created_by_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.camera_sources
    ADD CONSTRAINT camera_sources_created_by_fkey FOREIGN KEY (created_by) REFERENCES auth.users(id);


--
-- Name: cameras cameras_branch_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.cameras
    ADD CONSTRAINT cameras_branch_id_fkey FOREIGN KEY (branch_id) REFERENCES public.branches(id) ON DELETE CASCADE;


--
-- Name: cameras cameras_frigate_instance_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.cameras
    ADD CONSTRAINT cameras_frigate_instance_id_fkey FOREIGN KEY (frigate_instance_id) REFERENCES public.frigate_instances(id);


--
-- Name: cameras cameras_security_zone_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.cameras
    ADD CONSTRAINT cameras_security_zone_id_fkey FOREIGN KEY (security_zone_id) REFERENCES public.security_zones(id);


--
-- Name: chat_messages chat_messages_thread_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.chat_messages
    ADD CONSTRAINT chat_messages_thread_id_fkey FOREIGN KEY (thread_id) REFERENCES public.chat_threads(id) ON DELETE CASCADE;


--
-- Name: chat_thread_participants chat_thread_participants_thread_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.chat_thread_participants
    ADD CONSTRAINT chat_thread_participants_thread_id_fkey FOREIGN KEY (thread_id) REFERENCES public.chat_threads(id) ON DELETE CASCADE;


--
-- Name: chat_threads chat_threads_organization_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.chat_threads
    ADD CONSTRAINT chat_threads_organization_id_fkey FOREIGN KEY (organization_id) REFERENCES public.organizations(id) ON DELETE CASCADE;


--
-- Name: detection_rules detection_rules_organization_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.detection_rules
    ADD CONSTRAINT detection_rules_organization_id_fkey FOREIGN KEY (organization_id) REFERENCES public.organizations(id) ON DELETE CASCADE;


--
-- Name: events events_camera_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.events
    ADD CONSTRAINT events_camera_id_fkey FOREIGN KEY (camera_id) REFERENCES public.cameras(id) ON DELETE CASCADE;


--
-- Name: frigate_exports fk_frigate_exports_instance; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.frigate_exports
    ADD CONSTRAINT fk_frigate_exports_instance FOREIGN KEY (frigate_instance_id) REFERENCES public.frigate_instances(id) ON DELETE CASCADE;


--
-- Name: frigate_previews fk_frigate_previews_instance; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.frigate_previews
    ADD CONSTRAINT fk_frigate_previews_instance FOREIGN KEY (frigate_instance_id) REFERENCES public.frigate_instances(id) ON DELETE CASCADE;


--
-- Name: frigate_recordings fk_frigate_recordings_instance; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.frigate_recordings
    ADD CONSTRAINT fk_frigate_recordings_instance FOREIGN KEY (frigate_instance_id) REFERENCES public.frigate_instances(id) ON DELETE CASCADE;


--
-- Name: frigate_reviews fk_frigate_reviews_instance; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.frigate_reviews
    ADD CONSTRAINT fk_frigate_reviews_instance FOREIGN KEY (frigate_instance_id) REFERENCES public.frigate_instances(id) ON DELETE CASCADE;


--
-- Name: frigate_timeline fk_frigate_timeline_instance; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.frigate_timeline
    ADD CONSTRAINT fk_frigate_timeline_instance FOREIGN KEY (frigate_instance_id) REFERENCES public.frigate_instances(id) ON DELETE CASCADE;


--
-- Name: form_assignments form_assignments_workflow_form_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.form_assignments
    ADD CONSTRAINT form_assignments_workflow_form_id_fkey FOREIGN KEY (workflow_form_id) REFERENCES public.workflow_forms(id) ON DELETE CASCADE;


--
-- Name: form_distribution_settings form_distribution_settings_workflow_form_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.form_distribution_settings
    ADD CONSTRAINT form_distribution_settings_workflow_form_id_fkey FOREIGN KEY (workflow_form_id) REFERENCES public.workflow_forms(id) ON DELETE CASCADE;


--
-- Name: form_submissions form_submissions_form_assignment_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.form_submissions
    ADD CONSTRAINT form_submissions_form_assignment_id_fkey FOREIGN KEY (form_assignment_id) REFERENCES public.form_assignments(id) ON DELETE CASCADE;


--
-- Name: frigate_alert_rules frigate_alert_rules_camera_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.frigate_alert_rules
    ADD CONSTRAINT frigate_alert_rules_camera_id_fkey FOREIGN KEY (camera_id) REFERENCES public.cameras(id) ON DELETE CASCADE;


--
-- Name: frigate_deployed_models frigate_deployed_models_frigate_instance_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.frigate_deployed_models
    ADD CONSTRAINT frigate_deployed_models_frigate_instance_id_fkey FOREIGN KEY (frigate_instance_id) REFERENCES public.frigate_instances(id) ON DELETE CASCADE;


--
-- Name: frigate_faces frigate_faces_camera_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.frigate_faces
    ADD CONSTRAINT frigate_faces_camera_id_fkey FOREIGN KEY (camera_id) REFERENCES public.cameras(id) ON DELETE CASCADE;


--
-- Name: frigate_instances frigate_instances_branch_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.frigate_instances
    ADD CONSTRAINT frigate_instances_branch_id_fkey FOREIGN KEY (branch_id) REFERENCES public.branches(id) ON DELETE SET NULL;


--
-- Name: frigate_license_plates frigate_license_plates_camera_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.frigate_license_plates
    ADD CONSTRAINT frigate_license_plates_camera_id_fkey FOREIGN KEY (camera_id) REFERENCES public.cameras(id) ON DELETE CASCADE;


--
-- Name: frigate_license_plates frigate_license_plates_frigate_instance_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.frigate_license_plates
    ADD CONSTRAINT frigate_license_plates_frigate_instance_id_fkey FOREIGN KEY (frigate_instance_id) REFERENCES public.frigate_instances(id) ON DELETE SET NULL;


--
-- Name: frigate_model_deployments frigate_model_deployments_deployed_by_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.frigate_model_deployments
    ADD CONSTRAINT frigate_model_deployments_deployed_by_fkey FOREIGN KEY (deployed_by) REFERENCES auth.users(id);


--
-- Name: frigate_model_deployments frigate_model_deployments_frigate_instance_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.frigate_model_deployments
    ADD CONSTRAINT frigate_model_deployments_frigate_instance_id_fkey FOREIGN KEY (frigate_instance_id) REFERENCES public.frigate_instances(id) ON DELETE CASCADE;


--
-- Name: frigate_model_sync_log frigate_model_sync_log_frigate_instance_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.frigate_model_sync_log
    ADD CONSTRAINT frigate_model_sync_log_frigate_instance_id_fkey FOREIGN KEY (frigate_instance_id) REFERENCES public.frigate_instances(id) ON DELETE CASCADE;


--
-- Name: frigate_stats_history frigate_stats_history_frigate_instance_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.frigate_stats_history
    ADD CONSTRAINT frigate_stats_history_frigate_instance_id_fkey FOREIGN KEY (frigate_instance_id) REFERENCES public.frigate_instances(id) ON DELETE CASCADE;


--
-- Name: frigate_sync_logs frigate_sync_logs_frigate_instance_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.frigate_sync_logs
    ADD CONSTRAINT frigate_sync_logs_frigate_instance_id_fkey FOREIGN KEY (frigate_instance_id) REFERENCES public.frigate_instances(id) ON DELETE CASCADE;


--
-- Name: frigate_timeline frigate_timeline_camera_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.frigate_timeline
    ADD CONSTRAINT frigate_timeline_camera_id_fkey FOREIGN KEY (camera_id) REFERENCES public.cameras(id) ON DELETE CASCADE;


--
-- Name: frigate_triggers frigate_triggers_frigate_instance_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.frigate_triggers
    ADD CONSTRAINT frigate_triggers_frigate_instance_id_fkey FOREIGN KEY (frigate_instance_id) REFERENCES public.frigate_instances(id) ON DELETE CASCADE;


--
-- Name: frigate_zones frigate_zones_camera_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.frigate_zones
    ADD CONSTRAINT frigate_zones_camera_id_fkey FOREIGN KEY (camera_id) REFERENCES public.cameras(id) ON DELETE CASCADE;


--
-- Name: health_alerts health_alerts_student_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.health_alerts
    ADD CONSTRAINT health_alerts_student_id_fkey FOREIGN KEY (student_id) REFERENCES public.students(id) ON DELETE CASCADE;


--
-- Name: legal_documents legal_documents_created_by_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.legal_documents
    ADD CONSTRAINT legal_documents_created_by_fkey FOREIGN KEY (created_by) REFERENCES auth.users(id);


--
-- Name: legal_documents legal_documents_updated_by_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.legal_documents
    ADD CONSTRAINT legal_documents_updated_by_fkey FOREIGN KEY (updated_by) REFERENCES auth.users(id);


--
-- Name: network_scan_results network_scan_results_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.network_scan_results
    ADD CONSTRAINT network_scan_results_user_id_fkey FOREIGN KEY (user_id) REFERENCES auth.users(id);


--
-- Name: notification_methods notification_methods_created_by_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.notification_methods
    ADD CONSTRAINT notification_methods_created_by_fkey FOREIGN KEY (created_by) REFERENCES auth.users(id);


--
-- Name: organization_settings organization_settings_organization_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.organization_settings
    ADD CONSTRAINT organization_settings_organization_id_fkey FOREIGN KEY (organization_id) REFERENCES public.organizations(id) ON DELETE CASCADE;


--
-- Name: organizations organizations_industry_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.organizations
    ADD CONSTRAINT organizations_industry_id_fkey FOREIGN KEY (industry_id) REFERENCES public.industries(id);


--
-- Name: security_zones security_zones_branch_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.security_zones
    ADD CONSTRAINT security_zones_branch_id_fkey FOREIGN KEY (branch_id) REFERENCES public.branches(id) ON DELETE CASCADE;


--
-- Name: storage_configs storage_configs_created_by_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.storage_configs
    ADD CONSTRAINT storage_configs_created_by_fkey FOREIGN KEY (created_by) REFERENCES auth.users(id);


--
-- Name: students students_branch_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.students
    ADD CONSTRAINT students_branch_id_fkey FOREIGN KEY (branch_id) REFERENCES public.branches(id) ON DELETE SET NULL;


--
-- Name: students students_organization_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.students
    ADD CONSTRAINT students_organization_id_fkey FOREIGN KEY (organization_id) REFERENCES public.organizations(id) ON DELETE CASCADE;


--
-- Name: subscribers subscribers_approved_by_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.subscribers
    ADD CONSTRAINT subscribers_approved_by_fkey FOREIGN KEY (approved_by) REFERENCES auth.users(id);


--
-- Name: subscribers subscribers_organization_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.subscribers
    ADD CONSTRAINT subscribers_organization_id_fkey FOREIGN KEY (organization_id) REFERENCES public.organizations(id);


--
-- Name: subscribers subscribers_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.subscribers
    ADD CONSTRAINT subscribers_user_id_fkey FOREIGN KEY (user_id) REFERENCES auth.users(id) ON DELETE CASCADE;


--
-- Name: system_settings system_settings_updated_by_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.system_settings
    ADD CONSTRAINT system_settings_updated_by_fkey FOREIGN KEY (updated_by) REFERENCES auth.users(id);


--
-- Name: user_branch_access user_branch_access_branch_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.user_branch_access
    ADD CONSTRAINT user_branch_access_branch_id_fkey FOREIGN KEY (branch_id) REFERENCES public.branches(id) ON DELETE CASCADE;


--
-- Name: user_branch_access user_branch_access_granted_by_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.user_branch_access
    ADD CONSTRAINT user_branch_access_granted_by_fkey FOREIGN KEY (granted_by) REFERENCES auth.users(id);


--
-- Name: user_branch_access user_branch_access_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.user_branch_access
    ADD CONSTRAINT user_branch_access_user_id_fkey FOREIGN KEY (user_id) REFERENCES auth.users(id) ON DELETE CASCADE;


--
-- Name: user_group_members user_group_members_group_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.user_group_members
    ADD CONSTRAINT user_group_members_group_id_fkey FOREIGN KEY (group_id) REFERENCES public.user_groups(id) ON DELETE CASCADE;


--
-- Name: user_group_members user_group_members_user_role_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.user_group_members
    ADD CONSTRAINT user_group_members_user_role_id_fkey FOREIGN KEY (user_role_id) REFERENCES public.user_roles(id) ON DELETE CASCADE;


--
-- Name: user_groups user_groups_organization_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.user_groups
    ADD CONSTRAINT user_groups_organization_id_fkey FOREIGN KEY (organization_id) REFERENCES public.organizations(id) ON DELETE CASCADE;


--
-- Name: user_preferences user_preferences_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.user_preferences
    ADD CONSTRAINT user_preferences_user_id_fkey FOREIGN KEY (user_id) REFERENCES auth.users(id) ON DELETE CASCADE;


--
-- Name: user_roles user_roles_granted_by_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.user_roles
    ADD CONSTRAINT user_roles_granted_by_fkey FOREIGN KEY (granted_by) REFERENCES auth.users(id);


--
-- Name: user_roles user_roles_organization_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.user_roles
    ADD CONSTRAINT user_roles_organization_id_fkey FOREIGN KEY (organization_id) REFERENCES public.organizations(id) ON DELETE CASCADE;


--
-- Name: user_roles user_roles_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.user_roles
    ADD CONSTRAINT user_roles_user_id_fkey FOREIGN KEY (user_id) REFERENCES auth.users(id) ON DELETE CASCADE;


--
-- Name: iceberg_namespaces iceberg_namespaces_catalog_id_fkey; Type: FK CONSTRAINT; Schema: storage; Owner: supabase_storage_admin
--

ALTER TABLE ONLY storage.iceberg_namespaces
    ADD CONSTRAINT iceberg_namespaces_catalog_id_fkey FOREIGN KEY (catalog_id) REFERENCES storage.buckets_analytics(id) ON DELETE CASCADE;


--
-- Name: iceberg_tables iceberg_tables_catalog_id_fkey; Type: FK CONSTRAINT; Schema: storage; Owner: supabase_storage_admin
--

ALTER TABLE ONLY storage.iceberg_tables
    ADD CONSTRAINT iceberg_tables_catalog_id_fkey FOREIGN KEY (catalog_id) REFERENCES storage.buckets_analytics(id) ON DELETE CASCADE;


--
-- Name: iceberg_tables iceberg_tables_namespace_id_fkey; Type: FK CONSTRAINT; Schema: storage; Owner: supabase_storage_admin
--

ALTER TABLE ONLY storage.iceberg_tables
    ADD CONSTRAINT iceberg_tables_namespace_id_fkey FOREIGN KEY (namespace_id) REFERENCES storage.iceberg_namespaces(id) ON DELETE CASCADE;


--
-- Name: objects objects_bucketId_fkey; Type: FK CONSTRAINT; Schema: storage; Owner: supabase_storage_admin
--

ALTER TABLE ONLY storage.objects
    ADD CONSTRAINT "objects_bucketId_fkey" FOREIGN KEY (bucket_id) REFERENCES storage.buckets(id);


--
-- Name: s3_multipart_uploads s3_multipart_uploads_bucket_id_fkey; Type: FK CONSTRAINT; Schema: storage; Owner: supabase_storage_admin
--

ALTER TABLE ONLY storage.s3_multipart_uploads
    ADD CONSTRAINT s3_multipart_uploads_bucket_id_fkey FOREIGN KEY (bucket_id) REFERENCES storage.buckets(id);


--
-- Name: s3_multipart_uploads_parts s3_multipart_uploads_parts_bucket_id_fkey; Type: FK CONSTRAINT; Schema: storage; Owner: supabase_storage_admin
--

ALTER TABLE ONLY storage.s3_multipart_uploads_parts
    ADD CONSTRAINT s3_multipart_uploads_parts_bucket_id_fkey FOREIGN KEY (bucket_id) REFERENCES storage.buckets(id);


--
-- Name: s3_multipart_uploads_parts s3_multipart_uploads_parts_upload_id_fkey; Type: FK CONSTRAINT; Schema: storage; Owner: supabase_storage_admin
--

ALTER TABLE ONLY storage.s3_multipart_uploads_parts
    ADD CONSTRAINT s3_multipart_uploads_parts_upload_id_fkey FOREIGN KEY (upload_id) REFERENCES storage.s3_multipart_uploads(id) ON DELETE CASCADE;


--
-- Name: vector_indexes vector_indexes_bucket_id_fkey; Type: FK CONSTRAINT; Schema: storage; Owner: supabase_storage_admin
--

ALTER TABLE ONLY storage.vector_indexes
    ADD CONSTRAINT vector_indexes_bucket_id_fkey FOREIGN KEY (bucket_id) REFERENCES storage.buckets_vectors(id);


--
-- Name: audit_log_entries; Type: ROW SECURITY; Schema: auth; Owner: supabase_auth_admin
--

ALTER TABLE auth.audit_log_entries ENABLE ROW LEVEL SECURITY;

--
-- Name: flow_state; Type: ROW SECURITY; Schema: auth; Owner: supabase_auth_admin
--

ALTER TABLE auth.flow_state ENABLE ROW LEVEL SECURITY;

--
-- Name: identities; Type: ROW SECURITY; Schema: auth; Owner: supabase_auth_admin
--

ALTER TABLE auth.identities ENABLE ROW LEVEL SECURITY;

--
-- Name: instances; Type: ROW SECURITY; Schema: auth; Owner: supabase_auth_admin
--

ALTER TABLE auth.instances ENABLE ROW LEVEL SECURITY;

--
-- Name: mfa_amr_claims; Type: ROW SECURITY; Schema: auth; Owner: supabase_auth_admin
--

ALTER TABLE auth.mfa_amr_claims ENABLE ROW LEVEL SECURITY;

--
-- Name: mfa_challenges; Type: ROW SECURITY; Schema: auth; Owner: supabase_auth_admin
--

ALTER TABLE auth.mfa_challenges ENABLE ROW LEVEL SECURITY;

--
-- Name: mfa_factors; Type: ROW SECURITY; Schema: auth; Owner: supabase_auth_admin
--

ALTER TABLE auth.mfa_factors ENABLE ROW LEVEL SECURITY;

--
-- Name: one_time_tokens; Type: ROW SECURITY; Schema: auth; Owner: supabase_auth_admin
--

ALTER TABLE auth.one_time_tokens ENABLE ROW LEVEL SECURITY;

--
-- Name: refresh_tokens; Type: ROW SECURITY; Schema: auth; Owner: supabase_auth_admin
--

ALTER TABLE auth.refresh_tokens ENABLE ROW LEVEL SECURITY;

--
-- Name: saml_providers; Type: ROW SECURITY; Schema: auth; Owner: supabase_auth_admin
--

ALTER TABLE auth.saml_providers ENABLE ROW LEVEL SECURITY;

--
-- Name: saml_relay_states; Type: ROW SECURITY; Schema: auth; Owner: supabase_auth_admin
--

ALTER TABLE auth.saml_relay_states ENABLE ROW LEVEL SECURITY;

--
-- Name: schema_migrations; Type: ROW SECURITY; Schema: auth; Owner: supabase_auth_admin
--

ALTER TABLE auth.schema_migrations ENABLE ROW LEVEL SECURITY;

--
-- Name: sessions; Type: ROW SECURITY; Schema: auth; Owner: supabase_auth_admin
--

ALTER TABLE auth.sessions ENABLE ROW LEVEL SECURITY;

--
-- Name: sso_domains; Type: ROW SECURITY; Schema: auth; Owner: supabase_auth_admin
--

ALTER TABLE auth.sso_domains ENABLE ROW LEVEL SECURITY;

--
-- Name: sso_providers; Type: ROW SECURITY; Schema: auth; Owner: supabase_auth_admin
--

ALTER TABLE auth.sso_providers ENABLE ROW LEVEL SECURITY;

--
-- Name: users; Type: ROW SECURITY; Schema: auth; Owner: supabase_auth_admin
--

ALTER TABLE auth.users ENABLE ROW LEVEL SECURITY;

--
-- Name: cameras Admins and managers can delete cameras; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY "Admins and managers can delete cameras" ON public.cameras FOR DELETE USING ((EXISTS ( SELECT 1
   FROM (public.user_roles ur
     JOIN public.branches b ON ((ur.organization_id = b.organization_id)))
  WHERE ((ur.user_id = auth.uid()) AND (b.id = cameras.branch_id) AND (ur.role = ANY (ARRAY['admin'::public.user_role, 'manager'::public.user_role]))))));


--
-- Name: security_zones Admins and managers can delete security zones; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY "Admins and managers can delete security zones" ON public.security_zones FOR DELETE USING ((public.is_current_user_super_admin() OR (EXISTS ( SELECT 1
   FROM (public.user_roles ur
     JOIN public.branches b ON ((security_zones.branch_id = b.id)))
  WHERE ((ur.user_id = auth.uid()) AND (ur.organization_id = b.organization_id) AND (ur.role = ANY (ARRAY['company_admin'::public.user_role, 'branch_manager'::public.user_role]))))) OR (EXISTS ( SELECT 1
   FROM public.user_branch_access uba
  WHERE ((uba.user_id = auth.uid()) AND (uba.branch_id = security_zones.branch_id))))));


--
-- Name: aman_instances Admins and managers can manage Aman instances; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY "Admins and managers can manage Aman instances" ON public.aman_instances USING ((EXISTS ( SELECT 1
   FROM public.user_roles ur
  WHERE ((ur.user_id = auth.uid()) AND (ur.organization_id = aman_instances.organization_id) AND (ur.role = ANY (ARRAY['admin'::public.user_role, 'manager'::public.user_role])))))) WITH CHECK ((EXISTS ( SELECT 1
   FROM public.user_roles ur
  WHERE ((ur.user_id = auth.uid()) AND (ur.organization_id = aman_instances.organization_id) AND (ur.role = ANY (ARRAY['admin'::public.user_role, 'manager'::public.user_role]))))));


--
-- Name: camera_event_assignments Admins and managers can manage camera event assignments; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY "Admins and managers can manage camera event assignments" ON public.camera_event_assignments TO authenticated USING ((EXISTS ( SELECT 1
   FROM ((public.cameras c
     JOIN public.branches b ON ((c.branch_id = b.id)))
     JOIN public.user_roles ur ON ((ur.organization_id = b.organization_id)))
  WHERE ((c.id = camera_event_assignments.camera_id) AND (ur.user_id = auth.uid()) AND (ur.role = ANY (ARRAY['admin'::public.user_role, 'manager'::public.user_role]))))));


--
-- Name: detection_rules Admins and managers can manage detection rules; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY "Admins and managers can manage detection rules" ON public.detection_rules USING ((EXISTS ( SELECT 1
   FROM public.user_roles ur
  WHERE ((ur.user_id = auth.uid()) AND (ur.organization_id = detection_rules.organization_id) AND (ur.role = ANY (ARRAY['admin'::public.user_role, 'manager'::public.user_role]))))));


--
-- Name: form_assignments Admins and managers can manage form assignments; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY "Admins and managers can manage form assignments" ON public.form_assignments USING ((EXISTS ( SELECT 1
   FROM public.user_roles ur
  WHERE ((ur.user_id = auth.uid()) AND (ur.organization_id = form_assignments.organization_id) AND (ur.role = ANY (ARRAY['admin'::public.user_role, 'manager'::public.user_role]))))));


--
-- Name: user_group_members Admins and managers can manage group members; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY "Admins and managers can manage group members" ON public.user_group_members USING ((EXISTS ( SELECT 1
   FROM (public.user_groups ug
     JOIN public.user_roles ur ON ((ur.organization_id = ug.organization_id)))
  WHERE ((ug.id = user_group_members.group_id) AND (ur.user_id = auth.uid()) AND (ur.role = ANY (ARRAY['admin'::public.user_role, 'manager'::public.user_role]))))));


--
-- Name: user_groups Admins and managers can manage groups; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY "Admins and managers can manage groups" ON public.user_groups USING ((EXISTS ( SELECT 1
   FROM public.user_roles ur
  WHERE ((ur.user_id = auth.uid()) AND (ur.organization_id = user_groups.organization_id) AND (ur.role = ANY (ARRAY['admin'::public.user_role, 'manager'::public.user_role]))))));


--
-- Name: cameras Admins and managers can update cameras; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY "Admins and managers can update cameras" ON public.cameras FOR UPDATE USING ((EXISTS ( SELECT 1
   FROM (public.user_roles ur
     JOIN public.branches b ON ((ur.organization_id = b.organization_id)))
  WHERE ((ur.user_id = auth.uid()) AND (b.id = cameras.branch_id) AND (ur.role = ANY (ARRAY['admin'::public.user_role, 'manager'::public.user_role]))))));


--
-- Name: security_zones Admins and managers can update security zones; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY "Admins and managers can update security zones" ON public.security_zones FOR UPDATE USING ((public.is_current_user_super_admin() OR (EXISTS ( SELECT 1
   FROM (public.user_roles ur
     JOIN public.branches b ON ((security_zones.branch_id = b.id)))
  WHERE ((ur.user_id = auth.uid()) AND (ur.organization_id = b.organization_id) AND (ur.role = ANY (ARRAY['company_admin'::public.user_role, 'branch_manager'::public.user_role]))))) OR (EXISTS ( SELECT 1
   FROM public.user_branch_access uba
  WHERE ((uba.user_id = auth.uid()) AND (uba.branch_id = security_zones.branch_id))))));


--
-- Name: form_submissions Admins and managers can view submissions in their organization; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY "Admins and managers can view submissions in their organization" ON public.form_submissions FOR SELECT USING ((EXISTS ( SELECT 1
   FROM (public.form_assignments fa
     JOIN public.user_roles ur ON ((ur.organization_id = fa.organization_id)))
  WHERE ((fa.id = form_submissions.form_assignment_id) AND (ur.user_id = auth.uid()) AND (ur.role = ANY (ARRAY['admin'::public.user_role, 'manager'::public.user_role]))))));


--
-- Name: ai_models Admins can manage AI models; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY "Admins can manage AI models" ON public.ai_models USING ((EXISTS ( SELECT 1
   FROM public.user_roles ur
  WHERE ((ur.user_id = auth.uid()) AND (ur.role = 'admin'::public.user_role)))));


--
-- Name: frigate_alert_rules Admins can manage alert rules in their organization cameras; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY "Admins can manage alert rules in their organization cameras" ON public.frigate_alert_rules USING ((EXISTS ( SELECT 1
   FROM ((public.cameras c
     JOIN public.branches b ON ((c.branch_id = b.id)))
     JOIN public.user_roles ur ON ((ur.organization_id = b.organization_id)))
  WHERE ((c.id = frigate_alert_rules.camera_id) AND (ur.user_id = auth.uid()) AND (ur.role = ANY (ARRAY['admin'::public.user_role, 'manager'::public.user_role]))))));


--
-- Name: frigate_faces Admins can manage faces in their organization; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY "Admins can manage faces in their organization" ON public.frigate_faces USING ((EXISTS ( SELECT 1
   FROM ((public.cameras c
     JOIN public.branches b ON ((c.branch_id = b.id)))
     JOIN public.user_roles ur ON ((ur.organization_id = b.organization_id)))
  WHERE ((c.id = frigate_faces.camera_id) AND (ur.user_id = auth.uid()) AND (ur.role = ANY (ARRAY['admin'::public.user_role, 'manager'::public.user_role]))))));


--
-- Name: frigate_zones Admins can manage zones in their organization cameras; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY "Admins can manage zones in their organization cameras" ON public.frigate_zones USING ((EXISTS ( SELECT 1
   FROM ((public.cameras c
     JOIN public.branches b ON ((c.branch_id = b.id)))
     JOIN public.user_roles ur ON ((ur.organization_id = b.organization_id)))
  WHERE ((c.id = frigate_zones.camera_id) AND (ur.user_id = auth.uid()) AND (ur.role = ANY (ARRAY['admin'::public.user_role, 'manager'::public.user_role]))))));


--
-- Name: chatbot_knowledge_base Anyone can view active knowledge base; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY "Anyone can view active knowledge base" ON public.chatbot_knowledge_base FOR SELECT USING ((is_active = true));


--
-- Name: legal_documents Anyone can view legal documents; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY "Anyone can view legal documents" ON public.legal_documents FOR SELECT USING (true);


--
-- Name: screen_permissions Authenticated users can view active screen permissions; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY "Authenticated users can view active screen permissions" ON public.screen_permissions FOR SELECT USING ((COALESCE(is_active, true) = true));


--
-- Name: form_submissions Branch managers can update branch form submissions; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY "Branch managers can update branch form submissions" ON public.form_submissions FOR UPDATE USING (public.branch_manager_can_view_submission(id)) WITH CHECK (public.branch_manager_can_view_submission(id));


--
-- Name: form_submissions Branch managers can view branch form submissions; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY "Branch managers can view branch form submissions" ON public.form_submissions FOR SELECT USING (public.branch_manager_can_view_submission(id));


--
-- Name: pinned_dashboards Branch managers can view branch pinned dashboards; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY "Branch managers can view branch pinned dashboards" ON public.pinned_dashboards FOR SELECT USING ((EXISTS ( SELECT 1
   FROM (public.aman_instances ai
     JOIN public.branch_roles br ON ((br.branch_id = ai.branch_id)))
  WHERE ((ai.id = pinned_dashboards.instance_id) AND (br.user_id = auth.uid()) AND (br.role = 'branch_manager'::text)))));


--
-- Name: user_roles Branch managers can view branch user roles; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY "Branch managers can view branch user roles" ON public.user_roles FOR SELECT USING (public.current_user_is_branch_manager_for_user(user_id));


--
-- Name: user_branch_access Company admins can manage branch access in their organization; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY "Company admins can manage branch access in their organization" ON public.user_branch_access USING ((EXISTS ( SELECT 1
   FROM (public.user_roles ur
     JOIN public.branches b ON ((user_branch_access.branch_id = b.id)))
  WHERE ((ur.user_id = auth.uid()) AND (ur.organization_id = b.organization_id) AND (ur.role = ANY (ARRAY['super_admin'::public.user_role, 'company_admin'::public.user_role]))))));


--
-- Name: pinned_labels Labels: users can delete their own; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY "Labels: users can delete their own" ON public.pinned_labels FOR DELETE USING ((auth.uid() = user_id));


--
-- Name: pinned_labels Labels: users can insert their own; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY "Labels: users can insert their own" ON public.pinned_labels FOR INSERT WITH CHECK ((auth.uid() = user_id));


--
-- Name: pinned_labels Labels: users can update their own; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY "Labels: users can update their own" ON public.pinned_labels FOR UPDATE USING ((auth.uid() = user_id));


--
-- Name: pinned_labels Labels: users can view their own; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY "Labels: users can view their own" ON public.pinned_labels FOR SELECT USING ((auth.uid() = user_id));


--
-- Name: pinned_dashboards Org admins and managers can view org pinned dashboards; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY "Org admins and managers can view org pinned dashboards" ON public.pinned_dashboards FOR SELECT USING ((EXISTS ( SELECT 1
   FROM (public.aman_instances ai
     JOIN public.user_roles ur ON ((ur.organization_id = ai.organization_id)))
  WHERE ((ai.id = pinned_dashboards.instance_id) AND (ur.user_id = auth.uid()) AND (ur.role = ANY (ARRAY['admin'::public.user_role, 'manager'::public.user_role]))))));


--
-- Name: frigate_instances Org admins can manage frigate instances in their organization; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY "Org admins can manage frigate instances in their organization" ON public.frigate_instances USING ((EXISTS ( SELECT 1
   FROM (public.branches b
     JOIN public.user_roles ur ON ((ur.organization_id = b.organization_id)))
  WHERE ((b.id = frigate_instances.branch_id) AND (ur.user_id = auth.uid()) AND (ur.role = ANY (ARRAY['admin'::public.user_role, 'manager'::public.user_role]))))));


--
-- Name: subscribers Org admins can update subscribers; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY "Org admins can update subscribers" ON public.subscribers FOR UPDATE USING ((public.is_current_user_super_admin() OR (EXISTS ( SELECT 1
   FROM public.user_roles ur
  WHERE ((ur.user_id = auth.uid()) AND (ur.role = ANY (ARRAY['admin'::public.user_role, 'manager'::public.user_role]))))))) WITH CHECK ((public.is_current_user_super_admin() OR (EXISTS ( SELECT 1
   FROM public.user_roles ur
  WHERE ((ur.user_id = auth.uid()) AND (ur.role = ANY (ARRAY['admin'::public.user_role, 'manager'::public.user_role])))))));


--
-- Name: subscribers Org admins can view all subscribers; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY "Org admins can view all subscribers" ON public.subscribers FOR SELECT USING ((public.is_current_user_super_admin() OR (EXISTS ( SELECT 1
   FROM public.user_roles ur
  WHERE ((ur.user_id = auth.uid()) AND (ur.role = ANY (ARRAY['admin'::public.user_role, 'manager'::public.user_role])))))));


--
-- Name: subscribers Org admins can view org subscribers; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY "Org admins can view org subscribers" ON public.subscribers FOR SELECT USING ((EXISTS ( SELECT 1
   FROM public.user_roles ur
  WHERE ((ur.user_id = auth.uid()) AND (ur.organization_id = subscribers.organization_id) AND (ur.role = 'admin'::public.user_role)))));


--
-- Name: form_distribution_settings Org admins/managers can manage form distribution settings; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY "Org admins/managers can manage form distribution settings" ON public.form_distribution_settings TO authenticated USING ((EXISTS ( SELECT 1
   FROM (public.form_assignments fa
     JOIN public.user_roles ur ON ((ur.organization_id = fa.organization_id)))
  WHERE ((fa.workflow_form_id = form_distribution_settings.workflow_form_id) AND (ur.user_id = auth.uid()) AND (ur.role = ANY (ARRAY['admin'::public.user_role, 'manager'::public.user_role])))))) WITH CHECK ((EXISTS ( SELECT 1
   FROM (public.form_assignments fa
     JOIN public.user_roles ur ON ((ur.organization_id = fa.organization_id)))
  WHERE ((fa.workflow_form_id = form_distribution_settings.workflow_form_id) AND (ur.user_id = auth.uid()) AND (ur.role = ANY (ARRAY['admin'::public.user_role, 'manager'::public.user_role]))))));


--
-- Name: form_submissions Org admins/managers can update submissions; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY "Org admins/managers can update submissions" ON public.form_submissions FOR UPDATE USING ((EXISTS ( SELECT 1
   FROM (public.form_assignments fa
     JOIN public.user_roles ur ON ((ur.organization_id = fa.organization_id)))
  WHERE ((fa.id = form_submissions.form_assignment_id) AND (ur.user_id = auth.uid()) AND (ur.role = ANY (ARRAY['admin'::public.user_role, 'manager'::public.user_role])))))) WITH CHECK ((EXISTS ( SELECT 1
   FROM (public.form_assignments fa
     JOIN public.user_roles ur ON ((ur.organization_id = fa.organization_id)))
  WHERE ((fa.id = form_submissions.form_assignment_id) AND (ur.user_id = auth.uid()) AND (ur.role = ANY (ARRAY['admin'::public.user_role, 'manager'::public.user_role]))))));


--
-- Name: user_roles Org admins/managers can view org user roles; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY "Org admins/managers can view org user roles" ON public.user_roles FOR SELECT USING (public.current_user_is_org_admin_or_manager(organization_id));


--
-- Name: chat_thread_participants Org members can add participants to their org threads; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY "Org members can add participants to their org threads" ON public.chat_thread_participants FOR INSERT WITH CHECK ((EXISTS ( SELECT 1
   FROM (public.chat_threads t
     JOIN public.user_roles ur ON ((ur.organization_id = t.organization_id)))
  WHERE ((t.id = chat_thread_participants.thread_id) AND (ur.user_id = auth.uid())))));


--
-- Name: chat_threads Org members can create threads in their org; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY "Org members can create threads in their org" ON public.chat_threads FOR INSERT WITH CHECK ((organization_id IN ( SELECT user_roles.organization_id
   FROM public.user_roles
  WHERE (user_roles.user_id = auth.uid()))));


--
-- Name: chat_threads Org members can update org threads; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY "Org members can update org threads" ON public.chat_threads FOR UPDATE USING ((EXISTS ( SELECT 1
   FROM public.user_roles ur
  WHERE ((ur.user_id = auth.uid()) AND (ur.organization_id = chat_threads.organization_id)))));


--
-- Name: form_distribution_settings Org members can view form distribution settings; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY "Org members can view form distribution settings" ON public.form_distribution_settings FOR SELECT TO authenticated USING ((EXISTS ( SELECT 1
   FROM (public.form_assignments fa
     JOIN public.user_roles ur ON ((ur.organization_id = fa.organization_id)))
  WHERE ((fa.workflow_form_id = form_distribution_settings.workflow_form_id) AND (ur.user_id = auth.uid())))));


--
-- Name: chat_threads Org members can view org threads; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY "Org members can view org threads" ON public.chat_threads FOR SELECT USING ((EXISTS ( SELECT 1
   FROM public.user_roles ur
  WHERE ((ur.user_id = auth.uid()) AND (ur.organization_id = chat_threads.organization_id)))));


--
-- Name: chat_thread_participants Org members can view participants for org threads; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY "Org members can view participants for org threads" ON public.chat_thread_participants FOR SELECT USING ((EXISTS ( SELECT 1
   FROM (public.chat_threads t
     JOIN public.user_roles ur ON ((ur.organization_id = t.organization_id)))
  WHERE ((t.id = chat_thread_participants.thread_id) AND (ur.user_id = auth.uid())))));


--
-- Name: chat_messages Participants can send messages to their threads; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY "Participants can send messages to their threads" ON public.chat_messages FOR INSERT WITH CHECK (((sender_id = auth.uid()) AND (EXISTS ( SELECT 1
   FROM public.chat_thread_participants p
  WHERE ((p.thread_id = chat_messages.thread_id) AND (p.user_id = auth.uid())))) AND (organization_id = ( SELECT t.organization_id
   FROM public.chat_threads t
  WHERE (t.id = chat_messages.thread_id)))));


--
-- Name: chat_messages Participants can view messages in their threads; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY "Participants can view messages in their threads" ON public.chat_messages FOR SELECT USING ((EXISTS ( SELECT 1
   FROM public.chat_thread_participants p
  WHERE ((p.thread_id = chat_messages.thread_id) AND (p.user_id = auth.uid())))));


--
-- Name: form_submissions Representatives can manage their own submissions; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY "Representatives can manage their own submissions" ON public.form_submissions USING ((EXISTS ( SELECT 1
   FROM (public.form_assignments fa
     JOIN public.user_roles ur ON ((ur.id = fa.representative_id)))
  WHERE ((fa.id = form_submissions.form_assignment_id) AND (ur.user_id = auth.uid())))));


--
-- Name: form_assignments Representatives can view their assignments; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY "Representatives can view their assignments" ON public.form_assignments FOR SELECT USING ((representative_id IN ( SELECT user_roles.id
   FROM public.user_roles
  WHERE (user_roles.user_id = auth.uid()))));


--
-- Name: ai_analysis_logs Super admin can manage AI analysis logs; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY "Super admin can manage AI analysis logs" ON public.ai_analysis_logs USING (public.is_current_user_super_admin()) WITH CHECK (public.is_current_user_super_admin());


--
-- Name: alert_template_events Super admin can manage alert template events; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY "Super admin can manage alert template events" ON public.alert_template_events TO authenticated USING (public.is_current_user_super_admin());


--
-- Name: alert_template_industries Super admin can manage alert template industries; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY "Super admin can manage alert template industries" ON public.alert_template_industries USING (public.is_current_user_super_admin());


--
-- Name: aman_instances Super admin can manage all Aman instances; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY "Super admin can manage all Aman instances" ON public.aman_instances USING (public.is_current_user_super_admin()) WITH CHECK (public.is_current_user_super_admin());


--
-- Name: alert_templates Super admin can manage all alert templates; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY "Super admin can manage all alert templates" ON public.alert_templates TO authenticated USING (public.is_current_user_super_admin());


--
-- Name: user_branch_access Super admin can manage all branch access; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY "Super admin can manage all branch access" ON public.user_branch_access USING (public.is_current_user_super_admin());


--
-- Name: camera_alert_assignments Super admin can manage all camera alert assignments; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY "Super admin can manage all camera alert assignments" ON public.camera_alert_assignments TO authenticated USING (public.is_current_user_super_admin());


--
-- Name: chat_threads Super admin can manage all chat threads; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY "Super admin can manage all chat threads" ON public.chat_threads USING (public.is_current_user_super_admin()) WITH CHECK (public.is_current_user_super_admin());


--
-- Name: event_types Super admin can manage all event types; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY "Super admin can manage all event types" ON public.event_types TO authenticated USING (public.is_current_user_super_admin());


--
-- Name: form_distribution_settings Super admin can manage all form distribution settings; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY "Super admin can manage all form distribution settings" ON public.form_distribution_settings TO authenticated USING (public.is_current_user_super_admin()) WITH CHECK (public.is_current_user_super_admin());


--
-- Name: form_submissions Super admin can manage all form submissions; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY "Super admin can manage all form submissions" ON public.form_submissions USING (public.is_current_user_super_admin()) WITH CHECK (public.is_current_user_super_admin());


--
-- Name: frigate_alert_rules Super admin can manage all frigate alert rules; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY "Super admin can manage all frigate alert rules" ON public.frigate_alert_rules USING (public.is_current_user_super_admin());


--
-- Name: frigate_faces Super admin can manage all frigate faces; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY "Super admin can manage all frigate faces" ON public.frigate_faces USING (public.is_current_user_super_admin());


--
-- Name: frigate_instances Super admin can manage all frigate instances; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY "Super admin can manage all frigate instances" ON public.frigate_instances USING (public.is_current_user_super_admin());


--
-- Name: frigate_license_plates Super admin can manage all frigate license plates; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY "Super admin can manage all frigate license plates" ON public.frigate_license_plates USING (public.is_current_user_super_admin());


--
-- Name: frigate_timeline Super admin can manage all frigate timeline; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY "Super admin can manage all frigate timeline" ON public.frigate_timeline USING (public.is_current_user_super_admin());


--
-- Name: frigate_zones Super admin can manage all frigate zones; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY "Super admin can manage all frigate zones" ON public.frigate_zones USING (public.is_current_user_super_admin());


--
-- Name: industries Super admin can manage all industries; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY "Super admin can manage all industries" ON public.industries USING (public.is_current_user_super_admin());


--
-- Name: organizations Super admin can manage all organizations; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY "Super admin can manage all organizations" ON public.organizations USING (public.is_current_user_super_admin());


--
-- Name: chat_thread_participants Super admin can manage all participants; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY "Super admin can manage all participants" ON public.chat_thread_participants USING (public.is_current_user_super_admin()) WITH CHECK (public.is_current_user_super_admin());


--
-- Name: subscribers Super admin can manage all subscribers; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY "Super admin can manage all subscribers" ON public.subscribers USING (public.is_current_user_super_admin()) WITH CHECK (public.is_current_user_super_admin());


--
-- Name: user_roles Super admin can manage all user roles; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY "Super admin can manage all user roles" ON public.user_roles USING (public.is_current_user_super_admin());


--
-- Name: branch_roles Super admin can manage branch roles; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY "Super admin can manage branch roles" ON public.branch_roles USING (public.is_current_user_super_admin()) WITH CHECK (public.is_current_user_super_admin());


--
-- Name: camera_sources Super admin can manage camera sources; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY "Super admin can manage camera sources" ON public.camera_sources USING (public.is_current_user_super_admin());


--
-- Name: form_distribution_settings Super admin can manage form distribution; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY "Super admin can manage form distribution" ON public.form_distribution_settings USING (public.is_current_user_super_admin());


--
-- Name: chatbot_knowledge_base Super admin can manage knowledge base; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY "Super admin can manage knowledge base" ON public.chatbot_knowledge_base USING (public.is_current_user_super_admin());


--
-- Name: notification_labels Super admin can manage notification labels; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY "Super admin can manage notification labels" ON public.notification_labels USING (public.is_current_user_super_admin()) WITH CHECK (public.is_current_user_super_admin());


--
-- Name: notification_methods Super admin can manage notification methods; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY "Super admin can manage notification methods" ON public.notification_methods USING (public.is_current_user_super_admin());


--
-- Name: screen_permissions Super admin can manage screen permissions; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY "Super admin can manage screen permissions" ON public.screen_permissions USING (public.is_current_user_super_admin()) WITH CHECK (public.is_current_user_super_admin());


--
-- Name: storage_configs Super admin can manage storage configs; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY "Super admin can manage storage configs" ON public.storage_configs TO authenticated USING (public.is_current_user_super_admin());


--
-- Name: workflow_forms Super admin can manage workflow forms; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY "Super admin can manage workflow forms" ON public.workflow_forms USING (public.is_current_user_super_admin());


--
-- Name: branches Super admin can view all branches; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY "Super admin can view all branches" ON public.branches FOR SELECT USING (public.is_current_user_super_admin());


--
-- Name: form_assignments Super admin can view all form assignments; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY "Super admin can view all form assignments" ON public.form_assignments FOR SELECT USING (public.is_current_user_super_admin());


--
-- Name: pinned_dashboards Super admin can view all pinned dashboards; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY "Super admin can view all pinned dashboards" ON public.pinned_dashboards FOR SELECT USING (public.is_current_user_super_admin());


--
-- Name: chat_messages Super admin can view and manage all messages; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY "Super admin can view and manage all messages" ON public.chat_messages USING (public.is_current_user_super_admin()) WITH CHECK (public.is_current_user_super_admin());


--
-- Name: legal_documents Super admins can manage legal documents; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY "Super admins can manage legal documents" ON public.legal_documents USING ((EXISTS ( SELECT 1
   FROM public.user_roles ur
  WHERE ((ur.user_id = auth.uid()) AND (ur.role = 'admin'::public.user_role)))));


--
-- Name: cameras System can insert cameras during sync; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY "System can insert cameras during sync" ON public.cameras FOR INSERT WITH CHECK ((((auth.jwt() ->> 'sub'::text) IS NOT NULL) AND (branch_id IS NOT NULL)));


--
-- Name: events System can insert events during sync; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY "System can insert events during sync" ON public.events FOR INSERT WITH CHECK ((((auth.jwt() ->> 'sub'::text) IS NOT NULL) AND ((metadata ->> 'frigate_instance_id'::text) IS NOT NULL)));


--
-- Name: frigate_previews System can insert frigate_previews; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY "System can insert frigate_previews" ON public.frigate_previews FOR INSERT WITH CHECK (((auth.jwt() ->> 'sub'::text) IS NOT NULL));


--
-- Name: frigate_recordings System can insert frigate_recordings; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY "System can insert frigate_recordings" ON public.frigate_recordings FOR INSERT WITH CHECK (((auth.jwt() ->> 'sub'::text) IS NOT NULL));


--
-- Name: frigate_reviews System can insert frigate_reviews; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY "System can insert frigate_reviews" ON public.frigate_reviews FOR INSERT WITH CHECK (((auth.jwt() ->> 'sub'::text) IS NOT NULL));


--
-- Name: frigate_timeline System can insert frigate_timeline; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY "System can insert frigate_timeline" ON public.frigate_timeline FOR INSERT WITH CHECK (((auth.jwt() ->> 'sub'::text) IS NOT NULL));


--
-- Name: subscribers System can insert new subscribers; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY "System can insert new subscribers" ON public.subscribers FOR INSERT WITH CHECK ((auth.uid() = user_id));


--
-- Name: security_zones Users can create security zones in their organization; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY "Users can create security zones in their organization" ON public.security_zones FOR INSERT WITH CHECK ((public.is_current_user_super_admin() OR (EXISTS ( SELECT 1
   FROM (public.user_roles ur
     JOIN public.branches b ON ((security_zones.branch_id = b.id)))
  WHERE ((ur.user_id = auth.uid()) AND (ur.organization_id = b.organization_id) AND (ur.role = ANY (ARRAY['company_admin'::public.user_role, 'branch_manager'::public.user_role]))))) OR (EXISTS ( SELECT 1
   FROM public.user_branch_access uba
  WHERE ((uba.user_id = auth.uid()) AND (uba.branch_id = security_zones.branch_id))))));


--
-- Name: subscribers Users can create their own subscriptions; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY "Users can create their own subscriptions" ON public.subscribers FOR INSERT WITH CHECK ((user_id = auth.uid()));


--
-- Name: frigate_exports Users can delete frigate_exports; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY "Users can delete frigate_exports" ON public.frigate_exports FOR DELETE USING ((auth.role() = 'authenticated'::text));


--
-- Name: frigate_previews Users can delete frigate_previews; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY "Users can delete frigate_previews" ON public.frigate_previews FOR DELETE USING ((auth.role() = 'authenticated'::text));


--
-- Name: frigate_recordings Users can delete frigate_recordings; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY "Users can delete frigate_recordings" ON public.frigate_recordings FOR DELETE USING ((auth.role() = 'authenticated'::text));


--
-- Name: frigate_reviews Users can delete frigate_reviews; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY "Users can delete frigate_reviews" ON public.frigate_reviews FOR DELETE USING ((auth.role() = 'authenticated'::text));


--
-- Name: frigate_exports Users can insert frigate_exports; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY "Users can insert frigate_exports" ON public.frigate_exports FOR INSERT WITH CHECK ((auth.role() = 'authenticated'::text));


--
-- Name: frigate_previews Users can insert frigate_previews; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY "Users can insert frigate_previews" ON public.frigate_previews FOR INSERT WITH CHECK ((auth.role() = 'authenticated'::text));


--
-- Name: frigate_recordings Users can insert frigate_recordings; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY "Users can insert frigate_recordings" ON public.frigate_recordings FOR INSERT WITH CHECK ((auth.role() = 'authenticated'::text));


--
-- Name: frigate_reviews Users can insert frigate_reviews; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY "Users can insert frigate_reviews" ON public.frigate_reviews FOR INSERT WITH CHECK ((auth.role() = 'authenticated'::text));


--
-- Name: network_scan_results Users can insert their own scan results; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY "Users can insert their own scan results" ON public.network_scan_results FOR INSERT WITH CHECK ((user_id = auth.uid()));


--
-- Name: user_preferences Users can manage their own preferences; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY "Users can manage their own preferences" ON public.user_preferences USING ((user_id = auth.uid()));


--
-- Name: events Users can update event reviewed; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY "Users can update event reviewed" ON public.events FOR UPDATE USING ((EXISTS ( SELECT 1
   FROM ((public.cameras c
     JOIN public.branches b ON ((c.branch_id = b.id)))
     JOIN public.user_roles ur ON ((ur.organization_id = b.organization_id)))
  WHERE ((c.id = events.camera_id) AND (ur.user_id = auth.uid()))))) WITH CHECK ((reviewed = true));


--
-- Name: frigate_exports Users can update frigate_exports; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY "Users can update frigate_exports" ON public.frigate_exports FOR UPDATE USING ((auth.role() = 'authenticated'::text));


--
-- Name: frigate_previews Users can update frigate_previews; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY "Users can update frigate_previews" ON public.frigate_previews FOR UPDATE USING ((auth.role() = 'authenticated'::text));


--
-- Name: frigate_recordings Users can update frigate_recordings; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY "Users can update frigate_recordings" ON public.frigate_recordings FOR UPDATE USING ((auth.role() = 'authenticated'::text));


--
-- Name: frigate_reviews Users can update frigate_reviews; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY "Users can update frigate_reviews" ON public.frigate_reviews FOR UPDATE USING ((auth.role() = 'authenticated'::text));


--
-- Name: subscribers Users can update their own subscription; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY "Users can update their own subscription" ON public.subscribers FOR UPDATE USING ((user_id = auth.uid()));


--
-- Name: subscribers Users can update their own subscriptions; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY "Users can update their own subscriptions" ON public.subscribers FOR UPDATE USING ((user_id = auth.uid())) WITH CHECK ((user_id = auth.uid()));


--
-- Name: ai_analysis_logs Users can view AI analysis logs in their org; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY "Users can view AI analysis logs in their org" ON public.ai_analysis_logs FOR SELECT USING ((EXISTS ( SELECT 1
   FROM ((public.cameras c
     JOIN public.branches b ON ((c.branch_id = b.id)))
     JOIN public.user_roles ur ON ((ur.organization_id = b.organization_id)))
  WHERE ((c.id = ai_analysis_logs.camera_id) AND (ur.user_id = auth.uid())))));


--
-- Name: ai_models Users can view AI models in their organization; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY "Users can view AI models in their organization" ON public.ai_models FOR SELECT USING ((EXISTS ( SELECT 1
   FROM public.user_roles ur
  WHERE ((ur.user_id = auth.uid()) AND (ur.organization_id IS NOT NULL)))));


--
-- Name: aman_instances Users can view Aman instances in their organization; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY "Users can view Aman instances in their organization" ON public.aman_instances FOR SELECT USING ((EXISTS ( SELECT 1
   FROM public.user_roles ur
  WHERE ((ur.user_id = auth.uid()) AND (ur.organization_id = aman_instances.organization_id)))));


--
-- Name: notification_labels Users can view active notification labels; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY "Users can view active notification labels" ON public.notification_labels FOR SELECT USING ((is_active = true));


--
-- Name: workflow_forms Users can view active workflow forms; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY "Users can view active workflow forms" ON public.workflow_forms FOR SELECT USING ((is_active = true));


--
-- Name: frigate_alert_rules Users can view alert rules in their organization cameras; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY "Users can view alert rules in their organization cameras" ON public.frigate_alert_rules FOR SELECT USING ((EXISTS ( SELECT 1
   FROM ((public.cameras c
     JOIN public.branches b ON ((c.branch_id = b.id)))
     JOIN public.user_roles ur ON ((ur.organization_id = b.organization_id)))
  WHERE ((c.id = frigate_alert_rules.camera_id) AND (ur.user_id = auth.uid())))));


--
-- Name: alert_template_events Users can view alert template events; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY "Users can view alert template events" ON public.alert_template_events FOR SELECT TO authenticated USING (true);


--
-- Name: alert_template_industries Users can view alert template industries in their organization; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY "Users can view alert template industries in their organization" ON public.alert_template_industries FOR SELECT USING ((EXISTS ( SELECT 1
   FROM (public.user_roles ur
     JOIN public.organizations o ON ((o.id = ur.organization_id)))
  WHERE ((ur.user_id = auth.uid()) AND (o.industry_id = alert_template_industries.industry_id)))));


--
-- Name: alert_templates Users can view alert templates for their industry; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY "Users can view alert templates for their industry" ON public.alert_templates FOR SELECT USING ((public.is_current_user_super_admin() OR (EXISTS ( SELECT 1
   FROM ((public.alert_template_industries ati
     JOIN public.user_roles ur ON ((ur.user_id = auth.uid())))
     JOIN public.organizations o ON ((o.id = ur.organization_id)))
  WHERE ((ati.alert_template_id = alert_templates.id) AND (ati.industry_id = o.industry_id))))));


--
-- Name: frigate_exports Users can view all frigate_exports; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY "Users can view all frigate_exports" ON public.frigate_exports FOR SELECT USING ((auth.role() = 'authenticated'::text));


--
-- Name: frigate_previews Users can view all frigate_previews; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY "Users can view all frigate_previews" ON public.frigate_previews FOR SELECT USING ((auth.role() = 'authenticated'::text));


--
-- Name: frigate_recordings Users can view all frigate_recordings; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY "Users can view all frigate_recordings" ON public.frigate_recordings FOR SELECT USING ((auth.role() = 'authenticated'::text));


--
-- Name: frigate_reviews Users can view all frigate_reviews; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY "Users can view all frigate_reviews" ON public.frigate_reviews FOR SELECT USING ((auth.role() = 'authenticated'::text));


--
-- Name: industries Users can view all industries; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY "Users can view all industries" ON public.industries FOR SELECT USING (true);


--
-- Name: branches Users can view branches in their organization; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY "Users can view branches in their organization" ON public.branches FOR SELECT USING ((public.is_current_user_super_admin() OR (EXISTS ( SELECT 1
   FROM public.user_roles ur
  WHERE ((ur.user_id = auth.uid()) AND (ur.organization_id = branches.organization_id)))) OR (EXISTS ( SELECT 1
   FROM public.user_branch_access uba
  WHERE ((uba.user_id = auth.uid()) AND (uba.branch_id = branches.id))))));


--
-- Name: camera_alert_assignments Users can view camera alert assignments in their organization; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY "Users can view camera alert assignments in their organization" ON public.camera_alert_assignments FOR SELECT TO authenticated USING ((EXISTS ( SELECT 1
   FROM ((public.cameras c
     JOIN public.branches b ON ((c.branch_id = b.id)))
     JOIN public.user_roles ur ON ((ur.organization_id = b.organization_id)))
  WHERE ((c.id = camera_alert_assignments.camera_id) AND (ur.user_id = auth.uid())))));


--
-- Name: camera_event_assignments Users can view camera event assignments in their organization; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY "Users can view camera event assignments in their organization" ON public.camera_event_assignments FOR SELECT TO authenticated USING ((EXISTS ( SELECT 1
   FROM ((public.cameras c
     JOIN public.branches b ON ((c.branch_id = b.id)))
     JOIN public.user_roles ur ON ((ur.organization_id = b.organization_id)))
  WHERE ((c.id = camera_event_assignments.camera_id) AND (ur.user_id = auth.uid())))));


--
-- Name: camera_sources Users can view camera sources; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY "Users can view camera sources" ON public.camera_sources FOR SELECT USING (((auth.role() = 'authenticated'::text) AND (active = true)));


--
-- Name: cameras Users can view cameras in their organization; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY "Users can view cameras in their organization" ON public.cameras FOR SELECT TO authenticated USING ((public.is_current_user_super_admin() OR (EXISTS ( SELECT 1
   FROM (public.branches b
     JOIN public.user_roles ur ON ((ur.organization_id = b.organization_id)))
  WHERE ((b.id = cameras.branch_id) AND (ur.user_id = auth.uid()))))));


--
-- Name: detection_rules Users can view detection rules in their organization; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY "Users can view detection rules in their organization" ON public.detection_rules FOR SELECT USING ((EXISTS ( SELECT 1
   FROM public.user_roles ur
  WHERE ((ur.user_id = auth.uid()) AND (ur.organization_id = detection_rules.organization_id)))));


--
-- Name: event_types Users can view event types; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY "Users can view event types" ON public.event_types FOR SELECT TO authenticated USING ((enabled = true));


--
-- Name: events Users can view events in their organization; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY "Users can view events in their organization" ON public.events FOR SELECT USING ((EXISTS ( SELECT 1
   FROM (((public.user_roles ur
     JOIN public.cameras c ON ((events.camera_id = c.id)))
     JOIN public.branches b ON ((c.branch_id = b.id)))
     JOIN public.organizations o ON ((b.organization_id = o.id)))
  WHERE ((ur.user_id = auth.uid()) AND (ur.organization_id = o.id)))));


--
-- Name: frigate_faces Users can view faces in their organization cameras; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY "Users can view faces in their organization cameras" ON public.frigate_faces FOR SELECT USING ((EXISTS ( SELECT 1
   FROM ((public.cameras c
     JOIN public.branches b ON ((c.branch_id = b.id)))
     JOIN public.user_roles ur ON ((ur.organization_id = b.organization_id)))
  WHERE ((c.id = frigate_faces.camera_id) AND (ur.user_id = auth.uid())))));


--
-- Name: form_distribution_settings Users can view form distribution in their organization; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY "Users can view form distribution in their organization" ON public.form_distribution_settings FOR SELECT USING ((EXISTS ( SELECT 1
   FROM public.workflow_forms wf
  WHERE (wf.id = form_distribution_settings.workflow_form_id))));


--
-- Name: frigate_instances Users can view frigate instances in their organization; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY "Users can view frigate instances in their organization" ON public.frigate_instances FOR SELECT USING ((EXISTS ( SELECT 1
   FROM (public.branches b
     JOIN public.user_roles ur ON ((ur.organization_id = b.organization_id)))
  WHERE ((b.id = frigate_instances.branch_id) AND (ur.user_id = auth.uid())))));


--
-- Name: user_group_members Users can view group members in their organization; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY "Users can view group members in their organization" ON public.user_group_members FOR SELECT USING ((EXISTS ( SELECT 1
   FROM (public.user_groups ug
     JOIN public.user_roles ur ON ((ur.organization_id = ug.organization_id)))
  WHERE ((ug.id = user_group_members.group_id) AND (ur.user_id = auth.uid())))));


--
-- Name: user_groups Users can view groups in their organization; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY "Users can view groups in their organization" ON public.user_groups FOR SELECT USING ((EXISTS ( SELECT 1
   FROM public.user_roles ur
  WHERE ((ur.user_id = auth.uid()) AND (ur.organization_id = user_groups.organization_id)))));


--
-- Name: frigate_license_plates Users can view license plates in their organization cameras; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY "Users can view license plates in their organization cameras" ON public.frigate_license_plates FOR SELECT USING ((EXISTS ( SELECT 1
   FROM ((public.cameras c
     JOIN public.branches b ON ((c.branch_id = b.id)))
     JOIN public.user_roles ur ON ((ur.organization_id = b.organization_id)))
  WHERE ((c.id = frigate_license_plates.camera_id) AND (ur.user_id = auth.uid())))));


--
-- Name: notification_methods Users can view notification methods; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY "Users can view notification methods" ON public.notification_methods FOR SELECT USING ((enabled = true));


--
-- Name: security_zones Users can view security zones in their organization; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY "Users can view security zones in their organization" ON public.security_zones FOR SELECT USING ((public.is_current_user_super_admin() OR (EXISTS ( SELECT 1
   FROM (public.user_roles ur
     JOIN public.branches b ON ((security_zones.branch_id = b.id)))
  WHERE ((ur.user_id = auth.uid()) AND (ur.organization_id = b.organization_id)))) OR (EXISTS ( SELECT 1
   FROM public.user_branch_access uba
  WHERE ((uba.user_id = auth.uid()) AND (uba.branch_id = security_zones.branch_id))))));


--
-- Name: organizations Users can view their organization; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY "Users can view their organization" ON public.organizations FOR SELECT USING ((public.is_current_user_super_admin() OR (EXISTS ( SELECT 1
   FROM public.user_roles
  WHERE ((user_roles.user_id = auth.uid()) AND (user_roles.organization_id = organizations.id))))));


--
-- Name: user_branch_access Users can view their own branch access; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY "Users can view their own branch access" ON public.user_branch_access FOR SELECT USING ((user_id = auth.uid()));


--
-- Name: branch_roles Users can view their own branch roles; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY "Users can view their own branch roles" ON public.branch_roles FOR SELECT USING ((user_id = auth.uid()));


--
-- Name: user_roles Users can view their own roles; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY "Users can view their own roles" ON public.user_roles FOR SELECT USING ((user_id = auth.uid()));


--
-- Name: network_scan_results Users can view their own scan results; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY "Users can view their own scan results" ON public.network_scan_results FOR SELECT USING ((user_id = auth.uid()));


--
-- Name: subscribers Users can view their own subscription; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY "Users can view their own subscription" ON public.subscribers FOR SELECT USING ((user_id = auth.uid()));


--
-- Name: subscribers Users can view their own subscriptions; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY "Users can view their own subscriptions" ON public.subscribers FOR SELECT USING ((user_id = auth.uid()));


--
-- Name: frigate_timeline Users can view timeline in their organization cameras; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY "Users can view timeline in their organization cameras" ON public.frigate_timeline FOR SELECT USING ((EXISTS ( SELECT 1
   FROM ((public.cameras c
     JOIN public.branches b ON ((c.branch_id = b.id)))
     JOIN public.user_roles ur ON ((ur.organization_id = b.organization_id)))
  WHERE ((c.id = frigate_timeline.camera_id) AND (ur.user_id = auth.uid())))));


--
-- Name: frigate_zones Users can view zones in their organization cameras; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY "Users can view zones in their organization cameras" ON public.frigate_zones FOR SELECT USING ((EXISTS ( SELECT 1
   FROM ((public.cameras c
     JOIN public.branches b ON ((c.branch_id = b.id)))
     JOIN public.user_roles ur ON ((ur.organization_id = b.organization_id)))
  WHERE ((c.id = frigate_zones.camera_id) AND (ur.user_id = auth.uid())))));


--
-- Name: cameras Users with admin/manager role can insert cameras; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY "Users with admin/manager role can insert cameras" ON public.cameras FOR INSERT TO authenticated WITH CHECK ((public.is_current_user_super_admin() OR (EXISTS ( SELECT 1
   FROM (public.user_roles ur
     JOIN public.branches b ON ((b.organization_id = ur.organization_id)))
  WHERE ((ur.user_id = auth.uid()) AND (ur.role = ANY (ARRAY['admin'::public.user_role, 'manager'::public.user_role])) AND (b.id = cameras.branch_id))))));


--
-- Name: aman_instances aman_delete_org; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY aman_delete_org ON public.aman_instances FOR DELETE TO authenticated USING ((organization_id IN ( SELECT user_roles.organization_id
   FROM public.user_roles
  WHERE ((user_roles.user_id = auth.uid()) AND (user_roles.role = ANY (ARRAY['admin'::public.user_role, 'manager'::public.user_role]))))));


--
-- Name: aman_instances aman_delete_super; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY aman_delete_super ON public.aman_instances FOR DELETE TO authenticated USING ((EXISTS ( SELECT 1
   FROM public.user_roles
  WHERE ((user_roles.user_id = auth.uid()) AND (user_roles.role = 'super_admin'::public.user_role)))));


--
-- Name: aman_instances aman_insert_org; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY aman_insert_org ON public.aman_instances FOR INSERT TO authenticated WITH CHECK ((organization_id IN ( SELECT user_roles.organization_id
   FROM public.user_roles
  WHERE ((user_roles.user_id = auth.uid()) AND (user_roles.role = ANY (ARRAY['admin'::public.user_role, 'manager'::public.user_role]))))));


--
-- Name: aman_instances aman_insert_super; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY aman_insert_super ON public.aman_instances FOR INSERT TO authenticated WITH CHECK ((EXISTS ( SELECT 1
   FROM public.user_roles
  WHERE ((user_roles.user_id = auth.uid()) AND (user_roles.role = 'super_admin'::public.user_role)))));


--
-- Name: aman_instances aman_update_org; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY aman_update_org ON public.aman_instances FOR UPDATE TO authenticated USING ((organization_id IN ( SELECT user_roles.organization_id
   FROM public.user_roles
  WHERE ((user_roles.user_id = auth.uid()) AND (user_roles.role = ANY (ARRAY['admin'::public.user_role, 'manager'::public.user_role]))))));


--
-- Name: aman_instances aman_update_super; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY aman_update_super ON public.aman_instances FOR UPDATE TO authenticated USING ((EXISTS ( SELECT 1
   FROM public.user_roles
  WHERE ((user_roles.user_id = auth.uid()) AND (user_roles.role = 'super_admin'::public.user_role)))));


--
-- Name: aman_instances aman_view_org_admin; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY aman_view_org_admin ON public.aman_instances FOR SELECT TO authenticated USING ((organization_id IN ( SELECT user_roles.organization_id
   FROM public.user_roles
  WHERE ((user_roles.user_id = auth.uid()) AND (user_roles.role = ANY (ARRAY['admin'::public.user_role, 'manager'::public.user_role]))))));


--
-- Name: aman_instances aman_view_rep; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY aman_view_rep ON public.aman_instances FOR SELECT TO authenticated USING ((branch_id IN ( SELECT aman_instances.branch_id
   FROM public.user_roles
  WHERE ((user_roles.user_id = auth.uid()) AND (user_roles.role = 'representative'::public.user_role)))));


--
-- Name: aman_instances aman_view_super_admin; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY aman_view_super_admin ON public.aman_instances FOR SELECT TO authenticated USING ((EXISTS ( SELECT 1
   FROM public.user_roles
  WHERE ((user_roles.user_id = auth.uid()) AND (user_roles.role = 'super_admin'::public.user_role)))));


--
-- Name: auto_sync_settings autosync_update; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY autosync_update ON public.auto_sync_settings FOR UPDATE USING (public.is_current_user_super_admin());


--
-- Name: auto_sync_settings autosync_view; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY autosync_view ON public.auto_sync_settings FOR SELECT USING (public.is_current_user_super_admin());


--
-- Name: frigate_deployed_models; Type: ROW SECURITY; Schema: public; Owner: postgres
--

ALTER TABLE public.frigate_deployed_models ENABLE ROW LEVEL SECURITY;

--
-- Name: frigate_deployed_models frigate_deployed_models_all; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY frigate_deployed_models_all ON public.frigate_deployed_models USING (true) WITH CHECK (true);


--
-- Name: frigate_model_deployments; Type: ROW SECURITY; Schema: public; Owner: postgres
--

ALTER TABLE public.frigate_model_deployments ENABLE ROW LEVEL SECURITY;

--
-- Name: frigate_model_deployments frigate_model_deployments_all; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY frigate_model_deployments_all ON public.frigate_model_deployments USING (true) WITH CHECK (true);


--
-- Name: frigate_model_registry; Type: ROW SECURITY; Schema: public; Owner: postgres
--

ALTER TABLE public.frigate_model_registry ENABLE ROW LEVEL SECURITY;

--
-- Name: frigate_model_registry frigate_model_registry_all; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY frigate_model_registry_all ON public.frigate_model_registry USING (true) WITH CHECK (true);


--
-- Name: frigate_model_sync_log; Type: ROW SECURITY; Schema: public; Owner: postgres
--

ALTER TABLE public.frigate_model_sync_log ENABLE ROW LEVEL SECURITY;

--
-- Name: frigate_model_sync_log frigate_model_sync_log_all; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY frigate_model_sync_log_all ON public.frigate_model_sync_log USING (true) WITH CHECK (true);


--
-- Name: frigate_stats_history; Type: ROW SECURITY; Schema: public; Owner: postgres
--

ALTER TABLE public.frigate_stats_history ENABLE ROW LEVEL SECURITY;

--
-- Name: frigate_stats_history frigate_stats_history_all; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY frigate_stats_history_all ON public.frigate_stats_history USING (true) WITH CHECK (true);


--
-- Name: frigate_sync_logs; Type: ROW SECURITY; Schema: public; Owner: postgres
--

ALTER TABLE public.frigate_sync_logs ENABLE ROW LEVEL SECURITY;

--
-- Name: frigate_sync_logs frigate_sync_logs_all; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY frigate_sync_logs_all ON public.frigate_sync_logs USING (true) WITH CHECK (true);


--
-- Name: frigate_triggers; Type: ROW SECURITY; Schema: public; Owner: postgres
--

ALTER TABLE public.frigate_triggers ENABLE ROW LEVEL SECURITY;

--
-- Name: frigate_triggers frigate_triggers_all; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY frigate_triggers_all ON public.frigate_triggers USING (true) WITH CHECK (true);


--
-- Name: organization_settings org_settings_manage; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY org_settings_manage ON public.organization_settings USING ((public.is_current_user_super_admin() OR (organization_id IN ( SELECT user_roles.organization_id
   FROM public.user_roles
  WHERE ((user_roles.user_id = auth.uid()) AND (user_roles.role = ANY (ARRAY['admin'::public.user_role, 'manager'::public.user_role]))))))) WITH CHECK ((public.is_current_user_super_admin() OR (organization_id IN ( SELECT user_roles.organization_id
   FROM public.user_roles
  WHERE ((user_roles.user_id = auth.uid()) AND (user_roles.role = ANY (ARRAY['admin'::public.user_role, 'manager'::public.user_role])))))));


--
-- Name: organization_settings org_settings_view; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY org_settings_view ON public.organization_settings FOR SELECT USING ((public.is_current_user_super_admin() OR (organization_id IN ( SELECT user_roles.organization_id
   FROM public.user_roles
  WHERE (user_roles.user_id = auth.uid())))));


--
-- Name: system_settings super_admin_system_settings_policy; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY super_admin_system_settings_policy ON public.system_settings TO authenticated USING (public.is_current_user_super_admin());


--
-- Name: messages; Type: ROW SECURITY; Schema: realtime; Owner: supabase_realtime_admin
--

ALTER TABLE realtime.messages ENABLE ROW LEVEL SECURITY;

--
-- Name: objects Anyone can view form logos; Type: POLICY; Schema: storage; Owner: supabase_storage_admin
--

CREATE POLICY "Anyone can view form logos" ON storage.objects FOR SELECT USING ((bucket_id = 'form-logos'::text));


--
-- Name: objects Authenticated users can delete model-files; Type: POLICY; Schema: storage; Owner: supabase_storage_admin
--

CREATE POLICY "Authenticated users can delete model-files" ON storage.objects FOR DELETE TO authenticated USING ((bucket_id = 'model-files'::text));


--
-- Name: objects Authenticated users can update model-files; Type: POLICY; Schema: storage; Owner: supabase_storage_admin
--

CREATE POLICY "Authenticated users can update model-files" ON storage.objects FOR UPDATE TO authenticated USING ((bucket_id = 'model-files'::text)) WITH CHECK ((bucket_id = 'model-files'::text));


--
-- Name: objects Authenticated users can upload form logos; Type: POLICY; Schema: storage; Owner: supabase_storage_admin
--

CREATE POLICY "Authenticated users can upload form logos" ON storage.objects FOR INSERT WITH CHECK (((bucket_id = 'form-logos'::text) AND (auth.role() = 'authenticated'::text)));


--
-- Name: objects Authenticated users can upload to model-files; Type: POLICY; Schema: storage; Owner: supabase_storage_admin
--

CREATE POLICY "Authenticated users can upload to model-files" ON storage.objects FOR INSERT TO authenticated WITH CHECK ((bucket_id = 'model-files'::text));


--
-- Name: objects Enable delete for authenticated users on model files; Type: POLICY; Schema: storage; Owner: supabase_storage_admin
--

CREATE POLICY "Enable delete for authenticated users on model files" ON storage.objects FOR DELETE TO authenticated USING ((bucket_id = 'model-files'::text));


--
-- Name: objects Enable delete for authenticated users on test uploads; Type: POLICY; Schema: storage; Owner: supabase_storage_admin
--

CREATE POLICY "Enable delete for authenticated users on test uploads" ON storage.objects FOR DELETE TO authenticated USING ((bucket_id = 'test-uploads'::text));


--
-- Name: objects Enable read for all users on model files; Type: POLICY; Schema: storage; Owner: supabase_storage_admin
--

CREATE POLICY "Enable read for all users on model files" ON storage.objects FOR SELECT USING ((bucket_id = 'model-files'::text));


--
-- Name: objects Enable read for all users on test uploads; Type: POLICY; Schema: storage; Owner: supabase_storage_admin
--

CREATE POLICY "Enable read for all users on test uploads" ON storage.objects FOR SELECT USING ((bucket_id = 'test-uploads'::text));


--
-- Name: objects Enable update for authenticated users on model files; Type: POLICY; Schema: storage; Owner: supabase_storage_admin
--

CREATE POLICY "Enable update for authenticated users on model files" ON storage.objects FOR UPDATE TO authenticated USING ((bucket_id = 'model-files'::text)) WITH CHECK ((bucket_id = 'model-files'::text));


--
-- Name: objects Enable update for authenticated users on test uploads; Type: POLICY; Schema: storage; Owner: supabase_storage_admin
--

CREATE POLICY "Enable update for authenticated users on test uploads" ON storage.objects FOR UPDATE TO authenticated USING ((bucket_id = 'test-uploads'::text)) WITH CHECK ((bucket_id = 'test-uploads'::text));


--
-- Name: objects Enable upload for authenticated users on model files; Type: POLICY; Schema: storage; Owner: supabase_storage_admin
--

CREATE POLICY "Enable upload for authenticated users on model files" ON storage.objects FOR INSERT TO authenticated WITH CHECK ((bucket_id = 'model-files'::text));


--
-- Name: objects Enable upload for authenticated users on test uploads; Type: POLICY; Schema: storage; Owner: supabase_storage_admin
--

CREATE POLICY "Enable upload for authenticated users on test uploads" ON storage.objects FOR INSERT TO authenticated WITH CHECK ((bucket_id = 'test-uploads'::text));


--
-- Name: objects Public can read model-files; Type: POLICY; Schema: storage; Owner: supabase_storage_admin
--

CREATE POLICY "Public can read model-files" ON storage.objects FOR SELECT USING ((bucket_id = 'model-files'::text));


--
-- Name: objects Public can view form attachments; Type: POLICY; Schema: storage; Owner: supabase_storage_admin
--

CREATE POLICY "Public can view form attachments" ON storage.objects FOR SELECT USING ((bucket_id = 'form-attachments'::text));


--
-- Name: objects Super admin can manage model files; Type: POLICY; Schema: storage; Owner: supabase_storage_admin
--

CREATE POLICY "Super admin can manage model files" ON storage.objects TO authenticated USING (((bucket_id = 'model-files'::text) AND public.is_current_user_super_admin()));


--
-- Name: objects Users can delete their form logos; Type: POLICY; Schema: storage; Owner: supabase_storage_admin
--

CREATE POLICY "Users can delete their form logos" ON storage.objects FOR DELETE USING (((bucket_id = 'form-logos'::text) AND (auth.role() = 'authenticated'::text)));


--
-- Name: objects Users can delete their own files (form-attachments); Type: POLICY; Schema: storage; Owner: supabase_storage_admin
--

CREATE POLICY "Users can delete their own files (form-attachments)" ON storage.objects FOR DELETE USING (((bucket_id = 'form-attachments'::text) AND ((auth.uid())::text = (storage.foldername(name))[1])));


--
-- Name: objects Users can update their form logos; Type: POLICY; Schema: storage; Owner: supabase_storage_admin
--

CREATE POLICY "Users can update their form logos" ON storage.objects FOR UPDATE USING (((bucket_id = 'form-logos'::text) AND (auth.role() = 'authenticated'::text)));


--
-- Name: objects Users can update their own files (form-attachments); Type: POLICY; Schema: storage; Owner: supabase_storage_admin
--

CREATE POLICY "Users can update their own files (form-attachments)" ON storage.objects FOR UPDATE USING (((bucket_id = 'form-attachments'::text) AND ((auth.uid())::text = (storage.foldername(name))[1])));


--
-- Name: objects Users can upload to their folder (form-attachments); Type: POLICY; Schema: storage; Owner: supabase_storage_admin
--

CREATE POLICY "Users can upload to their folder (form-attachments)" ON storage.objects FOR INSERT WITH CHECK (((bucket_id = 'form-attachments'::text) AND ((auth.uid())::text = (storage.foldername(name))[1])));


--
-- Name: objects Users can view model files; Type: POLICY; Schema: storage; Owner: supabase_storage_admin
--

CREATE POLICY "Users can view model files" ON storage.objects FOR SELECT TO authenticated USING ((bucket_id = 'model-files'::text));


--
-- Name: buckets; Type: ROW SECURITY; Schema: storage; Owner: supabase_storage_admin
--

ALTER TABLE storage.buckets ENABLE ROW LEVEL SECURITY;

--
-- Name: buckets_analytics; Type: ROW SECURITY; Schema: storage; Owner: supabase_storage_admin
--

ALTER TABLE storage.buckets_analytics ENABLE ROW LEVEL SECURITY;

--
-- Name: buckets_vectors; Type: ROW SECURITY; Schema: storage; Owner: supabase_storage_admin
--

ALTER TABLE storage.buckets_vectors ENABLE ROW LEVEL SECURITY;

--
-- Name: objects frigate_models_delete; Type: POLICY; Schema: storage; Owner: supabase_storage_admin
--

CREATE POLICY frigate_models_delete ON storage.objects FOR DELETE USING ((bucket_id = 'frigate-models'::text));


--
-- Name: objects frigate_models_insert; Type: POLICY; Schema: storage; Owner: supabase_storage_admin
--

CREATE POLICY frigate_models_insert ON storage.objects FOR INSERT WITH CHECK ((bucket_id = 'frigate-models'::text));


--
-- Name: objects frigate_models_select; Type: POLICY; Schema: storage; Owner: supabase_storage_admin
--

CREATE POLICY frigate_models_select ON storage.objects FOR SELECT USING ((bucket_id = 'frigate-models'::text));


--
-- Name: objects frigate_models_update; Type: POLICY; Schema: storage; Owner: supabase_storage_admin
--

CREATE POLICY frigate_models_update ON storage.objects FOR UPDATE USING ((bucket_id = 'frigate-models'::text));


--
-- Name: iceberg_namespaces; Type: ROW SECURITY; Schema: storage; Owner: supabase_storage_admin
--

ALTER TABLE storage.iceberg_namespaces ENABLE ROW LEVEL SECURITY;

--
-- Name: iceberg_tables; Type: ROW SECURITY; Schema: storage; Owner: supabase_storage_admin
--

ALTER TABLE storage.iceberg_tables ENABLE ROW LEVEL SECURITY;

--
-- Name: migrations; Type: ROW SECURITY; Schema: storage; Owner: supabase_storage_admin
--

ALTER TABLE storage.migrations ENABLE ROW LEVEL SECURITY;

--
-- Name: objects; Type: ROW SECURITY; Schema: storage; Owner: supabase_storage_admin
--

ALTER TABLE storage.objects ENABLE ROW LEVEL SECURITY;

--
-- Name: s3_multipart_uploads; Type: ROW SECURITY; Schema: storage; Owner: supabase_storage_admin
--

ALTER TABLE storage.s3_multipart_uploads ENABLE ROW LEVEL SECURITY;

--
-- Name: s3_multipart_uploads_parts; Type: ROW SECURITY; Schema: storage; Owner: supabase_storage_admin
--

ALTER TABLE storage.s3_multipart_uploads_parts ENABLE ROW LEVEL SECURITY;

--
-- Name: vector_indexes; Type: ROW SECURITY; Schema: storage; Owner: supabase_storage_admin
--

ALTER TABLE storage.vector_indexes ENABLE ROW LEVEL SECURITY;

--
-- Name: supabase_realtime; Type: PUBLICATION; Schema: -; Owner: postgres
--

CREATE PUBLICATION supabase_realtime WITH (publish = 'insert, update, delete, truncate');


ALTER PUBLICATION supabase_realtime OWNER TO postgres;

--
-- Name: supabase_realtime_messages_publication; Type: PUBLICATION; Schema: -; Owner: supabase_admin
--

CREATE PUBLICATION supabase_realtime_messages_publication WITH (publish = 'insert, update, delete, truncate');


ALTER PUBLICATION supabase_realtime_messages_publication OWNER TO supabase_admin;

--
-- Name: supabase_realtime aman_instances; Type: PUBLICATION TABLE; Schema: public; Owner: postgres
--

ALTER PUBLICATION supabase_realtime ADD TABLE ONLY public.aman_instances;


--
-- Name: supabase_realtime branches; Type: PUBLICATION TABLE; Schema: public; Owner: postgres
--

ALTER PUBLICATION supabase_realtime ADD TABLE ONLY public.branches;


--
-- Name: supabase_realtime events; Type: PUBLICATION TABLE; Schema: public; Owner: postgres
--

ALTER PUBLICATION supabase_realtime ADD TABLE ONLY public.events;


--
-- Name: supabase_realtime health_alerts; Type: PUBLICATION TABLE; Schema: public; Owner: postgres
--

ALTER PUBLICATION supabase_realtime ADD TABLE ONLY public.health_alerts;


--
-- Name: supabase_realtime_messages_publication messages; Type: PUBLICATION TABLE; Schema: realtime; Owner: supabase_admin
--

ALTER PUBLICATION supabase_realtime_messages_publication ADD TABLE ONLY realtime.messages;


--
-- Name: SCHEMA auth; Type: ACL; Schema: -; Owner: supabase_admin
--

GRANT USAGE ON SCHEMA auth TO anon;
GRANT USAGE ON SCHEMA auth TO authenticated;
GRANT USAGE ON SCHEMA auth TO service_role;
GRANT ALL ON SCHEMA auth TO supabase_auth_admin;
GRANT ALL ON SCHEMA auth TO dashboard_user;
GRANT USAGE ON SCHEMA auth TO postgres;


--
-- Name: SCHEMA extensions; Type: ACL; Schema: -; Owner: postgres
--

GRANT USAGE ON SCHEMA extensions TO anon;
GRANT USAGE ON SCHEMA extensions TO authenticated;
GRANT USAGE ON SCHEMA extensions TO service_role;
GRANT ALL ON SCHEMA extensions TO dashboard_user;


--
-- Name: SCHEMA net; Type: ACL; Schema: -; Owner: supabase_admin
--

GRANT USAGE ON SCHEMA net TO supabase_functions_admin;
GRANT USAGE ON SCHEMA net TO postgres;
GRANT USAGE ON SCHEMA net TO anon;
GRANT USAGE ON SCHEMA net TO authenticated;
GRANT USAGE ON SCHEMA net TO service_role;


--
-- Name: SCHEMA public; Type: ACL; Schema: -; Owner: pg_database_owner
--

GRANT USAGE ON SCHEMA public TO postgres;
GRANT USAGE ON SCHEMA public TO anon;
GRANT USAGE ON SCHEMA public TO authenticated;
GRANT USAGE ON SCHEMA public TO service_role;


--
-- Name: SCHEMA realtime; Type: ACL; Schema: -; Owner: supabase_admin
--

GRANT USAGE ON SCHEMA realtime TO postgres;
GRANT USAGE ON SCHEMA realtime TO anon;
GRANT USAGE ON SCHEMA realtime TO authenticated;
GRANT USAGE ON SCHEMA realtime TO service_role;
GRANT ALL ON SCHEMA realtime TO supabase_realtime_admin;


--
-- Name: SCHEMA storage; Type: ACL; Schema: -; Owner: supabase_admin
--

GRANT USAGE ON SCHEMA storage TO postgres WITH GRANT OPTION;
GRANT USAGE ON SCHEMA storage TO anon;
GRANT USAGE ON SCHEMA storage TO authenticated;
GRANT USAGE ON SCHEMA storage TO service_role;
GRANT ALL ON SCHEMA storage TO supabase_storage_admin WITH GRANT OPTION;
GRANT ALL ON SCHEMA storage TO dashboard_user;


--
-- Name: SCHEMA supabase_functions; Type: ACL; Schema: -; Owner: supabase_admin
--

GRANT USAGE ON SCHEMA supabase_functions TO postgres;
GRANT USAGE ON SCHEMA supabase_functions TO anon;
GRANT USAGE ON SCHEMA supabase_functions TO authenticated;
GRANT USAGE ON SCHEMA supabase_functions TO service_role;
GRANT ALL ON SCHEMA supabase_functions TO supabase_functions_admin;


--
-- Name: SCHEMA vault; Type: ACL; Schema: -; Owner: supabase_admin
--

GRANT USAGE ON SCHEMA vault TO postgres WITH GRANT OPTION;
GRANT USAGE ON SCHEMA vault TO service_role;


--
-- Name: FUNCTION email(); Type: ACL; Schema: auth; Owner: supabase_auth_admin
--

GRANT ALL ON FUNCTION auth.email() TO dashboard_user;


--
-- Name: FUNCTION jwt(); Type: ACL; Schema: auth; Owner: supabase_auth_admin
--

GRANT ALL ON FUNCTION auth.jwt() TO postgres;
GRANT ALL ON FUNCTION auth.jwt() TO dashboard_user;


--
-- Name: FUNCTION role(); Type: ACL; Schema: auth; Owner: supabase_auth_admin
--

GRANT ALL ON FUNCTION auth.role() TO dashboard_user;


--
-- Name: FUNCTION uid(); Type: ACL; Schema: auth; Owner: supabase_auth_admin
--

GRANT ALL ON FUNCTION auth.uid() TO dashboard_user;


--
-- Name: FUNCTION armor(bytea); Type: ACL; Schema: extensions; Owner: supabase_admin
--

GRANT ALL ON FUNCTION extensions.armor(bytea) TO dashboard_user;
GRANT ALL ON FUNCTION extensions.armor(bytea) TO postgres WITH GRANT OPTION;


--
-- Name: FUNCTION armor(bytea, text[], text[]); Type: ACL; Schema: extensions; Owner: supabase_admin
--

GRANT ALL ON FUNCTION extensions.armor(bytea, text[], text[]) TO dashboard_user;
GRANT ALL ON FUNCTION extensions.armor(bytea, text[], text[]) TO postgres WITH GRANT OPTION;


--
-- Name: FUNCTION crypt(text, text); Type: ACL; Schema: extensions; Owner: supabase_admin
--

GRANT ALL ON FUNCTION extensions.crypt(text, text) TO dashboard_user;
GRANT ALL ON FUNCTION extensions.crypt(text, text) TO postgres WITH GRANT OPTION;


--
-- Name: FUNCTION dearmor(text); Type: ACL; Schema: extensions; Owner: supabase_admin
--

GRANT ALL ON FUNCTION extensions.dearmor(text) TO dashboard_user;
GRANT ALL ON FUNCTION extensions.dearmor(text) TO postgres WITH GRANT OPTION;


--
-- Name: FUNCTION decrypt(bytea, bytea, text); Type: ACL; Schema: extensions; Owner: supabase_admin
--

GRANT ALL ON FUNCTION extensions.decrypt(bytea, bytea, text) TO dashboard_user;
GRANT ALL ON FUNCTION extensions.decrypt(bytea, bytea, text) TO postgres WITH GRANT OPTION;


--
-- Name: FUNCTION decrypt_iv(bytea, bytea, bytea, text); Type: ACL; Schema: extensions; Owner: supabase_admin
--

GRANT ALL ON FUNCTION extensions.decrypt_iv(bytea, bytea, bytea, text) TO dashboard_user;
GRANT ALL ON FUNCTION extensions.decrypt_iv(bytea, bytea, bytea, text) TO postgres WITH GRANT OPTION;


--
-- Name: FUNCTION digest(bytea, text); Type: ACL; Schema: extensions; Owner: supabase_admin
--

GRANT ALL ON FUNCTION extensions.digest(bytea, text) TO dashboard_user;
GRANT ALL ON FUNCTION extensions.digest(bytea, text) TO postgres WITH GRANT OPTION;


--
-- Name: FUNCTION digest(text, text); Type: ACL; Schema: extensions; Owner: supabase_admin
--

GRANT ALL ON FUNCTION extensions.digest(text, text) TO dashboard_user;
GRANT ALL ON FUNCTION extensions.digest(text, text) TO postgres WITH GRANT OPTION;


--
-- Name: FUNCTION encrypt(bytea, bytea, text); Type: ACL; Schema: extensions; Owner: supabase_admin
--

GRANT ALL ON FUNCTION extensions.encrypt(bytea, bytea, text) TO dashboard_user;
GRANT ALL ON FUNCTION extensions.encrypt(bytea, bytea, text) TO postgres WITH GRANT OPTION;


--
-- Name: FUNCTION encrypt_iv(bytea, bytea, bytea, text); Type: ACL; Schema: extensions; Owner: supabase_admin
--

GRANT ALL ON FUNCTION extensions.encrypt_iv(bytea, bytea, bytea, text) TO dashboard_user;
GRANT ALL ON FUNCTION extensions.encrypt_iv(bytea, bytea, bytea, text) TO postgres WITH GRANT OPTION;


--
-- Name: FUNCTION gen_random_bytes(integer); Type: ACL; Schema: extensions; Owner: supabase_admin
--

GRANT ALL ON FUNCTION extensions.gen_random_bytes(integer) TO dashboard_user;
GRANT ALL ON FUNCTION extensions.gen_random_bytes(integer) TO postgres WITH GRANT OPTION;


--
-- Name: FUNCTION gen_random_uuid(); Type: ACL; Schema: extensions; Owner: supabase_admin
--

GRANT ALL ON FUNCTION extensions.gen_random_uuid() TO dashboard_user;
GRANT ALL ON FUNCTION extensions.gen_random_uuid() TO postgres WITH GRANT OPTION;


--
-- Name: FUNCTION gen_salt(text); Type: ACL; Schema: extensions; Owner: supabase_admin
--

GRANT ALL ON FUNCTION extensions.gen_salt(text) TO dashboard_user;
GRANT ALL ON FUNCTION extensions.gen_salt(text) TO postgres WITH GRANT OPTION;


--
-- Name: FUNCTION gen_salt(text, integer); Type: ACL; Schema: extensions; Owner: supabase_admin
--

GRANT ALL ON FUNCTION extensions.gen_salt(text, integer) TO dashboard_user;
GRANT ALL ON FUNCTION extensions.gen_salt(text, integer) TO postgres WITH GRANT OPTION;


--
-- Name: FUNCTION grant_pg_cron_access(); Type: ACL; Schema: extensions; Owner: supabase_admin
--

REVOKE ALL ON FUNCTION extensions.grant_pg_cron_access() FROM supabase_admin;
GRANT ALL ON FUNCTION extensions.grant_pg_cron_access() TO supabase_admin WITH GRANT OPTION;
GRANT ALL ON FUNCTION extensions.grant_pg_cron_access() TO dashboard_user;


--
-- Name: FUNCTION grant_pg_graphql_access(); Type: ACL; Schema: extensions; Owner: supabase_admin
--

GRANT ALL ON FUNCTION extensions.grant_pg_graphql_access() TO postgres WITH GRANT OPTION;


--
-- Name: FUNCTION grant_pg_net_access(); Type: ACL; Schema: extensions; Owner: supabase_admin
--

REVOKE ALL ON FUNCTION extensions.grant_pg_net_access() FROM supabase_admin;
GRANT ALL ON FUNCTION extensions.grant_pg_net_access() TO supabase_admin WITH GRANT OPTION;
GRANT ALL ON FUNCTION extensions.grant_pg_net_access() TO dashboard_user;


--
-- Name: FUNCTION hmac(bytea, bytea, text); Type: ACL; Schema: extensions; Owner: supabase_admin
--

GRANT ALL ON FUNCTION extensions.hmac(bytea, bytea, text) TO dashboard_user;
GRANT ALL ON FUNCTION extensions.hmac(bytea, bytea, text) TO postgres WITH GRANT OPTION;


--
-- Name: FUNCTION hmac(text, text, text); Type: ACL; Schema: extensions; Owner: supabase_admin
--

GRANT ALL ON FUNCTION extensions.hmac(text, text, text) TO dashboard_user;
GRANT ALL ON FUNCTION extensions.hmac(text, text, text) TO postgres WITH GRANT OPTION;


--
-- Name: FUNCTION pg_stat_statements(showtext boolean, OUT userid oid, OUT dbid oid, OUT toplevel boolean, OUT queryid bigint, OUT query text, OUT plans bigint, OUT total_plan_time double precision, OUT min_plan_time double precision, OUT max_plan_time double precision, OUT mean_plan_time double precision, OUT stddev_plan_time double precision, OUT calls bigint, OUT total_exec_time double precision, OUT min_exec_time double precision, OUT max_exec_time double precision, OUT mean_exec_time double precision, OUT stddev_exec_time double precision, OUT rows bigint, OUT shared_blks_hit bigint, OUT shared_blks_read bigint, OUT shared_blks_dirtied bigint, OUT shared_blks_written bigint, OUT local_blks_hit bigint, OUT local_blks_read bigint, OUT local_blks_dirtied bigint, OUT local_blks_written bigint, OUT temp_blks_read bigint, OUT temp_blks_written bigint, OUT shared_blk_read_time double precision, OUT shared_blk_write_time double precision, OUT local_blk_read_time double precision, OUT local_blk_write_time double precision, OUT temp_blk_read_time double precision, OUT temp_blk_write_time double precision, OUT wal_records bigint, OUT wal_fpi bigint, OUT wal_bytes numeric, OUT jit_functions bigint, OUT jit_generation_time double precision, OUT jit_inlining_count bigint, OUT jit_inlining_time double precision, OUT jit_optimization_count bigint, OUT jit_optimization_time double precision, OUT jit_emission_count bigint, OUT jit_emission_time double precision, OUT jit_deform_count bigint, OUT jit_deform_time double precision, OUT stats_since timestamp with time zone, OUT minmax_stats_since timestamp with time zone); Type: ACL; Schema: extensions; Owner: supabase_admin
--

GRANT ALL ON FUNCTION extensions.pg_stat_statements(showtext boolean, OUT userid oid, OUT dbid oid, OUT toplevel boolean, OUT queryid bigint, OUT query text, OUT plans bigint, OUT total_plan_time double precision, OUT min_plan_time double precision, OUT max_plan_time double precision, OUT mean_plan_time double precision, OUT stddev_plan_time double precision, OUT calls bigint, OUT total_exec_time double precision, OUT min_exec_time double precision, OUT max_exec_time double precision, OUT mean_exec_time double precision, OUT stddev_exec_time double precision, OUT rows bigint, OUT shared_blks_hit bigint, OUT shared_blks_read bigint, OUT shared_blks_dirtied bigint, OUT shared_blks_written bigint, OUT local_blks_hit bigint, OUT local_blks_read bigint, OUT local_blks_dirtied bigint, OUT local_blks_written bigint, OUT temp_blks_read bigint, OUT temp_blks_written bigint, OUT shared_blk_read_time double precision, OUT shared_blk_write_time double precision, OUT local_blk_read_time double precision, OUT local_blk_write_time double precision, OUT temp_blk_read_time double precision, OUT temp_blk_write_time double precision, OUT wal_records bigint, OUT wal_fpi bigint, OUT wal_bytes numeric, OUT jit_functions bigint, OUT jit_generation_time double precision, OUT jit_inlining_count bigint, OUT jit_inlining_time double precision, OUT jit_optimization_count bigint, OUT jit_optimization_time double precision, OUT jit_emission_count bigint, OUT jit_emission_time double precision, OUT jit_deform_count bigint, OUT jit_deform_time double precision, OUT stats_since timestamp with time zone, OUT minmax_stats_since timestamp with time zone) TO postgres WITH GRANT OPTION;


--
-- Name: FUNCTION pg_stat_statements_info(OUT dealloc bigint, OUT stats_reset timestamp with time zone); Type: ACL; Schema: extensions; Owner: supabase_admin
--

GRANT ALL ON FUNCTION extensions.pg_stat_statements_info(OUT dealloc bigint, OUT stats_reset timestamp with time zone) TO postgres WITH GRANT OPTION;


--
-- Name: FUNCTION pg_stat_statements_reset(userid oid, dbid oid, queryid bigint, minmax_only boolean); Type: ACL; Schema: extensions; Owner: supabase_admin
--

GRANT ALL ON FUNCTION extensions.pg_stat_statements_reset(userid oid, dbid oid, queryid bigint, minmax_only boolean) TO postgres WITH GRANT OPTION;


--
-- Name: FUNCTION pgp_armor_headers(text, OUT key text, OUT value text); Type: ACL; Schema: extensions; Owner: supabase_admin
--

GRANT ALL ON FUNCTION extensions.pgp_armor_headers(text, OUT key text, OUT value text) TO dashboard_user;
GRANT ALL ON FUNCTION extensions.pgp_armor_headers(text, OUT key text, OUT value text) TO postgres WITH GRANT OPTION;


--
-- Name: FUNCTION pgp_key_id(bytea); Type: ACL; Schema: extensions; Owner: supabase_admin
--

GRANT ALL ON FUNCTION extensions.pgp_key_id(bytea) TO dashboard_user;
GRANT ALL ON FUNCTION extensions.pgp_key_id(bytea) TO postgres WITH GRANT OPTION;


--
-- Name: FUNCTION pgp_pub_decrypt(bytea, bytea); Type: ACL; Schema: extensions; Owner: supabase_admin
--

GRANT ALL ON FUNCTION extensions.pgp_pub_decrypt(bytea, bytea) TO dashboard_user;
GRANT ALL ON FUNCTION extensions.pgp_pub_decrypt(bytea, bytea) TO postgres WITH GRANT OPTION;


--
-- Name: FUNCTION pgp_pub_decrypt(bytea, bytea, text); Type: ACL; Schema: extensions; Owner: supabase_admin
--

GRANT ALL ON FUNCTION extensions.pgp_pub_decrypt(bytea, bytea, text) TO dashboard_user;
GRANT ALL ON FUNCTION extensions.pgp_pub_decrypt(bytea, bytea, text) TO postgres WITH GRANT OPTION;


--
-- Name: FUNCTION pgp_pub_decrypt(bytea, bytea, text, text); Type: ACL; Schema: extensions; Owner: supabase_admin
--

GRANT ALL ON FUNCTION extensions.pgp_pub_decrypt(bytea, bytea, text, text) TO dashboard_user;
GRANT ALL ON FUNCTION extensions.pgp_pub_decrypt(bytea, bytea, text, text) TO postgres WITH GRANT OPTION;


--
-- Name: FUNCTION pgp_pub_decrypt_bytea(bytea, bytea); Type: ACL; Schema: extensions; Owner: supabase_admin
--

GRANT ALL ON FUNCTION extensions.pgp_pub_decrypt_bytea(bytea, bytea) TO dashboard_user;
GRANT ALL ON FUNCTION extensions.pgp_pub_decrypt_bytea(bytea, bytea) TO postgres WITH GRANT OPTION;


--
-- Name: FUNCTION pgp_pub_decrypt_bytea(bytea, bytea, text); Type: ACL; Schema: extensions; Owner: supabase_admin
--

GRANT ALL ON FUNCTION extensions.pgp_pub_decrypt_bytea(bytea, bytea, text) TO dashboard_user;
GRANT ALL ON FUNCTION extensions.pgp_pub_decrypt_bytea(bytea, bytea, text) TO postgres WITH GRANT OPTION;


--
-- Name: FUNCTION pgp_pub_decrypt_bytea(bytea, bytea, text, text); Type: ACL; Schema: extensions; Owner: supabase_admin
--

GRANT ALL ON FUNCTION extensions.pgp_pub_decrypt_bytea(bytea, bytea, text, text) TO dashboard_user;
GRANT ALL ON FUNCTION extensions.pgp_pub_decrypt_bytea(bytea, bytea, text, text) TO postgres WITH GRANT OPTION;


--
-- Name: FUNCTION pgp_pub_encrypt(text, bytea); Type: ACL; Schema: extensions; Owner: supabase_admin
--

GRANT ALL ON FUNCTION extensions.pgp_pub_encrypt(text, bytea) TO dashboard_user;
GRANT ALL ON FUNCTION extensions.pgp_pub_encrypt(text, bytea) TO postgres WITH GRANT OPTION;


--
-- Name: FUNCTION pgp_pub_encrypt(text, bytea, text); Type: ACL; Schema: extensions; Owner: supabase_admin
--

GRANT ALL ON FUNCTION extensions.pgp_pub_encrypt(text, bytea, text) TO dashboard_user;
GRANT ALL ON FUNCTION extensions.pgp_pub_encrypt(text, bytea, text) TO postgres WITH GRANT OPTION;


--
-- Name: FUNCTION pgp_pub_encrypt_bytea(bytea, bytea); Type: ACL; Schema: extensions; Owner: supabase_admin
--

GRANT ALL ON FUNCTION extensions.pgp_pub_encrypt_bytea(bytea, bytea) TO dashboard_user;
GRANT ALL ON FUNCTION extensions.pgp_pub_encrypt_bytea(bytea, bytea) TO postgres WITH GRANT OPTION;


--
-- Name: FUNCTION pgp_pub_encrypt_bytea(bytea, bytea, text); Type: ACL; Schema: extensions; Owner: supabase_admin
--

GRANT ALL ON FUNCTION extensions.pgp_pub_encrypt_bytea(bytea, bytea, text) TO dashboard_user;
GRANT ALL ON FUNCTION extensions.pgp_pub_encrypt_bytea(bytea, bytea, text) TO postgres WITH GRANT OPTION;


--
-- Name: FUNCTION pgp_sym_decrypt(bytea, text); Type: ACL; Schema: extensions; Owner: supabase_admin
--

GRANT ALL ON FUNCTION extensions.pgp_sym_decrypt(bytea, text) TO dashboard_user;
GRANT ALL ON FUNCTION extensions.pgp_sym_decrypt(bytea, text) TO postgres WITH GRANT OPTION;


--
-- Name: FUNCTION pgp_sym_decrypt(bytea, text, text); Type: ACL; Schema: extensions; Owner: supabase_admin
--

GRANT ALL ON FUNCTION extensions.pgp_sym_decrypt(bytea, text, text) TO dashboard_user;
GRANT ALL ON FUNCTION extensions.pgp_sym_decrypt(bytea, text, text) TO postgres WITH GRANT OPTION;


--
-- Name: FUNCTION pgp_sym_decrypt_bytea(bytea, text); Type: ACL; Schema: extensions; Owner: supabase_admin
--

GRANT ALL ON FUNCTION extensions.pgp_sym_decrypt_bytea(bytea, text) TO dashboard_user;
GRANT ALL ON FUNCTION extensions.pgp_sym_decrypt_bytea(bytea, text) TO postgres WITH GRANT OPTION;


--
-- Name: FUNCTION pgp_sym_decrypt_bytea(bytea, text, text); Type: ACL; Schema: extensions; Owner: supabase_admin
--

GRANT ALL ON FUNCTION extensions.pgp_sym_decrypt_bytea(bytea, text, text) TO dashboard_user;
GRANT ALL ON FUNCTION extensions.pgp_sym_decrypt_bytea(bytea, text, text) TO postgres WITH GRANT OPTION;


--
-- Name: FUNCTION pgp_sym_encrypt(text, text); Type: ACL; Schema: extensions; Owner: supabase_admin
--

GRANT ALL ON FUNCTION extensions.pgp_sym_encrypt(text, text) TO dashboard_user;
GRANT ALL ON FUNCTION extensions.pgp_sym_encrypt(text, text) TO postgres WITH GRANT OPTION;


--
-- Name: FUNCTION pgp_sym_encrypt(text, text, text); Type: ACL; Schema: extensions; Owner: supabase_admin
--

GRANT ALL ON FUNCTION extensions.pgp_sym_encrypt(text, text, text) TO dashboard_user;
GRANT ALL ON FUNCTION extensions.pgp_sym_encrypt(text, text, text) TO postgres WITH GRANT OPTION;


--
-- Name: FUNCTION pgp_sym_encrypt_bytea(bytea, text); Type: ACL; Schema: extensions; Owner: supabase_admin
--

GRANT ALL ON FUNCTION extensions.pgp_sym_encrypt_bytea(bytea, text) TO dashboard_user;
GRANT ALL ON FUNCTION extensions.pgp_sym_encrypt_bytea(bytea, text) TO postgres WITH GRANT OPTION;


--
-- Name: FUNCTION pgp_sym_encrypt_bytea(bytea, text, text); Type: ACL; Schema: extensions; Owner: supabase_admin
--

GRANT ALL ON FUNCTION extensions.pgp_sym_encrypt_bytea(bytea, text, text) TO dashboard_user;
GRANT ALL ON FUNCTION extensions.pgp_sym_encrypt_bytea(bytea, text, text) TO postgres WITH GRANT OPTION;


--
-- Name: FUNCTION pgrst_ddl_watch(); Type: ACL; Schema: extensions; Owner: supabase_admin
--

GRANT ALL ON FUNCTION extensions.pgrst_ddl_watch() TO postgres WITH GRANT OPTION;


--
-- Name: FUNCTION pgrst_drop_watch(); Type: ACL; Schema: extensions; Owner: supabase_admin
--

GRANT ALL ON FUNCTION extensions.pgrst_drop_watch() TO postgres WITH GRANT OPTION;


--
-- Name: FUNCTION set_graphql_placeholder(); Type: ACL; Schema: extensions; Owner: supabase_admin
--

GRANT ALL ON FUNCTION extensions.set_graphql_placeholder() TO postgres WITH GRANT OPTION;


--
-- Name: FUNCTION uuid_generate_v1(); Type: ACL; Schema: extensions; Owner: supabase_admin
--

GRANT ALL ON FUNCTION extensions.uuid_generate_v1() TO dashboard_user;
GRANT ALL ON FUNCTION extensions.uuid_generate_v1() TO postgres WITH GRANT OPTION;


--
-- Name: FUNCTION uuid_generate_v1mc(); Type: ACL; Schema: extensions; Owner: supabase_admin
--

GRANT ALL ON FUNCTION extensions.uuid_generate_v1mc() TO dashboard_user;
GRANT ALL ON FUNCTION extensions.uuid_generate_v1mc() TO postgres WITH GRANT OPTION;


--
-- Name: FUNCTION uuid_generate_v3(namespace uuid, name text); Type: ACL; Schema: extensions; Owner: supabase_admin
--

GRANT ALL ON FUNCTION extensions.uuid_generate_v3(namespace uuid, name text) TO dashboard_user;
GRANT ALL ON FUNCTION extensions.uuid_generate_v3(namespace uuid, name text) TO postgres WITH GRANT OPTION;


--
-- Name: FUNCTION uuid_generate_v4(); Type: ACL; Schema: extensions; Owner: supabase_admin
--

GRANT ALL ON FUNCTION extensions.uuid_generate_v4() TO dashboard_user;
GRANT ALL ON FUNCTION extensions.uuid_generate_v4() TO postgres WITH GRANT OPTION;


--
-- Name: FUNCTION uuid_generate_v5(namespace uuid, name text); Type: ACL; Schema: extensions; Owner: supabase_admin
--

GRANT ALL ON FUNCTION extensions.uuid_generate_v5(namespace uuid, name text) TO dashboard_user;
GRANT ALL ON FUNCTION extensions.uuid_generate_v5(namespace uuid, name text) TO postgres WITH GRANT OPTION;


--
-- Name: FUNCTION uuid_nil(); Type: ACL; Schema: extensions; Owner: supabase_admin
--

GRANT ALL ON FUNCTION extensions.uuid_nil() TO dashboard_user;
GRANT ALL ON FUNCTION extensions.uuid_nil() TO postgres WITH GRANT OPTION;


--
-- Name: FUNCTION uuid_ns_dns(); Type: ACL; Schema: extensions; Owner: supabase_admin
--

GRANT ALL ON FUNCTION extensions.uuid_ns_dns() TO dashboard_user;
GRANT ALL ON FUNCTION extensions.uuid_ns_dns() TO postgres WITH GRANT OPTION;


--
-- Name: FUNCTION uuid_ns_oid(); Type: ACL; Schema: extensions; Owner: supabase_admin
--

GRANT ALL ON FUNCTION extensions.uuid_ns_oid() TO dashboard_user;
GRANT ALL ON FUNCTION extensions.uuid_ns_oid() TO postgres WITH GRANT OPTION;


--
-- Name: FUNCTION uuid_ns_url(); Type: ACL; Schema: extensions; Owner: supabase_admin
--

GRANT ALL ON FUNCTION extensions.uuid_ns_url() TO dashboard_user;
GRANT ALL ON FUNCTION extensions.uuid_ns_url() TO postgres WITH GRANT OPTION;


--
-- Name: FUNCTION uuid_ns_x500(); Type: ACL; Schema: extensions; Owner: supabase_admin
--

GRANT ALL ON FUNCTION extensions.uuid_ns_x500() TO dashboard_user;
GRANT ALL ON FUNCTION extensions.uuid_ns_x500() TO postgres WITH GRANT OPTION;


--
-- Name: FUNCTION graphql("operationName" text, query text, variables jsonb, extensions jsonb); Type: ACL; Schema: graphql_public; Owner: supabase_admin
--

GRANT ALL ON FUNCTION graphql_public.graphql("operationName" text, query text, variables jsonb, extensions jsonb) TO postgres;
GRANT ALL ON FUNCTION graphql_public.graphql("operationName" text, query text, variables jsonb, extensions jsonb) TO anon;
GRANT ALL ON FUNCTION graphql_public.graphql("operationName" text, query text, variables jsonb, extensions jsonb) TO authenticated;
GRANT ALL ON FUNCTION graphql_public.graphql("operationName" text, query text, variables jsonb, extensions jsonb) TO service_role;


--
-- Name: FUNCTION http_get(url text, params jsonb, headers jsonb, timeout_milliseconds integer); Type: ACL; Schema: net; Owner: supabase_admin
--

REVOKE ALL ON FUNCTION net.http_get(url text, params jsonb, headers jsonb, timeout_milliseconds integer) FROM PUBLIC;
GRANT ALL ON FUNCTION net.http_get(url text, params jsonb, headers jsonb, timeout_milliseconds integer) TO supabase_functions_admin;
GRANT ALL ON FUNCTION net.http_get(url text, params jsonb, headers jsonb, timeout_milliseconds integer) TO postgres;
GRANT ALL ON FUNCTION net.http_get(url text, params jsonb, headers jsonb, timeout_milliseconds integer) TO anon;
GRANT ALL ON FUNCTION net.http_get(url text, params jsonb, headers jsonb, timeout_milliseconds integer) TO authenticated;
GRANT ALL ON FUNCTION net.http_get(url text, params jsonb, headers jsonb, timeout_milliseconds integer) TO service_role;


--
-- Name: FUNCTION http_post(url text, body jsonb, params jsonb, headers jsonb, timeout_milliseconds integer); Type: ACL; Schema: net; Owner: supabase_admin
--

REVOKE ALL ON FUNCTION net.http_post(url text, body jsonb, params jsonb, headers jsonb, timeout_milliseconds integer) FROM PUBLIC;
GRANT ALL ON FUNCTION net.http_post(url text, body jsonb, params jsonb, headers jsonb, timeout_milliseconds integer) TO supabase_functions_admin;
GRANT ALL ON FUNCTION net.http_post(url text, body jsonb, params jsonb, headers jsonb, timeout_milliseconds integer) TO postgres;
GRANT ALL ON FUNCTION net.http_post(url text, body jsonb, params jsonb, headers jsonb, timeout_milliseconds integer) TO anon;
GRANT ALL ON FUNCTION net.http_post(url text, body jsonb, params jsonb, headers jsonb, timeout_milliseconds integer) TO authenticated;
GRANT ALL ON FUNCTION net.http_post(url text, body jsonb, params jsonb, headers jsonb, timeout_milliseconds integer) TO service_role;


--
-- Name: FUNCTION pg_reload_conf(); Type: ACL; Schema: pg_catalog; Owner: supabase_admin
--

GRANT ALL ON FUNCTION pg_catalog.pg_reload_conf() TO postgres WITH GRANT OPTION;


--
-- Name: FUNCTION get_auth(p_usename text); Type: ACL; Schema: pgbouncer; Owner: supabase_admin
--

REVOKE ALL ON FUNCTION pgbouncer.get_auth(p_usename text) FROM PUBLIC;
GRANT ALL ON FUNCTION pgbouncer.get_auth(p_usename text) TO pgbouncer;


--
-- Name: FUNCTION branch_manager_can_view_submission(_submission_id uuid); Type: ACL; Schema: public; Owner: postgres
--

GRANT ALL ON FUNCTION public.branch_manager_can_view_submission(_submission_id uuid) TO anon;
GRANT ALL ON FUNCTION public.branch_manager_can_view_submission(_submission_id uuid) TO authenticated;
GRANT ALL ON FUNCTION public.branch_manager_can_view_submission(_submission_id uuid) TO service_role;


--
-- Name: FUNCTION current_user_is_branch_manager_for_user(target_user_id uuid); Type: ACL; Schema: public; Owner: postgres
--

GRANT ALL ON FUNCTION public.current_user_is_branch_manager_for_user(target_user_id uuid) TO anon;
GRANT ALL ON FUNCTION public.current_user_is_branch_manager_for_user(target_user_id uuid) TO authenticated;
GRANT ALL ON FUNCTION public.current_user_is_branch_manager_for_user(target_user_id uuid) TO service_role;


--
-- Name: FUNCTION current_user_is_org_admin_or_manager(org_id uuid); Type: ACL; Schema: public; Owner: postgres
--

GRANT ALL ON FUNCTION public.current_user_is_org_admin_or_manager(org_id uuid) TO anon;
GRANT ALL ON FUNCTION public.current_user_is_org_admin_or_manager(org_id uuid) TO authenticated;
GRANT ALL ON FUNCTION public.current_user_is_org_admin_or_manager(org_id uuid) TO service_role;


--
-- Name: FUNCTION get_user_role(user_id uuid); Type: ACL; Schema: public; Owner: postgres
--

GRANT ALL ON FUNCTION public.get_user_role(user_id uuid) TO anon;
GRANT ALL ON FUNCTION public.get_user_role(user_id uuid) TO authenticated;
GRANT ALL ON FUNCTION public.get_user_role(user_id uuid) TO service_role;


--
-- Name: FUNCTION handle_new_user(); Type: ACL; Schema: public; Owner: postgres
--

GRANT ALL ON FUNCTION public.handle_new_user() TO anon;
GRANT ALL ON FUNCTION public.handle_new_user() TO authenticated;
GRANT ALL ON FUNCTION public.handle_new_user() TO service_role;


--
-- Name: FUNCTION inc_download_count(mid text); Type: ACL; Schema: public; Owner: postgres
--

GRANT ALL ON FUNCTION public.inc_download_count(mid text) TO anon;
GRANT ALL ON FUNCTION public.inc_download_count(mid text) TO authenticated;
GRANT ALL ON FUNCTION public.inc_download_count(mid text) TO service_role;


--
-- Name: FUNCTION is_current_user_super_admin(); Type: ACL; Schema: public; Owner: postgres
--

GRANT ALL ON FUNCTION public.is_current_user_super_admin() TO anon;
GRANT ALL ON FUNCTION public.is_current_user_super_admin() TO authenticated;
GRANT ALL ON FUNCTION public.is_current_user_super_admin() TO service_role;


--
-- Name: FUNCTION is_super_admin(user_email text); Type: ACL; Schema: public; Owner: postgres
--

GRANT ALL ON FUNCTION public.is_super_admin(user_email text) TO anon;
GRANT ALL ON FUNCTION public.is_super_admin(user_email text) TO authenticated;
GRANT ALL ON FUNCTION public.is_super_admin(user_email text) TO service_role;


--
-- Name: FUNCTION manage_auto_sync_schedule(enabled boolean, interval_minutes integer); Type: ACL; Schema: public; Owner: postgres
--

GRANT ALL ON FUNCTION public.manage_auto_sync_schedule(enabled boolean, interval_minutes integer) TO anon;
GRANT ALL ON FUNCTION public.manage_auto_sync_schedule(enabled boolean, interval_minutes integer) TO authenticated;
GRANT ALL ON FUNCTION public.manage_auto_sync_schedule(enabled boolean, interval_minutes integer) TO service_role;


--
-- Name: FUNCTION restrict_events_update(); Type: ACL; Schema: public; Owner: postgres
--

GRANT ALL ON FUNCTION public.restrict_events_update() TO anon;
GRANT ALL ON FUNCTION public.restrict_events_update() TO authenticated;
GRANT ALL ON FUNCTION public.restrict_events_update() TO service_role;


--
-- Name: FUNCTION touch_chat_thread(); Type: ACL; Schema: public; Owner: postgres
--

GRANT ALL ON FUNCTION public.touch_chat_thread() TO anon;
GRANT ALL ON FUNCTION public.touch_chat_thread() TO authenticated;
GRANT ALL ON FUNCTION public.touch_chat_thread() TO service_role;


--
-- Name: FUNCTION trg_touch_updated_at(); Type: ACL; Schema: public; Owner: postgres
--

GRANT ALL ON FUNCTION public.trg_touch_updated_at() TO anon;
GRANT ALL ON FUNCTION public.trg_touch_updated_at() TO authenticated;
GRANT ALL ON FUNCTION public.trg_touch_updated_at() TO service_role;


--
-- Name: FUNCTION trigger_auto_sync(); Type: ACL; Schema: public; Owner: postgres
--

GRANT ALL ON FUNCTION public.trigger_auto_sync() TO anon;
GRANT ALL ON FUNCTION public.trigger_auto_sync() TO authenticated;
GRANT ALL ON FUNCTION public.trigger_auto_sync() TO service_role;


--
-- Name: FUNCTION update_modified_column(); Type: ACL; Schema: public; Owner: postgres
--

GRANT ALL ON FUNCTION public.update_modified_column() TO anon;
GRANT ALL ON FUNCTION public.update_modified_column() TO authenticated;
GRANT ALL ON FUNCTION public.update_modified_column() TO service_role;


--
-- Name: FUNCTION update_subscriber_activity(); Type: ACL; Schema: public; Owner: postgres
--

GRANT ALL ON FUNCTION public.update_subscriber_activity() TO anon;
GRANT ALL ON FUNCTION public.update_subscriber_activity() TO authenticated;
GRANT ALL ON FUNCTION public.update_subscriber_activity() TO service_role;


--
-- Name: FUNCTION user_is_org_member_for_thread(thread_id uuid); Type: ACL; Schema: public; Owner: postgres
--

GRANT ALL ON FUNCTION public.user_is_org_member_for_thread(thread_id uuid) TO anon;
GRANT ALL ON FUNCTION public.user_is_org_member_for_thread(thread_id uuid) TO authenticated;
GRANT ALL ON FUNCTION public.user_is_org_member_for_thread(thread_id uuid) TO service_role;


--
-- Name: FUNCTION user_is_thread_participant(thread_id uuid); Type: ACL; Schema: public; Owner: postgres
--

GRANT ALL ON FUNCTION public.user_is_thread_participant(thread_id uuid) TO anon;
GRANT ALL ON FUNCTION public.user_is_thread_participant(thread_id uuid) TO authenticated;
GRANT ALL ON FUNCTION public.user_is_thread_participant(thread_id uuid) TO service_role;


--
-- Name: FUNCTION veedon_bump_branch_config(); Type: ACL; Schema: public; Owner: postgres
--

GRANT ALL ON FUNCTION public.veedon_bump_branch_config() TO anon;
GRANT ALL ON FUNCTION public.veedon_bump_branch_config() TO authenticated;
GRANT ALL ON FUNCTION public.veedon_bump_branch_config() TO service_role;


--
-- Name: FUNCTION apply_rls(wal jsonb, max_record_bytes integer); Type: ACL; Schema: realtime; Owner: supabase_admin
--

GRANT ALL ON FUNCTION realtime.apply_rls(wal jsonb, max_record_bytes integer) TO postgres;
GRANT ALL ON FUNCTION realtime.apply_rls(wal jsonb, max_record_bytes integer) TO dashboard_user;
GRANT ALL ON FUNCTION realtime.apply_rls(wal jsonb, max_record_bytes integer) TO anon;
GRANT ALL ON FUNCTION realtime.apply_rls(wal jsonb, max_record_bytes integer) TO authenticated;
GRANT ALL ON FUNCTION realtime.apply_rls(wal jsonb, max_record_bytes integer) TO service_role;
GRANT ALL ON FUNCTION realtime.apply_rls(wal jsonb, max_record_bytes integer) TO supabase_realtime_admin;


--
-- Name: FUNCTION broadcast_changes(topic_name text, event_name text, operation text, table_name text, table_schema text, new record, old record, level text); Type: ACL; Schema: realtime; Owner: supabase_admin
--

GRANT ALL ON FUNCTION realtime.broadcast_changes(topic_name text, event_name text, operation text, table_name text, table_schema text, new record, old record, level text) TO postgres;
GRANT ALL ON FUNCTION realtime.broadcast_changes(topic_name text, event_name text, operation text, table_name text, table_schema text, new record, old record, level text) TO dashboard_user;


--
-- Name: FUNCTION build_prepared_statement_sql(prepared_statement_name text, entity regclass, columns realtime.wal_column[]); Type: ACL; Schema: realtime; Owner: supabase_admin
--

GRANT ALL ON FUNCTION realtime.build_prepared_statement_sql(prepared_statement_name text, entity regclass, columns realtime.wal_column[]) TO postgres;
GRANT ALL ON FUNCTION realtime.build_prepared_statement_sql(prepared_statement_name text, entity regclass, columns realtime.wal_column[]) TO dashboard_user;
GRANT ALL ON FUNCTION realtime.build_prepared_statement_sql(prepared_statement_name text, entity regclass, columns realtime.wal_column[]) TO anon;
GRANT ALL ON FUNCTION realtime.build_prepared_statement_sql(prepared_statement_name text, entity regclass, columns realtime.wal_column[]) TO authenticated;
GRANT ALL ON FUNCTION realtime.build_prepared_statement_sql(prepared_statement_name text, entity regclass, columns realtime.wal_column[]) TO service_role;
GRANT ALL ON FUNCTION realtime.build_prepared_statement_sql(prepared_statement_name text, entity regclass, columns realtime.wal_column[]) TO supabase_realtime_admin;


--
-- Name: FUNCTION "cast"(val text, type_ regtype); Type: ACL; Schema: realtime; Owner: supabase_admin
--

GRANT ALL ON FUNCTION realtime."cast"(val text, type_ regtype) TO postgres;
GRANT ALL ON FUNCTION realtime."cast"(val text, type_ regtype) TO dashboard_user;
GRANT ALL ON FUNCTION realtime."cast"(val text, type_ regtype) TO anon;
GRANT ALL ON FUNCTION realtime."cast"(val text, type_ regtype) TO authenticated;
GRANT ALL ON FUNCTION realtime."cast"(val text, type_ regtype) TO service_role;
GRANT ALL ON FUNCTION realtime."cast"(val text, type_ regtype) TO supabase_realtime_admin;


--
-- Name: FUNCTION check_equality_op(op realtime.equality_op, type_ regtype, val_1 text, val_2 text); Type: ACL; Schema: realtime; Owner: supabase_admin
--

GRANT ALL ON FUNCTION realtime.check_equality_op(op realtime.equality_op, type_ regtype, val_1 text, val_2 text) TO postgres;
GRANT ALL ON FUNCTION realtime.check_equality_op(op realtime.equality_op, type_ regtype, val_1 text, val_2 text) TO dashboard_user;
GRANT ALL ON FUNCTION realtime.check_equality_op(op realtime.equality_op, type_ regtype, val_1 text, val_2 text) TO anon;
GRANT ALL ON FUNCTION realtime.check_equality_op(op realtime.equality_op, type_ regtype, val_1 text, val_2 text) TO authenticated;
GRANT ALL ON FUNCTION realtime.check_equality_op(op realtime.equality_op, type_ regtype, val_1 text, val_2 text) TO service_role;
GRANT ALL ON FUNCTION realtime.check_equality_op(op realtime.equality_op, type_ regtype, val_1 text, val_2 text) TO supabase_realtime_admin;


--
-- Name: FUNCTION is_visible_through_filters(columns realtime.wal_column[], filters realtime.user_defined_filter[]); Type: ACL; Schema: realtime; Owner: supabase_admin
--

GRANT ALL ON FUNCTION realtime.is_visible_through_filters(columns realtime.wal_column[], filters realtime.user_defined_filter[]) TO postgres;
GRANT ALL ON FUNCTION realtime.is_visible_through_filters(columns realtime.wal_column[], filters realtime.user_defined_filter[]) TO dashboard_user;
GRANT ALL ON FUNCTION realtime.is_visible_through_filters(columns realtime.wal_column[], filters realtime.user_defined_filter[]) TO anon;
GRANT ALL ON FUNCTION realtime.is_visible_through_filters(columns realtime.wal_column[], filters realtime.user_defined_filter[]) TO authenticated;
GRANT ALL ON FUNCTION realtime.is_visible_through_filters(columns realtime.wal_column[], filters realtime.user_defined_filter[]) TO service_role;
GRANT ALL ON FUNCTION realtime.is_visible_through_filters(columns realtime.wal_column[], filters realtime.user_defined_filter[]) TO supabase_realtime_admin;


--
-- Name: FUNCTION list_changes(publication name, slot_name name, max_changes integer, max_record_bytes integer); Type: ACL; Schema: realtime; Owner: supabase_admin
--

GRANT ALL ON FUNCTION realtime.list_changes(publication name, slot_name name, max_changes integer, max_record_bytes integer) TO postgres;
GRANT ALL ON FUNCTION realtime.list_changes(publication name, slot_name name, max_changes integer, max_record_bytes integer) TO dashboard_user;


--
-- Name: FUNCTION quote_wal2json(entity regclass); Type: ACL; Schema: realtime; Owner: supabase_admin
--

GRANT ALL ON FUNCTION realtime.quote_wal2json(entity regclass) TO postgres;
GRANT ALL ON FUNCTION realtime.quote_wal2json(entity regclass) TO dashboard_user;
GRANT ALL ON FUNCTION realtime.quote_wal2json(entity regclass) TO anon;
GRANT ALL ON FUNCTION realtime.quote_wal2json(entity regclass) TO authenticated;
GRANT ALL ON FUNCTION realtime.quote_wal2json(entity regclass) TO service_role;
GRANT ALL ON FUNCTION realtime.quote_wal2json(entity regclass) TO supabase_realtime_admin;


--
-- Name: FUNCTION send(payload jsonb, event text, topic text, private boolean); Type: ACL; Schema: realtime; Owner: supabase_admin
--

GRANT ALL ON FUNCTION realtime.send(payload jsonb, event text, topic text, private boolean) TO postgres;
GRANT ALL ON FUNCTION realtime.send(payload jsonb, event text, topic text, private boolean) TO dashboard_user;


--
-- Name: FUNCTION send_binary(payload bytea, event text, topic text, private boolean); Type: ACL; Schema: realtime; Owner: supabase_admin
--

GRANT ALL ON FUNCTION realtime.send_binary(payload bytea, event text, topic text, private boolean) TO postgres;
GRANT ALL ON FUNCTION realtime.send_binary(payload bytea, event text, topic text, private boolean) TO dashboard_user;


--
-- Name: FUNCTION subscription_check_filters(); Type: ACL; Schema: realtime; Owner: supabase_admin
--

GRANT ALL ON FUNCTION realtime.subscription_check_filters() TO postgres;
GRANT ALL ON FUNCTION realtime.subscription_check_filters() TO dashboard_user;
GRANT ALL ON FUNCTION realtime.subscription_check_filters() TO anon;
GRANT ALL ON FUNCTION realtime.subscription_check_filters() TO authenticated;
GRANT ALL ON FUNCTION realtime.subscription_check_filters() TO service_role;
GRANT ALL ON FUNCTION realtime.subscription_check_filters() TO supabase_realtime_admin;


--
-- Name: FUNCTION to_regrole(role_name text); Type: ACL; Schema: realtime; Owner: supabase_admin
--

GRANT ALL ON FUNCTION realtime.to_regrole(role_name text) TO postgres;
GRANT ALL ON FUNCTION realtime.to_regrole(role_name text) TO dashboard_user;
GRANT ALL ON FUNCTION realtime.to_regrole(role_name text) TO anon;
GRANT ALL ON FUNCTION realtime.to_regrole(role_name text) TO authenticated;
GRANT ALL ON FUNCTION realtime.to_regrole(role_name text) TO service_role;
GRANT ALL ON FUNCTION realtime.to_regrole(role_name text) TO supabase_realtime_admin;


--
-- Name: FUNCTION topic(); Type: ACL; Schema: realtime; Owner: supabase_realtime_admin
--

GRANT ALL ON FUNCTION realtime.topic() TO postgres;
GRANT ALL ON FUNCTION realtime.topic() TO dashboard_user;


--
-- Name: FUNCTION wal2json_escape_identifier(name text); Type: ACL; Schema: realtime; Owner: supabase_admin
--

GRANT ALL ON FUNCTION realtime.wal2json_escape_identifier(name text) TO postgres;
GRANT ALL ON FUNCTION realtime.wal2json_escape_identifier(name text) TO dashboard_user;


--
-- Name: FUNCTION http_request(); Type: ACL; Schema: supabase_functions; Owner: supabase_functions_admin
--

REVOKE ALL ON FUNCTION supabase_functions.http_request() FROM PUBLIC;
GRANT ALL ON FUNCTION supabase_functions.http_request() TO postgres;
GRANT ALL ON FUNCTION supabase_functions.http_request() TO anon;
GRANT ALL ON FUNCTION supabase_functions.http_request() TO authenticated;
GRANT ALL ON FUNCTION supabase_functions.http_request() TO service_role;


--
-- Name: FUNCTION _crypto_aead_det_decrypt(message bytea, additional bytea, key_id bigint, context bytea, nonce bytea); Type: ACL; Schema: vault; Owner: supabase_admin
--

GRANT ALL ON FUNCTION vault._crypto_aead_det_decrypt(message bytea, additional bytea, key_id bigint, context bytea, nonce bytea) TO postgres WITH GRANT OPTION;
GRANT ALL ON FUNCTION vault._crypto_aead_det_decrypt(message bytea, additional bytea, key_id bigint, context bytea, nonce bytea) TO service_role;


--
-- Name: FUNCTION create_secret(new_secret text, new_name text, new_description text, new_key_id uuid); Type: ACL; Schema: vault; Owner: supabase_admin
--

GRANT ALL ON FUNCTION vault.create_secret(new_secret text, new_name text, new_description text, new_key_id uuid) TO postgres WITH GRANT OPTION;
GRANT ALL ON FUNCTION vault.create_secret(new_secret text, new_name text, new_description text, new_key_id uuid) TO service_role;


--
-- Name: FUNCTION update_secret(secret_id uuid, new_secret text, new_name text, new_description text, new_key_id uuid); Type: ACL; Schema: vault; Owner: supabase_admin
--

GRANT ALL ON FUNCTION vault.update_secret(secret_id uuid, new_secret text, new_name text, new_description text, new_key_id uuid) TO postgres WITH GRANT OPTION;
GRANT ALL ON FUNCTION vault.update_secret(secret_id uuid, new_secret text, new_name text, new_description text, new_key_id uuid) TO service_role;


--
-- Name: TABLE audit_log_entries; Type: ACL; Schema: auth; Owner: supabase_auth_admin
--

GRANT ALL ON TABLE auth.audit_log_entries TO dashboard_user;
GRANT INSERT,REFERENCES,DELETE,TRIGGER,TRUNCATE,MAINTAIN,UPDATE ON TABLE auth.audit_log_entries TO postgres;
GRANT SELECT ON TABLE auth.audit_log_entries TO postgres WITH GRANT OPTION;


--
-- Name: TABLE custom_oauth_providers; Type: ACL; Schema: auth; Owner: supabase_auth_admin
--

GRANT ALL ON TABLE auth.custom_oauth_providers TO postgres;
GRANT ALL ON TABLE auth.custom_oauth_providers TO dashboard_user;


--
-- Name: TABLE flow_state; Type: ACL; Schema: auth; Owner: supabase_auth_admin
--

GRANT INSERT,REFERENCES,DELETE,TRIGGER,TRUNCATE,MAINTAIN,UPDATE ON TABLE auth.flow_state TO postgres;
GRANT SELECT ON TABLE auth.flow_state TO postgres WITH GRANT OPTION;
GRANT ALL ON TABLE auth.flow_state TO dashboard_user;


--
-- Name: TABLE identities; Type: ACL; Schema: auth; Owner: supabase_auth_admin
--

GRANT INSERT,REFERENCES,DELETE,TRIGGER,TRUNCATE,MAINTAIN,UPDATE ON TABLE auth.identities TO postgres;
GRANT SELECT ON TABLE auth.identities TO postgres WITH GRANT OPTION;
GRANT ALL ON TABLE auth.identities TO dashboard_user;


--
-- Name: TABLE instances; Type: ACL; Schema: auth; Owner: supabase_auth_admin
--

GRANT ALL ON TABLE auth.instances TO dashboard_user;
GRANT INSERT,REFERENCES,DELETE,TRIGGER,TRUNCATE,MAINTAIN,UPDATE ON TABLE auth.instances TO postgres;
GRANT SELECT ON TABLE auth.instances TO postgres WITH GRANT OPTION;


--
-- Name: TABLE mfa_amr_claims; Type: ACL; Schema: auth; Owner: supabase_auth_admin
--

GRANT INSERT,REFERENCES,DELETE,TRIGGER,TRUNCATE,MAINTAIN,UPDATE ON TABLE auth.mfa_amr_claims TO postgres;
GRANT SELECT ON TABLE auth.mfa_amr_claims TO postgres WITH GRANT OPTION;
GRANT ALL ON TABLE auth.mfa_amr_claims TO dashboard_user;


--
-- Name: TABLE mfa_challenges; Type: ACL; Schema: auth; Owner: supabase_auth_admin
--

GRANT INSERT,REFERENCES,DELETE,TRIGGER,TRUNCATE,MAINTAIN,UPDATE ON TABLE auth.mfa_challenges TO postgres;
GRANT SELECT ON TABLE auth.mfa_challenges TO postgres WITH GRANT OPTION;
GRANT ALL ON TABLE auth.mfa_challenges TO dashboard_user;


--
-- Name: TABLE mfa_factors; Type: ACL; Schema: auth; Owner: supabase_auth_admin
--

GRANT INSERT,REFERENCES,DELETE,TRIGGER,TRUNCATE,MAINTAIN,UPDATE ON TABLE auth.mfa_factors TO postgres;
GRANT SELECT ON TABLE auth.mfa_factors TO postgres WITH GRANT OPTION;
GRANT ALL ON TABLE auth.mfa_factors TO dashboard_user;


--
-- Name: TABLE oauth_authorizations; Type: ACL; Schema: auth; Owner: supabase_auth_admin
--

GRANT ALL ON TABLE auth.oauth_authorizations TO postgres;
GRANT ALL ON TABLE auth.oauth_authorizations TO dashboard_user;


--
-- Name: TABLE oauth_client_states; Type: ACL; Schema: auth; Owner: supabase_auth_admin
--

GRANT ALL ON TABLE auth.oauth_client_states TO postgres;
GRANT ALL ON TABLE auth.oauth_client_states TO dashboard_user;


--
-- Name: TABLE oauth_clients; Type: ACL; Schema: auth; Owner: supabase_auth_admin
--

GRANT ALL ON TABLE auth.oauth_clients TO postgres;
GRANT ALL ON TABLE auth.oauth_clients TO dashboard_user;


--
-- Name: TABLE oauth_consents; Type: ACL; Schema: auth; Owner: supabase_auth_admin
--

GRANT ALL ON TABLE auth.oauth_consents TO postgres;
GRANT ALL ON TABLE auth.oauth_consents TO dashboard_user;


--
-- Name: TABLE one_time_tokens; Type: ACL; Schema: auth; Owner: supabase_auth_admin
--

GRANT INSERT,REFERENCES,DELETE,TRIGGER,TRUNCATE,MAINTAIN,UPDATE ON TABLE auth.one_time_tokens TO postgres;
GRANT SELECT ON TABLE auth.one_time_tokens TO postgres WITH GRANT OPTION;
GRANT ALL ON TABLE auth.one_time_tokens TO dashboard_user;


--
-- Name: TABLE refresh_tokens; Type: ACL; Schema: auth; Owner: supabase_auth_admin
--

GRANT ALL ON TABLE auth.refresh_tokens TO dashboard_user;
GRANT INSERT,REFERENCES,DELETE,TRIGGER,TRUNCATE,MAINTAIN,UPDATE ON TABLE auth.refresh_tokens TO postgres;
GRANT SELECT ON TABLE auth.refresh_tokens TO postgres WITH GRANT OPTION;


--
-- Name: SEQUENCE refresh_tokens_id_seq; Type: ACL; Schema: auth; Owner: supabase_auth_admin
--

GRANT ALL ON SEQUENCE auth.refresh_tokens_id_seq TO dashboard_user;
GRANT ALL ON SEQUENCE auth.refresh_tokens_id_seq TO postgres;


--
-- Name: TABLE saml_providers; Type: ACL; Schema: auth; Owner: supabase_auth_admin
--

GRANT INSERT,REFERENCES,DELETE,TRIGGER,TRUNCATE,MAINTAIN,UPDATE ON TABLE auth.saml_providers TO postgres;
GRANT SELECT ON TABLE auth.saml_providers TO postgres WITH GRANT OPTION;
GRANT ALL ON TABLE auth.saml_providers TO dashboard_user;


--
-- Name: TABLE saml_relay_states; Type: ACL; Schema: auth; Owner: supabase_auth_admin
--

GRANT INSERT,REFERENCES,DELETE,TRIGGER,TRUNCATE,MAINTAIN,UPDATE ON TABLE auth.saml_relay_states TO postgres;
GRANT SELECT ON TABLE auth.saml_relay_states TO postgres WITH GRANT OPTION;
GRANT ALL ON TABLE auth.saml_relay_states TO dashboard_user;


--
-- Name: TABLE schema_migrations; Type: ACL; Schema: auth; Owner: supabase_auth_admin
--

GRANT SELECT ON TABLE auth.schema_migrations TO postgres WITH GRANT OPTION;


--
-- Name: TABLE sessions; Type: ACL; Schema: auth; Owner: supabase_auth_admin
--

GRANT INSERT,REFERENCES,DELETE,TRIGGER,TRUNCATE,MAINTAIN,UPDATE ON TABLE auth.sessions TO postgres;
GRANT SELECT ON TABLE auth.sessions TO postgres WITH GRANT OPTION;
GRANT ALL ON TABLE auth.sessions TO dashboard_user;


--
-- Name: TABLE sso_domains; Type: ACL; Schema: auth; Owner: supabase_auth_admin
--

GRANT INSERT,REFERENCES,DELETE,TRIGGER,TRUNCATE,MAINTAIN,UPDATE ON TABLE auth.sso_domains TO postgres;
GRANT SELECT ON TABLE auth.sso_domains TO postgres WITH GRANT OPTION;
GRANT ALL ON TABLE auth.sso_domains TO dashboard_user;


--
-- Name: TABLE sso_providers; Type: ACL; Schema: auth; Owner: supabase_auth_admin
--

GRANT INSERT,REFERENCES,DELETE,TRIGGER,TRUNCATE,MAINTAIN,UPDATE ON TABLE auth.sso_providers TO postgres;
GRANT SELECT ON TABLE auth.sso_providers TO postgres WITH GRANT OPTION;
GRANT ALL ON TABLE auth.sso_providers TO dashboard_user;


--
-- Name: TABLE users; Type: ACL; Schema: auth; Owner: supabase_auth_admin
--

GRANT ALL ON TABLE auth.users TO dashboard_user;
GRANT INSERT,REFERENCES,DELETE,TRIGGER,TRUNCATE,MAINTAIN,UPDATE ON TABLE auth.users TO postgres;
GRANT SELECT ON TABLE auth.users TO postgres WITH GRANT OPTION;


--
-- Name: TABLE webauthn_challenges; Type: ACL; Schema: auth; Owner: supabase_auth_admin
--

GRANT ALL ON TABLE auth.webauthn_challenges TO postgres;
GRANT ALL ON TABLE auth.webauthn_challenges TO dashboard_user;


--
-- Name: TABLE webauthn_credentials; Type: ACL; Schema: auth; Owner: supabase_auth_admin
--

GRANT ALL ON TABLE auth.webauthn_credentials TO postgres;
GRANT ALL ON TABLE auth.webauthn_credentials TO dashboard_user;


--
-- Name: TABLE pg_stat_statements; Type: ACL; Schema: extensions; Owner: supabase_admin
--

GRANT ALL ON TABLE extensions.pg_stat_statements TO postgres WITH GRANT OPTION;


--
-- Name: TABLE pg_stat_statements_info; Type: ACL; Schema: extensions; Owner: supabase_admin
--

GRANT ALL ON TABLE extensions.pg_stat_statements_info TO postgres WITH GRANT OPTION;


--
-- Name: TABLE ai_analysis_logs; Type: ACL; Schema: public; Owner: postgres
--

GRANT ALL ON TABLE public.ai_analysis_logs TO anon;
GRANT ALL ON TABLE public.ai_analysis_logs TO authenticated;
GRANT ALL ON TABLE public.ai_analysis_logs TO service_role;


--
-- Name: TABLE ai_models; Type: ACL; Schema: public; Owner: postgres
--

GRANT ALL ON TABLE public.ai_models TO anon;
GRANT ALL ON TABLE public.ai_models TO authenticated;
GRANT ALL ON TABLE public.ai_models TO service_role;


--
-- Name: TABLE alert_template_events; Type: ACL; Schema: public; Owner: postgres
--

GRANT ALL ON TABLE public.alert_template_events TO anon;
GRANT ALL ON TABLE public.alert_template_events TO authenticated;
GRANT ALL ON TABLE public.alert_template_events TO service_role;


--
-- Name: TABLE alert_template_industries; Type: ACL; Schema: public; Owner: postgres
--

GRANT ALL ON TABLE public.alert_template_industries TO anon;
GRANT ALL ON TABLE public.alert_template_industries TO authenticated;
GRANT ALL ON TABLE public.alert_template_industries TO service_role;


--
-- Name: TABLE alert_templates; Type: ACL; Schema: public; Owner: postgres
--

GRANT ALL ON TABLE public.alert_templates TO anon;
GRANT ALL ON TABLE public.alert_templates TO authenticated;
GRANT ALL ON TABLE public.alert_templates TO service_role;


--
-- Name: TABLE aman_instances; Type: ACL; Schema: public; Owner: postgres
--

GRANT ALL ON TABLE public.aman_instances TO service_role;
GRANT SELECT,INSERT,DELETE,UPDATE ON TABLE public.aman_instances TO authenticated;


--
-- Name: COLUMN aman_instances.id; Type: ACL; Schema: public; Owner: postgres
--

GRANT SELECT(id) ON TABLE public.aman_instances TO authenticated;


--
-- Name: COLUMN aman_instances.organization_id; Type: ACL; Schema: public; Owner: postgres
--

GRANT SELECT(organization_id) ON TABLE public.aman_instances TO authenticated;


--
-- Name: COLUMN aman_instances.branch_id; Type: ACL; Schema: public; Owner: postgres
--

GRANT SELECT(branch_id) ON TABLE public.aman_instances TO authenticated;


--
-- Name: COLUMN aman_instances.name; Type: ACL; Schema: public; Owner: postgres
--

GRANT SELECT(name) ON TABLE public.aman_instances TO authenticated;


--
-- Name: COLUMN aman_instances.base_url; Type: ACL; Schema: public; Owner: postgres
--

GRANT SELECT(base_url) ON TABLE public.aman_instances TO authenticated;


--
-- Name: COLUMN aman_instances.active; Type: ACL; Schema: public; Owner: postgres
--

GRANT SELECT(active) ON TABLE public.aman_instances TO authenticated;


--
-- Name: COLUMN aman_instances.created_by; Type: ACL; Schema: public; Owner: postgres
--

GRANT SELECT(created_by) ON TABLE public.aman_instances TO authenticated;


--
-- Name: COLUMN aman_instances.created_at; Type: ACL; Schema: public; Owner: postgres
--

GRANT SELECT(created_at) ON TABLE public.aman_instances TO authenticated;


--
-- Name: COLUMN aman_instances.updated_at; Type: ACL; Schema: public; Owner: postgres
--

GRANT SELECT(updated_at) ON TABLE public.aman_instances TO authenticated;


--
-- Name: TABLE auto_sync_settings; Type: ACL; Schema: public; Owner: postgres
--

GRANT ALL ON TABLE public.auto_sync_settings TO anon;
GRANT ALL ON TABLE public.auto_sync_settings TO authenticated;
GRANT ALL ON TABLE public.auto_sync_settings TO service_role;


--
-- Name: TABLE branch_roles; Type: ACL; Schema: public; Owner: postgres
--

GRANT ALL ON TABLE public.branch_roles TO anon;
GRANT ALL ON TABLE public.branch_roles TO authenticated;
GRANT ALL ON TABLE public.branch_roles TO service_role;


--
-- Name: TABLE branches; Type: ACL; Schema: public; Owner: postgres
--

GRANT ALL ON TABLE public.branches TO anon;
GRANT ALL ON TABLE public.branches TO authenticated;
GRANT ALL ON TABLE public.branches TO service_role;


--
-- Name: TABLE camera_alert_assignments; Type: ACL; Schema: public; Owner: postgres
--

GRANT ALL ON TABLE public.camera_alert_assignments TO anon;
GRANT ALL ON TABLE public.camera_alert_assignments TO authenticated;
GRANT ALL ON TABLE public.camera_alert_assignments TO service_role;


--
-- Name: TABLE camera_event_assignments; Type: ACL; Schema: public; Owner: postgres
--

GRANT ALL ON TABLE public.camera_event_assignments TO anon;
GRANT ALL ON TABLE public.camera_event_assignments TO authenticated;
GRANT ALL ON TABLE public.camera_event_assignments TO service_role;


--
-- Name: TABLE camera_sources; Type: ACL; Schema: public; Owner: postgres
--

GRANT ALL ON TABLE public.camera_sources TO anon;
GRANT ALL ON TABLE public.camera_sources TO authenticated;
GRANT ALL ON TABLE public.camera_sources TO service_role;


--
-- Name: TABLE cameras; Type: ACL; Schema: public; Owner: postgres
--

GRANT ALL ON TABLE public.cameras TO anon;
GRANT ALL ON TABLE public.cameras TO authenticated;
GRANT ALL ON TABLE public.cameras TO service_role;


--
-- Name: TABLE chat_messages; Type: ACL; Schema: public; Owner: postgres
--

GRANT ALL ON TABLE public.chat_messages TO anon;
GRANT ALL ON TABLE public.chat_messages TO authenticated;
GRANT ALL ON TABLE public.chat_messages TO service_role;


--
-- Name: TABLE chat_thread_participants; Type: ACL; Schema: public; Owner: postgres
--

GRANT ALL ON TABLE public.chat_thread_participants TO anon;
GRANT ALL ON TABLE public.chat_thread_participants TO authenticated;
GRANT ALL ON TABLE public.chat_thread_participants TO service_role;


--
-- Name: TABLE chat_threads; Type: ACL; Schema: public; Owner: postgres
--

GRANT ALL ON TABLE public.chat_threads TO anon;
GRANT ALL ON TABLE public.chat_threads TO authenticated;
GRANT ALL ON TABLE public.chat_threads TO service_role;


--
-- Name: TABLE chatbot_knowledge_base; Type: ACL; Schema: public; Owner: postgres
--

GRANT ALL ON TABLE public.chatbot_knowledge_base TO anon;
GRANT ALL ON TABLE public.chatbot_knowledge_base TO authenticated;
GRANT ALL ON TABLE public.chatbot_knowledge_base TO service_role;


--
-- Name: TABLE detection_rules; Type: ACL; Schema: public; Owner: postgres
--

GRANT ALL ON TABLE public.detection_rules TO anon;
GRANT ALL ON TABLE public.detection_rules TO authenticated;
GRANT ALL ON TABLE public.detection_rules TO service_role;


--
-- Name: TABLE event_types; Type: ACL; Schema: public; Owner: postgres
--

GRANT ALL ON TABLE public.event_types TO anon;
GRANT ALL ON TABLE public.event_types TO authenticated;
GRANT ALL ON TABLE public.event_types TO service_role;


--
-- Name: TABLE events; Type: ACL; Schema: public; Owner: postgres
--

GRANT ALL ON TABLE public.events TO anon;
GRANT ALL ON TABLE public.events TO authenticated;
GRANT ALL ON TABLE public.events TO service_role;


--
-- Name: TABLE form_assignments; Type: ACL; Schema: public; Owner: postgres
--

GRANT ALL ON TABLE public.form_assignments TO anon;
GRANT ALL ON TABLE public.form_assignments TO authenticated;
GRANT ALL ON TABLE public.form_assignments TO service_role;


--
-- Name: TABLE form_distribution_settings; Type: ACL; Schema: public; Owner: postgres
--

GRANT ALL ON TABLE public.form_distribution_settings TO anon;
GRANT ALL ON TABLE public.form_distribution_settings TO authenticated;
GRANT ALL ON TABLE public.form_distribution_settings TO service_role;


--
-- Name: TABLE form_submissions; Type: ACL; Schema: public; Owner: postgres
--

GRANT ALL ON TABLE public.form_submissions TO anon;
GRANT ALL ON TABLE public.form_submissions TO authenticated;
GRANT ALL ON TABLE public.form_submissions TO service_role;


--
-- Name: TABLE frigate_alert_rules; Type: ACL; Schema: public; Owner: postgres
--

GRANT ALL ON TABLE public.frigate_alert_rules TO anon;
GRANT ALL ON TABLE public.frigate_alert_rules TO authenticated;
GRANT ALL ON TABLE public.frigate_alert_rules TO service_role;


--
-- Name: TABLE frigate_deployed_models; Type: ACL; Schema: public; Owner: postgres
--

GRANT ALL ON TABLE public.frigate_deployed_models TO anon;
GRANT ALL ON TABLE public.frigate_deployed_models TO authenticated;
GRANT ALL ON TABLE public.frigate_deployed_models TO service_role;


--
-- Name: TABLE frigate_exports; Type: ACL; Schema: public; Owner: postgres
--

GRANT ALL ON TABLE public.frigate_exports TO anon;
GRANT ALL ON TABLE public.frigate_exports TO authenticated;
GRANT ALL ON TABLE public.frigate_exports TO service_role;


--
-- Name: TABLE frigate_faces; Type: ACL; Schema: public; Owner: postgres
--

GRANT ALL ON TABLE public.frigate_faces TO anon;
GRANT ALL ON TABLE public.frigate_faces TO authenticated;
GRANT ALL ON TABLE public.frigate_faces TO service_role;


--
-- Name: TABLE frigate_instances; Type: ACL; Schema: public; Owner: postgres
--

GRANT ALL ON TABLE public.frigate_instances TO anon;
GRANT ALL ON TABLE public.frigate_instances TO authenticated;
GRANT ALL ON TABLE public.frigate_instances TO service_role;


--
-- Name: TABLE frigate_license_plates; Type: ACL; Schema: public; Owner: postgres
--

GRANT ALL ON TABLE public.frigate_license_plates TO anon;
GRANT ALL ON TABLE public.frigate_license_plates TO authenticated;
GRANT ALL ON TABLE public.frigate_license_plates TO service_role;


--
-- Name: TABLE frigate_model_deployments; Type: ACL; Schema: public; Owner: postgres
--

GRANT ALL ON TABLE public.frigate_model_deployments TO anon;
GRANT ALL ON TABLE public.frigate_model_deployments TO authenticated;
GRANT ALL ON TABLE public.frigate_model_deployments TO service_role;


--
-- Name: TABLE frigate_model_registry; Type: ACL; Schema: public; Owner: postgres
--

GRANT ALL ON TABLE public.frigate_model_registry TO anon;
GRANT ALL ON TABLE public.frigate_model_registry TO authenticated;
GRANT ALL ON TABLE public.frigate_model_registry TO service_role;


--
-- Name: TABLE frigate_model_sync_log; Type: ACL; Schema: public; Owner: postgres
--

GRANT ALL ON TABLE public.frigate_model_sync_log TO anon;
GRANT ALL ON TABLE public.frigate_model_sync_log TO authenticated;
GRANT ALL ON TABLE public.frigate_model_sync_log TO service_role;


--
-- Name: TABLE frigate_previews; Type: ACL; Schema: public; Owner: postgres
--

GRANT ALL ON TABLE public.frigate_previews TO anon;
GRANT ALL ON TABLE public.frigate_previews TO authenticated;
GRANT ALL ON TABLE public.frigate_previews TO service_role;


--
-- Name: TABLE frigate_recordings; Type: ACL; Schema: public; Owner: postgres
--

GRANT ALL ON TABLE public.frigate_recordings TO anon;
GRANT ALL ON TABLE public.frigate_recordings TO authenticated;
GRANT ALL ON TABLE public.frigate_recordings TO service_role;


--
-- Name: TABLE frigate_reviews; Type: ACL; Schema: public; Owner: postgres
--

GRANT ALL ON TABLE public.frigate_reviews TO anon;
GRANT ALL ON TABLE public.frigate_reviews TO authenticated;
GRANT ALL ON TABLE public.frigate_reviews TO service_role;


--
-- Name: TABLE frigate_stats_history; Type: ACL; Schema: public; Owner: postgres
--

GRANT ALL ON TABLE public.frigate_stats_history TO anon;
GRANT ALL ON TABLE public.frigate_stats_history TO authenticated;
GRANT ALL ON TABLE public.frigate_stats_history TO service_role;


--
-- Name: TABLE frigate_sync_logs; Type: ACL; Schema: public; Owner: postgres
--

GRANT ALL ON TABLE public.frigate_sync_logs TO anon;
GRANT ALL ON TABLE public.frigate_sync_logs TO authenticated;
GRANT ALL ON TABLE public.frigate_sync_logs TO service_role;


--
-- Name: TABLE frigate_timeline; Type: ACL; Schema: public; Owner: postgres
--

GRANT ALL ON TABLE public.frigate_timeline TO anon;
GRANT ALL ON TABLE public.frigate_timeline TO authenticated;
GRANT ALL ON TABLE public.frigate_timeline TO service_role;


--
-- Name: TABLE frigate_triggers; Type: ACL; Schema: public; Owner: postgres
--

GRANT ALL ON TABLE public.frigate_triggers TO anon;
GRANT ALL ON TABLE public.frigate_triggers TO authenticated;
GRANT ALL ON TABLE public.frigate_triggers TO service_role;


--
-- Name: TABLE frigate_zones; Type: ACL; Schema: public; Owner: postgres
--

GRANT ALL ON TABLE public.frigate_zones TO anon;
GRANT ALL ON TABLE public.frigate_zones TO authenticated;
GRANT ALL ON TABLE public.frigate_zones TO service_role;


--
-- Name: TABLE health_alerts; Type: ACL; Schema: public; Owner: postgres
--

GRANT ALL ON TABLE public.health_alerts TO anon;
GRANT ALL ON TABLE public.health_alerts TO authenticated;
GRANT ALL ON TABLE public.health_alerts TO service_role;


--
-- Name: TABLE industries; Type: ACL; Schema: public; Owner: postgres
--

GRANT ALL ON TABLE public.industries TO anon;
GRANT ALL ON TABLE public.industries TO authenticated;
GRANT ALL ON TABLE public.industries TO service_role;


--
-- Name: TABLE legal_documents; Type: ACL; Schema: public; Owner: postgres
--

GRANT ALL ON TABLE public.legal_documents TO anon;
GRANT ALL ON TABLE public.legal_documents TO authenticated;
GRANT ALL ON TABLE public.legal_documents TO service_role;


--
-- Name: TABLE network_scan_results; Type: ACL; Schema: public; Owner: postgres
--

GRANT ALL ON TABLE public.network_scan_results TO anon;
GRANT ALL ON TABLE public.network_scan_results TO authenticated;
GRANT ALL ON TABLE public.network_scan_results TO service_role;


--
-- Name: TABLE notification_labels; Type: ACL; Schema: public; Owner: postgres
--

GRANT ALL ON TABLE public.notification_labels TO anon;
GRANT ALL ON TABLE public.notification_labels TO authenticated;
GRANT ALL ON TABLE public.notification_labels TO service_role;


--
-- Name: TABLE notification_methods; Type: ACL; Schema: public; Owner: postgres
--

GRANT ALL ON TABLE public.notification_methods TO anon;
GRANT ALL ON TABLE public.notification_methods TO authenticated;
GRANT ALL ON TABLE public.notification_methods TO service_role;


--
-- Name: TABLE organization_settings; Type: ACL; Schema: public; Owner: postgres
--

GRANT ALL ON TABLE public.organization_settings TO anon;
GRANT ALL ON TABLE public.organization_settings TO authenticated;
GRANT ALL ON TABLE public.organization_settings TO service_role;


--
-- Name: TABLE organizations; Type: ACL; Schema: public; Owner: postgres
--

GRANT ALL ON TABLE public.organizations TO anon;
GRANT ALL ON TABLE public.organizations TO authenticated;
GRANT ALL ON TABLE public.organizations TO service_role;


--
-- Name: TABLE pinned_dashboards; Type: ACL; Schema: public; Owner: postgres
--

GRANT ALL ON TABLE public.pinned_dashboards TO anon;
GRANT ALL ON TABLE public.pinned_dashboards TO authenticated;
GRANT ALL ON TABLE public.pinned_dashboards TO service_role;


--
-- Name: TABLE pinned_labels; Type: ACL; Schema: public; Owner: postgres
--

GRANT ALL ON TABLE public.pinned_labels TO anon;
GRANT ALL ON TABLE public.pinned_labels TO authenticated;
GRANT ALL ON TABLE public.pinned_labels TO service_role;


--
-- Name: TABLE screen_permissions; Type: ACL; Schema: public; Owner: postgres
--

GRANT ALL ON TABLE public.screen_permissions TO anon;
GRANT ALL ON TABLE public.screen_permissions TO authenticated;
GRANT ALL ON TABLE public.screen_permissions TO service_role;


--
-- Name: TABLE security_zones; Type: ACL; Schema: public; Owner: postgres
--

GRANT ALL ON TABLE public.security_zones TO anon;
GRANT ALL ON TABLE public.security_zones TO authenticated;
GRANT ALL ON TABLE public.security_zones TO service_role;


--
-- Name: TABLE storage_configs; Type: ACL; Schema: public; Owner: postgres
--

GRANT ALL ON TABLE public.storage_configs TO anon;
GRANT ALL ON TABLE public.storage_configs TO authenticated;
GRANT ALL ON TABLE public.storage_configs TO service_role;


--
-- Name: TABLE students; Type: ACL; Schema: public; Owner: postgres
--

GRANT ALL ON TABLE public.students TO anon;
GRANT ALL ON TABLE public.students TO authenticated;
GRANT ALL ON TABLE public.students TO service_role;


--
-- Name: TABLE subscribers; Type: ACL; Schema: public; Owner: postgres
--

GRANT ALL ON TABLE public.subscribers TO anon;
GRANT ALL ON TABLE public.subscribers TO authenticated;
GRANT ALL ON TABLE public.subscribers TO service_role;


--
-- Name: TABLE system_settings; Type: ACL; Schema: public; Owner: postgres
--

GRANT ALL ON TABLE public.system_settings TO anon;
GRANT ALL ON TABLE public.system_settings TO authenticated;
GRANT ALL ON TABLE public.system_settings TO service_role;


--
-- Name: TABLE user_branch_access; Type: ACL; Schema: public; Owner: postgres
--

GRANT ALL ON TABLE public.user_branch_access TO anon;
GRANT ALL ON TABLE public.user_branch_access TO authenticated;
GRANT ALL ON TABLE public.user_branch_access TO service_role;


--
-- Name: TABLE user_group_members; Type: ACL; Schema: public; Owner: postgres
--

GRANT ALL ON TABLE public.user_group_members TO anon;
GRANT ALL ON TABLE public.user_group_members TO authenticated;
GRANT ALL ON TABLE public.user_group_members TO service_role;


--
-- Name: TABLE user_groups; Type: ACL; Schema: public; Owner: postgres
--

GRANT ALL ON TABLE public.user_groups TO anon;
GRANT ALL ON TABLE public.user_groups TO authenticated;
GRANT ALL ON TABLE public.user_groups TO service_role;


--
-- Name: TABLE user_preferences; Type: ACL; Schema: public; Owner: postgres
--

GRANT ALL ON TABLE public.user_preferences TO anon;
GRANT ALL ON TABLE public.user_preferences TO authenticated;
GRANT ALL ON TABLE public.user_preferences TO service_role;


--
-- Name: TABLE user_roles; Type: ACL; Schema: public; Owner: postgres
--

GRANT ALL ON TABLE public.user_roles TO anon;
GRANT ALL ON TABLE public.user_roles TO authenticated;
GRANT ALL ON TABLE public.user_roles TO service_role;


--
-- Name: TABLE workflow_forms; Type: ACL; Schema: public; Owner: postgres
--

GRANT ALL ON TABLE public.workflow_forms TO anon;
GRANT ALL ON TABLE public.workflow_forms TO authenticated;
GRANT ALL ON TABLE public.workflow_forms TO service_role;


--
-- Name: TABLE messages; Type: ACL; Schema: realtime; Owner: supabase_realtime_admin
--

GRANT ALL ON TABLE realtime.messages TO postgres;
GRANT ALL ON TABLE realtime.messages TO dashboard_user;
GRANT SELECT,INSERT,UPDATE ON TABLE realtime.messages TO anon;
GRANT SELECT,INSERT,UPDATE ON TABLE realtime.messages TO authenticated;
GRANT SELECT,INSERT,UPDATE ON TABLE realtime.messages TO service_role;


--
-- Name: TABLE messages_2026_07_02; Type: ACL; Schema: realtime; Owner: supabase_admin
--

GRANT ALL ON TABLE realtime.messages_2026_07_02 TO postgres;
GRANT ALL ON TABLE realtime.messages_2026_07_02 TO dashboard_user;


--
-- Name: TABLE messages_2026_07_03; Type: ACL; Schema: realtime; Owner: supabase_admin
--

GRANT ALL ON TABLE realtime.messages_2026_07_03 TO postgres;
GRANT ALL ON TABLE realtime.messages_2026_07_03 TO dashboard_user;


--
-- Name: TABLE messages_2026_07_04; Type: ACL; Schema: realtime; Owner: supabase_admin
--

GRANT ALL ON TABLE realtime.messages_2026_07_04 TO postgres;
GRANT ALL ON TABLE realtime.messages_2026_07_04 TO dashboard_user;


--
-- Name: TABLE messages_2026_07_05; Type: ACL; Schema: realtime; Owner: supabase_admin
--

GRANT ALL ON TABLE realtime.messages_2026_07_05 TO postgres;
GRANT ALL ON TABLE realtime.messages_2026_07_05 TO dashboard_user;


--
-- Name: TABLE messages_2026_07_06; Type: ACL; Schema: realtime; Owner: supabase_admin
--

GRANT ALL ON TABLE realtime.messages_2026_07_06 TO postgres;
GRANT ALL ON TABLE realtime.messages_2026_07_06 TO dashboard_user;


--
-- Name: TABLE messages_2026_07_07; Type: ACL; Schema: realtime; Owner: supabase_admin
--

GRANT ALL ON TABLE realtime.messages_2026_07_07 TO postgres;
GRANT ALL ON TABLE realtime.messages_2026_07_07 TO dashboard_user;


--
-- Name: TABLE messages_2026_07_08; Type: ACL; Schema: realtime; Owner: supabase_admin
--

GRANT ALL ON TABLE realtime.messages_2026_07_08 TO postgres;
GRANT ALL ON TABLE realtime.messages_2026_07_08 TO dashboard_user;


--
-- Name: TABLE schema_migrations; Type: ACL; Schema: realtime; Owner: supabase_admin
--

GRANT ALL ON TABLE realtime.schema_migrations TO postgres;
GRANT ALL ON TABLE realtime.schema_migrations TO dashboard_user;
GRANT SELECT ON TABLE realtime.schema_migrations TO anon;
GRANT SELECT ON TABLE realtime.schema_migrations TO authenticated;
GRANT SELECT ON TABLE realtime.schema_migrations TO service_role;
GRANT ALL ON TABLE realtime.schema_migrations TO supabase_realtime_admin;


--
-- Name: TABLE subscription; Type: ACL; Schema: realtime; Owner: supabase_admin
--

GRANT ALL ON TABLE realtime.subscription TO postgres;
GRANT ALL ON TABLE realtime.subscription TO dashboard_user;
GRANT SELECT ON TABLE realtime.subscription TO anon;
GRANT SELECT ON TABLE realtime.subscription TO authenticated;
GRANT SELECT ON TABLE realtime.subscription TO service_role;
GRANT ALL ON TABLE realtime.subscription TO supabase_realtime_admin;


--
-- Name: SEQUENCE subscription_id_seq; Type: ACL; Schema: realtime; Owner: supabase_admin
--

GRANT ALL ON SEQUENCE realtime.subscription_id_seq TO postgres;
GRANT ALL ON SEQUENCE realtime.subscription_id_seq TO dashboard_user;
GRANT USAGE ON SEQUENCE realtime.subscription_id_seq TO anon;
GRANT USAGE ON SEQUENCE realtime.subscription_id_seq TO authenticated;
GRANT USAGE ON SEQUENCE realtime.subscription_id_seq TO service_role;
GRANT ALL ON SEQUENCE realtime.subscription_id_seq TO supabase_realtime_admin;


--
-- Name: TABLE buckets; Type: ACL; Schema: storage; Owner: supabase_storage_admin
--

GRANT ALL ON TABLE storage.buckets TO postgres WITH GRANT OPTION;
GRANT ALL ON TABLE storage.buckets TO service_role;
GRANT ALL ON TABLE storage.buckets TO authenticated;
GRANT ALL ON TABLE storage.buckets TO anon;


--
-- Name: TABLE buckets_analytics; Type: ACL; Schema: storage; Owner: supabase_storage_admin
--

GRANT ALL ON TABLE storage.buckets_analytics TO service_role;
GRANT ALL ON TABLE storage.buckets_analytics TO authenticated;
GRANT ALL ON TABLE storage.buckets_analytics TO anon;


--
-- Name: TABLE buckets_vectors; Type: ACL; Schema: storage; Owner: supabase_storage_admin
--

GRANT SELECT ON TABLE storage.buckets_vectors TO service_role;
GRANT SELECT ON TABLE storage.buckets_vectors TO authenticated;
GRANT SELECT ON TABLE storage.buckets_vectors TO anon;


--
-- Name: TABLE iceberg_namespaces; Type: ACL; Schema: storage; Owner: supabase_storage_admin
--

GRANT ALL ON TABLE storage.iceberg_namespaces TO service_role;
GRANT SELECT ON TABLE storage.iceberg_namespaces TO authenticated;
GRANT SELECT ON TABLE storage.iceberg_namespaces TO anon;


--
-- Name: TABLE iceberg_tables; Type: ACL; Schema: storage; Owner: supabase_storage_admin
--

GRANT ALL ON TABLE storage.iceberg_tables TO service_role;
GRANT SELECT ON TABLE storage.iceberg_tables TO authenticated;
GRANT SELECT ON TABLE storage.iceberg_tables TO anon;


--
-- Name: TABLE objects; Type: ACL; Schema: storage; Owner: supabase_storage_admin
--

GRANT ALL ON TABLE storage.objects TO postgres WITH GRANT OPTION;
GRANT ALL ON TABLE storage.objects TO service_role;
GRANT ALL ON TABLE storage.objects TO authenticated;
GRANT ALL ON TABLE storage.objects TO anon;


--
-- Name: TABLE s3_multipart_uploads; Type: ACL; Schema: storage; Owner: supabase_storage_admin
--

GRANT ALL ON TABLE storage.s3_multipart_uploads TO service_role;
GRANT SELECT ON TABLE storage.s3_multipart_uploads TO authenticated;
GRANT SELECT ON TABLE storage.s3_multipart_uploads TO anon;


--
-- Name: TABLE s3_multipart_uploads_parts; Type: ACL; Schema: storage; Owner: supabase_storage_admin
--

GRANT ALL ON TABLE storage.s3_multipart_uploads_parts TO service_role;
GRANT SELECT ON TABLE storage.s3_multipart_uploads_parts TO authenticated;
GRANT SELECT ON TABLE storage.s3_multipart_uploads_parts TO anon;


--
-- Name: TABLE vector_indexes; Type: ACL; Schema: storage; Owner: supabase_storage_admin
--

GRANT SELECT ON TABLE storage.vector_indexes TO service_role;
GRANT SELECT ON TABLE storage.vector_indexes TO authenticated;
GRANT SELECT ON TABLE storage.vector_indexes TO anon;


--
-- Name: TABLE hooks; Type: ACL; Schema: supabase_functions; Owner: supabase_functions_admin
--

GRANT ALL ON TABLE supabase_functions.hooks TO postgres;
GRANT ALL ON TABLE supabase_functions.hooks TO anon;
GRANT ALL ON TABLE supabase_functions.hooks TO authenticated;
GRANT ALL ON TABLE supabase_functions.hooks TO service_role;


--
-- Name: SEQUENCE hooks_id_seq; Type: ACL; Schema: supabase_functions; Owner: supabase_functions_admin
--

GRANT ALL ON SEQUENCE supabase_functions.hooks_id_seq TO postgres;
GRANT ALL ON SEQUENCE supabase_functions.hooks_id_seq TO anon;
GRANT ALL ON SEQUENCE supabase_functions.hooks_id_seq TO authenticated;
GRANT ALL ON SEQUENCE supabase_functions.hooks_id_seq TO service_role;


--
-- Name: TABLE migrations; Type: ACL; Schema: supabase_functions; Owner: supabase_functions_admin
--

GRANT ALL ON TABLE supabase_functions.migrations TO postgres;
GRANT ALL ON TABLE supabase_functions.migrations TO anon;
GRANT ALL ON TABLE supabase_functions.migrations TO authenticated;
GRANT ALL ON TABLE supabase_functions.migrations TO service_role;


--
-- Name: TABLE secrets; Type: ACL; Schema: vault; Owner: supabase_admin
--

GRANT SELECT,REFERENCES,DELETE,TRUNCATE ON TABLE vault.secrets TO postgres WITH GRANT OPTION;
GRANT SELECT,DELETE ON TABLE vault.secrets TO service_role;


--
-- Name: TABLE decrypted_secrets; Type: ACL; Schema: vault; Owner: supabase_admin
--

GRANT SELECT,REFERENCES,DELETE,TRUNCATE ON TABLE vault.decrypted_secrets TO postgres WITH GRANT OPTION;
GRANT SELECT,DELETE ON TABLE vault.decrypted_secrets TO service_role;


--
-- Name: DEFAULT PRIVILEGES FOR SEQUENCES; Type: DEFAULT ACL; Schema: auth; Owner: supabase_auth_admin
--

ALTER DEFAULT PRIVILEGES FOR ROLE supabase_auth_admin IN SCHEMA auth GRANT ALL ON SEQUENCES TO postgres;
ALTER DEFAULT PRIVILEGES FOR ROLE supabase_auth_admin IN SCHEMA auth GRANT ALL ON SEQUENCES TO dashboard_user;


--
-- Name: DEFAULT PRIVILEGES FOR FUNCTIONS; Type: DEFAULT ACL; Schema: auth; Owner: supabase_auth_admin
--

ALTER DEFAULT PRIVILEGES FOR ROLE supabase_auth_admin IN SCHEMA auth GRANT ALL ON FUNCTIONS TO postgres;
ALTER DEFAULT PRIVILEGES FOR ROLE supabase_auth_admin IN SCHEMA auth GRANT ALL ON FUNCTIONS TO dashboard_user;


--
-- Name: DEFAULT PRIVILEGES FOR TABLES; Type: DEFAULT ACL; Schema: auth; Owner: supabase_auth_admin
--

ALTER DEFAULT PRIVILEGES FOR ROLE supabase_auth_admin IN SCHEMA auth GRANT ALL ON TABLES TO postgres;
ALTER DEFAULT PRIVILEGES FOR ROLE supabase_auth_admin IN SCHEMA auth GRANT ALL ON TABLES TO dashboard_user;


--
-- Name: DEFAULT PRIVILEGES FOR SEQUENCES; Type: DEFAULT ACL; Schema: extensions; Owner: supabase_admin
--

ALTER DEFAULT PRIVILEGES FOR ROLE supabase_admin IN SCHEMA extensions GRANT ALL ON SEQUENCES TO postgres WITH GRANT OPTION;


--
-- Name: DEFAULT PRIVILEGES FOR FUNCTIONS; Type: DEFAULT ACL; Schema: extensions; Owner: supabase_admin
--

ALTER DEFAULT PRIVILEGES FOR ROLE supabase_admin IN SCHEMA extensions GRANT ALL ON FUNCTIONS TO postgres WITH GRANT OPTION;


--
-- Name: DEFAULT PRIVILEGES FOR TABLES; Type: DEFAULT ACL; Schema: extensions; Owner: supabase_admin
--

ALTER DEFAULT PRIVILEGES FOR ROLE supabase_admin IN SCHEMA extensions GRANT ALL ON TABLES TO postgres WITH GRANT OPTION;


--
-- Name: DEFAULT PRIVILEGES FOR SEQUENCES; Type: DEFAULT ACL; Schema: graphql; Owner: supabase_admin
--

ALTER DEFAULT PRIVILEGES FOR ROLE supabase_admin IN SCHEMA graphql GRANT ALL ON SEQUENCES TO postgres;
ALTER DEFAULT PRIVILEGES FOR ROLE supabase_admin IN SCHEMA graphql GRANT ALL ON SEQUENCES TO anon;
ALTER DEFAULT PRIVILEGES FOR ROLE supabase_admin IN SCHEMA graphql GRANT ALL ON SEQUENCES TO authenticated;
ALTER DEFAULT PRIVILEGES FOR ROLE supabase_admin IN SCHEMA graphql GRANT ALL ON SEQUENCES TO service_role;


--
-- Name: DEFAULT PRIVILEGES FOR FUNCTIONS; Type: DEFAULT ACL; Schema: graphql; Owner: supabase_admin
--

ALTER DEFAULT PRIVILEGES FOR ROLE supabase_admin IN SCHEMA graphql GRANT ALL ON FUNCTIONS TO postgres;
ALTER DEFAULT PRIVILEGES FOR ROLE supabase_admin IN SCHEMA graphql GRANT ALL ON FUNCTIONS TO anon;
ALTER DEFAULT PRIVILEGES FOR ROLE supabase_admin IN SCHEMA graphql GRANT ALL ON FUNCTIONS TO authenticated;
ALTER DEFAULT PRIVILEGES FOR ROLE supabase_admin IN SCHEMA graphql GRANT ALL ON FUNCTIONS TO service_role;


--
-- Name: DEFAULT PRIVILEGES FOR TABLES; Type: DEFAULT ACL; Schema: graphql; Owner: supabase_admin
--

ALTER DEFAULT PRIVILEGES FOR ROLE supabase_admin IN SCHEMA graphql GRANT ALL ON TABLES TO postgres;
ALTER DEFAULT PRIVILEGES FOR ROLE supabase_admin IN SCHEMA graphql GRANT ALL ON TABLES TO anon;
ALTER DEFAULT PRIVILEGES FOR ROLE supabase_admin IN SCHEMA graphql GRANT ALL ON TABLES TO authenticated;
ALTER DEFAULT PRIVILEGES FOR ROLE supabase_admin IN SCHEMA graphql GRANT ALL ON TABLES TO service_role;


--
-- Name: DEFAULT PRIVILEGES FOR SEQUENCES; Type: DEFAULT ACL; Schema: graphql_public; Owner: supabase_admin
--

ALTER DEFAULT PRIVILEGES FOR ROLE supabase_admin IN SCHEMA graphql_public GRANT ALL ON SEQUENCES TO postgres;
ALTER DEFAULT PRIVILEGES FOR ROLE supabase_admin IN SCHEMA graphql_public GRANT ALL ON SEQUENCES TO anon;
ALTER DEFAULT PRIVILEGES FOR ROLE supabase_admin IN SCHEMA graphql_public GRANT ALL ON SEQUENCES TO authenticated;
ALTER DEFAULT PRIVILEGES FOR ROLE supabase_admin IN SCHEMA graphql_public GRANT ALL ON SEQUENCES TO service_role;


--
-- Name: DEFAULT PRIVILEGES FOR FUNCTIONS; Type: DEFAULT ACL; Schema: graphql_public; Owner: supabase_admin
--

ALTER DEFAULT PRIVILEGES FOR ROLE supabase_admin IN SCHEMA graphql_public GRANT ALL ON FUNCTIONS TO postgres;
ALTER DEFAULT PRIVILEGES FOR ROLE supabase_admin IN SCHEMA graphql_public GRANT ALL ON FUNCTIONS TO anon;
ALTER DEFAULT PRIVILEGES FOR ROLE supabase_admin IN SCHEMA graphql_public GRANT ALL ON FUNCTIONS TO authenticated;
ALTER DEFAULT PRIVILEGES FOR ROLE supabase_admin IN SCHEMA graphql_public GRANT ALL ON FUNCTIONS TO service_role;


--
-- Name: DEFAULT PRIVILEGES FOR TABLES; Type: DEFAULT ACL; Schema: graphql_public; Owner: supabase_admin
--

ALTER DEFAULT PRIVILEGES FOR ROLE supabase_admin IN SCHEMA graphql_public GRANT ALL ON TABLES TO postgres;
ALTER DEFAULT PRIVILEGES FOR ROLE supabase_admin IN SCHEMA graphql_public GRANT ALL ON TABLES TO anon;
ALTER DEFAULT PRIVILEGES FOR ROLE supabase_admin IN SCHEMA graphql_public GRANT ALL ON TABLES TO authenticated;
ALTER DEFAULT PRIVILEGES FOR ROLE supabase_admin IN SCHEMA graphql_public GRANT ALL ON TABLES TO service_role;


--
-- Name: DEFAULT PRIVILEGES FOR SEQUENCES; Type: DEFAULT ACL; Schema: public; Owner: postgres
--

ALTER DEFAULT PRIVILEGES FOR ROLE postgres IN SCHEMA public GRANT ALL ON SEQUENCES TO postgres;
ALTER DEFAULT PRIVILEGES FOR ROLE postgres IN SCHEMA public GRANT ALL ON SEQUENCES TO anon;
ALTER DEFAULT PRIVILEGES FOR ROLE postgres IN SCHEMA public GRANT ALL ON SEQUENCES TO authenticated;
ALTER DEFAULT PRIVILEGES FOR ROLE postgres IN SCHEMA public GRANT ALL ON SEQUENCES TO service_role;


--
-- Name: DEFAULT PRIVILEGES FOR SEQUENCES; Type: DEFAULT ACL; Schema: public; Owner: supabase_admin
--

ALTER DEFAULT PRIVILEGES FOR ROLE supabase_admin IN SCHEMA public GRANT ALL ON SEQUENCES TO postgres;
ALTER DEFAULT PRIVILEGES FOR ROLE supabase_admin IN SCHEMA public GRANT ALL ON SEQUENCES TO anon;
ALTER DEFAULT PRIVILEGES FOR ROLE supabase_admin IN SCHEMA public GRANT ALL ON SEQUENCES TO authenticated;
ALTER DEFAULT PRIVILEGES FOR ROLE supabase_admin IN SCHEMA public GRANT ALL ON SEQUENCES TO service_role;


--
-- Name: DEFAULT PRIVILEGES FOR FUNCTIONS; Type: DEFAULT ACL; Schema: public; Owner: postgres
--

ALTER DEFAULT PRIVILEGES FOR ROLE postgres IN SCHEMA public GRANT ALL ON FUNCTIONS TO postgres;
ALTER DEFAULT PRIVILEGES FOR ROLE postgres IN SCHEMA public GRANT ALL ON FUNCTIONS TO anon;
ALTER DEFAULT PRIVILEGES FOR ROLE postgres IN SCHEMA public GRANT ALL ON FUNCTIONS TO authenticated;
ALTER DEFAULT PRIVILEGES FOR ROLE postgres IN SCHEMA public GRANT ALL ON FUNCTIONS TO service_role;


--
-- Name: DEFAULT PRIVILEGES FOR FUNCTIONS; Type: DEFAULT ACL; Schema: public; Owner: supabase_admin
--

ALTER DEFAULT PRIVILEGES FOR ROLE supabase_admin IN SCHEMA public GRANT ALL ON FUNCTIONS TO postgres;
ALTER DEFAULT PRIVILEGES FOR ROLE supabase_admin IN SCHEMA public GRANT ALL ON FUNCTIONS TO anon;
ALTER DEFAULT PRIVILEGES FOR ROLE supabase_admin IN SCHEMA public GRANT ALL ON FUNCTIONS TO authenticated;
ALTER DEFAULT PRIVILEGES FOR ROLE supabase_admin IN SCHEMA public GRANT ALL ON FUNCTIONS TO service_role;


--
-- Name: DEFAULT PRIVILEGES FOR TABLES; Type: DEFAULT ACL; Schema: public; Owner: postgres
--

ALTER DEFAULT PRIVILEGES FOR ROLE postgres IN SCHEMA public GRANT ALL ON TABLES TO postgres;
ALTER DEFAULT PRIVILEGES FOR ROLE postgres IN SCHEMA public GRANT ALL ON TABLES TO anon;
ALTER DEFAULT PRIVILEGES FOR ROLE postgres IN SCHEMA public GRANT ALL ON TABLES TO authenticated;
ALTER DEFAULT PRIVILEGES FOR ROLE postgres IN SCHEMA public GRANT ALL ON TABLES TO service_role;


--
-- Name: DEFAULT PRIVILEGES FOR TABLES; Type: DEFAULT ACL; Schema: public; Owner: supabase_admin
--

ALTER DEFAULT PRIVILEGES FOR ROLE supabase_admin IN SCHEMA public GRANT ALL ON TABLES TO postgres;
ALTER DEFAULT PRIVILEGES FOR ROLE supabase_admin IN SCHEMA public GRANT ALL ON TABLES TO anon;
ALTER DEFAULT PRIVILEGES FOR ROLE supabase_admin IN SCHEMA public GRANT ALL ON TABLES TO authenticated;
ALTER DEFAULT PRIVILEGES FOR ROLE supabase_admin IN SCHEMA public GRANT ALL ON TABLES TO service_role;


--
-- Name: DEFAULT PRIVILEGES FOR SEQUENCES; Type: DEFAULT ACL; Schema: realtime; Owner: supabase_admin
--

ALTER DEFAULT PRIVILEGES FOR ROLE supabase_admin IN SCHEMA realtime GRANT ALL ON SEQUENCES TO postgres;
ALTER DEFAULT PRIVILEGES FOR ROLE supabase_admin IN SCHEMA realtime GRANT ALL ON SEQUENCES TO dashboard_user;


--
-- Name: DEFAULT PRIVILEGES FOR FUNCTIONS; Type: DEFAULT ACL; Schema: realtime; Owner: supabase_admin
--

ALTER DEFAULT PRIVILEGES FOR ROLE supabase_admin IN SCHEMA realtime GRANT ALL ON FUNCTIONS TO postgres;
ALTER DEFAULT PRIVILEGES FOR ROLE supabase_admin IN SCHEMA realtime GRANT ALL ON FUNCTIONS TO dashboard_user;


--
-- Name: DEFAULT PRIVILEGES FOR TABLES; Type: DEFAULT ACL; Schema: realtime; Owner: supabase_admin
--

ALTER DEFAULT PRIVILEGES FOR ROLE supabase_admin IN SCHEMA realtime GRANT ALL ON TABLES TO postgres;
ALTER DEFAULT PRIVILEGES FOR ROLE supabase_admin IN SCHEMA realtime GRANT ALL ON TABLES TO dashboard_user;


--
-- Name: DEFAULT PRIVILEGES FOR SEQUENCES; Type: DEFAULT ACL; Schema: storage; Owner: postgres
--

ALTER DEFAULT PRIVILEGES FOR ROLE postgres IN SCHEMA storage GRANT ALL ON SEQUENCES TO postgres;
ALTER DEFAULT PRIVILEGES FOR ROLE postgres IN SCHEMA storage GRANT ALL ON SEQUENCES TO anon;
ALTER DEFAULT PRIVILEGES FOR ROLE postgres IN SCHEMA storage GRANT ALL ON SEQUENCES TO authenticated;
ALTER DEFAULT PRIVILEGES FOR ROLE postgres IN SCHEMA storage GRANT ALL ON SEQUENCES TO service_role;


--
-- Name: DEFAULT PRIVILEGES FOR FUNCTIONS; Type: DEFAULT ACL; Schema: storage; Owner: postgres
--

ALTER DEFAULT PRIVILEGES FOR ROLE postgres IN SCHEMA storage GRANT ALL ON FUNCTIONS TO postgres;
ALTER DEFAULT PRIVILEGES FOR ROLE postgres IN SCHEMA storage GRANT ALL ON FUNCTIONS TO anon;
ALTER DEFAULT PRIVILEGES FOR ROLE postgres IN SCHEMA storage GRANT ALL ON FUNCTIONS TO authenticated;
ALTER DEFAULT PRIVILEGES FOR ROLE postgres IN SCHEMA storage GRANT ALL ON FUNCTIONS TO service_role;


--
-- Name: DEFAULT PRIVILEGES FOR TABLES; Type: DEFAULT ACL; Schema: storage; Owner: postgres
--

ALTER DEFAULT PRIVILEGES FOR ROLE postgres IN SCHEMA storage GRANT ALL ON TABLES TO postgres;
ALTER DEFAULT PRIVILEGES FOR ROLE postgres IN SCHEMA storage GRANT ALL ON TABLES TO anon;
ALTER DEFAULT PRIVILEGES FOR ROLE postgres IN SCHEMA storage GRANT ALL ON TABLES TO authenticated;
ALTER DEFAULT PRIVILEGES FOR ROLE postgres IN SCHEMA storage GRANT ALL ON TABLES TO service_role;


--
-- Name: DEFAULT PRIVILEGES FOR SEQUENCES; Type: DEFAULT ACL; Schema: supabase_functions; Owner: supabase_admin
--

ALTER DEFAULT PRIVILEGES FOR ROLE supabase_admin IN SCHEMA supabase_functions GRANT ALL ON SEQUENCES TO postgres;
ALTER DEFAULT PRIVILEGES FOR ROLE supabase_admin IN SCHEMA supabase_functions GRANT ALL ON SEQUENCES TO anon;
ALTER DEFAULT PRIVILEGES FOR ROLE supabase_admin IN SCHEMA supabase_functions GRANT ALL ON SEQUENCES TO authenticated;
ALTER DEFAULT PRIVILEGES FOR ROLE supabase_admin IN SCHEMA supabase_functions GRANT ALL ON SEQUENCES TO service_role;


--
-- Name: DEFAULT PRIVILEGES FOR FUNCTIONS; Type: DEFAULT ACL; Schema: supabase_functions; Owner: supabase_admin
--

ALTER DEFAULT PRIVILEGES FOR ROLE supabase_admin IN SCHEMA supabase_functions GRANT ALL ON FUNCTIONS TO postgres;
ALTER DEFAULT PRIVILEGES FOR ROLE supabase_admin IN SCHEMA supabase_functions GRANT ALL ON FUNCTIONS TO anon;
ALTER DEFAULT PRIVILEGES FOR ROLE supabase_admin IN SCHEMA supabase_functions GRANT ALL ON FUNCTIONS TO authenticated;
ALTER DEFAULT PRIVILEGES FOR ROLE supabase_admin IN SCHEMA supabase_functions GRANT ALL ON FUNCTIONS TO service_role;


--
-- Name: DEFAULT PRIVILEGES FOR TABLES; Type: DEFAULT ACL; Schema: supabase_functions; Owner: supabase_admin
--

ALTER DEFAULT PRIVILEGES FOR ROLE supabase_admin IN SCHEMA supabase_functions GRANT ALL ON TABLES TO postgres;
ALTER DEFAULT PRIVILEGES FOR ROLE supabase_admin IN SCHEMA supabase_functions GRANT ALL ON TABLES TO anon;
ALTER DEFAULT PRIVILEGES FOR ROLE supabase_admin IN SCHEMA supabase_functions GRANT ALL ON TABLES TO authenticated;
ALTER DEFAULT PRIVILEGES FOR ROLE supabase_admin IN SCHEMA supabase_functions GRANT ALL ON TABLES TO service_role;


--
-- Name: issue_graphql_placeholder; Type: EVENT TRIGGER; Schema: -; Owner: supabase_admin
--

CREATE EVENT TRIGGER issue_graphql_placeholder ON sql_drop
         WHEN TAG IN ('DROP EXTENSION')
   EXECUTE FUNCTION extensions.set_graphql_placeholder();


ALTER EVENT TRIGGER issue_graphql_placeholder OWNER TO supabase_admin;

--
-- Name: issue_pg_cron_access; Type: EVENT TRIGGER; Schema: -; Owner: supabase_admin
--

CREATE EVENT TRIGGER issue_pg_cron_access ON ddl_command_end
         WHEN TAG IN ('CREATE EXTENSION')
   EXECUTE FUNCTION extensions.grant_pg_cron_access();


ALTER EVENT TRIGGER issue_pg_cron_access OWNER TO supabase_admin;

--
-- Name: issue_pg_graphql_access; Type: EVENT TRIGGER; Schema: -; Owner: supabase_admin
--

CREATE EVENT TRIGGER issue_pg_graphql_access ON ddl_command_end
         WHEN TAG IN ('CREATE EXTENSION')
   EXECUTE FUNCTION extensions.grant_pg_graphql_access();


ALTER EVENT TRIGGER issue_pg_graphql_access OWNER TO supabase_admin;

--
-- Name: issue_pg_net_access; Type: EVENT TRIGGER; Schema: -; Owner: supabase_admin
--

CREATE EVENT TRIGGER issue_pg_net_access ON ddl_command_end
         WHEN TAG IN ('CREATE EXTENSION')
   EXECUTE FUNCTION extensions.grant_pg_net_access();


ALTER EVENT TRIGGER issue_pg_net_access OWNER TO supabase_admin;

--
-- Name: pgrst_ddl_watch; Type: EVENT TRIGGER; Schema: -; Owner: supabase_admin
--

CREATE EVENT TRIGGER pgrst_ddl_watch ON ddl_command_end
   EXECUTE FUNCTION extensions.pgrst_ddl_watch();


ALTER EVENT TRIGGER pgrst_ddl_watch OWNER TO supabase_admin;

--
-- Name: pgrst_drop_watch; Type: EVENT TRIGGER; Schema: -; Owner: supabase_admin
--

CREATE EVENT TRIGGER pgrst_drop_watch ON sql_drop
   EXECUTE FUNCTION extensions.pgrst_drop_watch();


ALTER EVENT TRIGGER pgrst_drop_watch OWNER TO supabase_admin;

--
-- PostgreSQL database dump complete
--

\unrestrict LV0qnjUH3SWL0aBPGm6cy1ZkmlSzDJdVUfB9wNeKmjDM3b1Te6x9rqoVJJo161S

