--- ===================================================================== -- GoberData · ESQUEMA COMPLETO (instalación desde cero) -- PostgreSQL 15 o superior · 139 tablas -- -- QUÉ ES ESTO -- El esquema completo y definitivo de GoberData: las 85 tablas que ya -- tenías en producción más las 54 que faltaban, con las columnas, índices -- y llaves foráneas corregidos. -- -- Se generó aplicando los scripts 01, 02 y 03 sobre una restauración -- limpia del volcado de producción y volcando el resultado. Es decir: no -- es teórico, es el esquema que quedó y contra el que se probó la -- aplicación completa (aprovisionamiento de demo, siembra de datos, -- aislamiento entre campañas, checkout, webhook y estadísticas). -- -- CUÁNDO USAR ESTE Y CUÁNDO LOS OTROS -- · Base NUEVA (servidor nuevo, entorno de pruebas, otro cliente): -- usa ESTE archivo. Crea todo de una vez. -- · Base EXISTENTE con datos (tu producción actual): -- NO uses este. Usa 01 → 02 → 03 en ese orden: son incrementales e -- idempotentes, y no tocan tus datos. -- -- CÓMO EJECUTARLO -- createdb -U postgres goberdata -- psql -U postgres -d goberdata -v ON_ERROR_STOP=1 -f 00-goberdata-esquema-completo.sql -- -- DESPUÉS, los datos base (roles, permisos, planes, geografía): -- php artisan db:seed --class=RolesAndPermissionsSeeder -- php artisan db:seed --class=MembershipPlansSeeder -- php artisan db:seed --class=ColombiaCompleteSeeder -- -- NOTA SOBRE LAS MIGRACIONES DE LARAVEL -- Si creas la base con este archivo, marca las migraciones como -- ejecutadas para que `php artisan migrate` no intente rehacerlas: -- php artisan migrate --pretend (revisa qué haría) -- o inserta las filas correspondientes en la tabla `migrations`. -- ===================================================================== -- -- \restrict 7jUpbJGgFswlKKELvwlcvpIAcF8fcDCqV0isz3asaQQTePEc1Ri6RSj8BZM35gL SET statement_timeout = 0; SET lock_timeout = 0; SET idle_in_transaction_session_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; SET default_tablespace = ''; SET default_table_access_method = heap; -- -- Name: active_sessions; Type: TABLE; Schema: public; Owner: - -- CREATE TABLE public.active_sessions ( id bigint NOT NULL, user_id bigint NOT NULL, campaign_id bigint, session_id character varying(255) NOT NULL, ip_address inet NOT NULL, user_agent character varying(255) NOT NULL, device_type character varying(255), browser character varying(255), os character varying(255), last_activity timestamp(0) without time zone NOT NULL, logged_in_at timestamp(0) without time zone NOT NULL, created_at timestamp(0) without time zone, updated_at timestamp(0) without time zone ); -- -- Name: active_sessions_id_seq; Type: SEQUENCE; Schema: public; Owner: - -- CREATE SEQUENCE public.active_sessions_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; -- -- Name: active_sessions_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - -- ALTER SEQUENCE public.active_sessions_id_seq OWNED BY public.active_sessions.id; -- -- Name: ai_contents; Type: TABLE; Schema: public; Owner: - -- CREATE TABLE public.ai_contents ( id bigint NOT NULL, campaign_id bigint NOT NULL, user_id bigint NOT NULL, title character varying(255) NOT NULL, content_type character varying(255) NOT NULL, content_text text NOT NULL, content_html text, prompt_used text NOT NULL, ai_model character varying(255) DEFAULT 'gpt-3.5-turbo'::character varying NOT NULL, generation_time_seconds integer, tokens_used integer, quality_score numeric(3,2), sentiment_score numeric(3,2), keywords json, metadata json, status character varying(255) DEFAULT 'draft'::character varying NOT NULL, created_at timestamp(0) without time zone, updated_at timestamp(0) without time zone, deleted_at timestamp(0) without time zone, CONSTRAINT ai_contents_content_type_check CHECK (((content_type)::text = ANY (ARRAY[('post'::character varying)::text, ('email'::character varying)::text, ('speech'::character varying)::text, ('proposal'::character varying)::text, ('press_release'::character varying)::text, ('social_media'::character varying)::text, ('campaign_material'::character varying)::text]))), CONSTRAINT ai_contents_status_check CHECK (((status)::text = ANY (ARRAY[('draft'::character varying)::text, ('review'::character varying)::text, ('approved'::character varying)::text, ('published'::character varying)::text, ('rejected'::character varying)::text]))) ); -- -- Name: ai_contents_id_seq; Type: SEQUENCE; Schema: public; Owner: - -- CREATE SEQUENCE public.ai_contents_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; -- -- Name: ai_contents_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - -- ALTER SEQUENCE public.ai_contents_id_seq OWNED BY public.ai_contents.id; -- -- Name: ai_providers; Type: TABLE; Schema: public; Owner: - -- CREATE TABLE public.ai_providers ( id bigint NOT NULL, campaign_id bigint NOT NULL, provider character varying(255) NOT NULL, api_key text, model character varying(255), base_url character varying(255), settings json, is_active boolean DEFAULT true NOT NULL, created_at timestamp(0) without time zone, updated_at timestamp(0) without time zone, key_hint character varying(12), last_verified_at timestamp(0) without time zone, verification_status character varying(20) DEFAULT 'sin_probar'::character varying NOT NULL, verification_error text, CONSTRAINT ai_providers_provider_check CHECK (((provider)::text = ANY (ARRAY[('openai'::character varying)::text, ('gemini'::character varying)::text, ('ollama'::character varying)::text, ('anthropic'::character varying)::text, ('custom'::character varying)::text]))) ); -- -- Name: ai_providers_id_seq; Type: SEQUENCE; Schema: public; Owner: - -- CREATE SEQUENCE public.ai_providers_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; -- -- Name: ai_providers_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - -- ALTER SEQUENCE public.ai_providers_id_seq OWNED BY public.ai_providers.id; -- -- Name: alert_triggers; Type: TABLE; Schema: public; Owner: - -- CREATE TABLE public.alert_triggers ( id bigint NOT NULL, campaign_id bigint NOT NULL, alert_id bigint NOT NULL, triggered_at timestamp(0) without time zone, context json, is_resolved boolean DEFAULT false NOT NULL, resolved_at timestamp(0) without time zone, resolved_by bigint, created_at timestamp(0) without time zone, updated_at timestamp(0) without time zone ); -- -- Name: alert_triggers_id_seq; Type: SEQUENCE; Schema: public; Owner: - -- CREATE SEQUENCE public.alert_triggers_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; -- -- Name: alert_triggers_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - -- ALTER SEQUENCE public.alert_triggers_id_seq OWNED BY public.alert_triggers.id; -- -- Name: alerts; Type: TABLE; Schema: public; Owner: - -- CREATE TABLE public.alerts ( id bigint NOT NULL, campaign_id bigint NOT NULL, kpi_id bigint, name character varying(160) NOT NULL, description text, type character varying(40), conditions json, severity character varying(20) DEFAULT 'media'::character varying NOT NULL, notification_channels json, recipients json, is_active boolean DEFAULT true NOT NULL, last_triggered_at timestamp(0) without time zone, created_at timestamp(0) without time zone, updated_at timestamp(0) without time zone ); -- -- Name: alerts_id_seq; Type: SEQUENCE; Schema: public; Owner: - -- CREATE SEQUENCE public.alerts_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; -- -- Name: alerts_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - -- ALTER SEQUENCE public.alerts_id_seq OWNED BY public.alerts.id; -- -- Name: audit_logs; Type: TABLE; Schema: public; Owner: - -- CREATE TABLE public.audit_logs ( id bigint NOT NULL, user_id bigint, campaign_id bigint, action character varying(255) NOT NULL, model_type character varying(255), model_id bigint, description character varying(255) NOT NULL, old_values json, new_values json, metadata json, ip_address inet, user_agent character varying(255), url character varying(255), method character varying(255), severity character varying(255) DEFAULT 'low'::character varying NOT NULL, category character varying(255) DEFAULT 'other'::character varying NOT NULL, is_suspicious boolean DEFAULT false NOT NULL, requires_review boolean DEFAULT false NOT NULL, reviewed_at timestamp(0) without time zone, reviewed_by bigint, created_at timestamp(0) without time zone, updated_at timestamp(0) without time zone, CONSTRAINT audit_logs_category_check CHECK (((category)::text = ANY (ARRAY[('auth'::character varying)::text, ('user_management'::character varying)::text, ('campaign_management'::character varying)::text, ('data_export'::character varying)::text, ('configuration'::character varying)::text, ('content_creation'::character varying)::text, ('payment'::character varying)::text, ('other'::character varying)::text]))), CONSTRAINT audit_logs_severity_check CHECK (((severity)::text = ANY (ARRAY[('low'::character varying)::text, ('medium'::character varying)::text, ('high'::character varying)::text, ('critical'::character varying)::text]))) ); -- -- Name: audit_logs_id_seq; Type: SEQUENCE; Schema: public; Owner: - -- CREATE SEQUENCE public.audit_logs_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; -- -- Name: audit_logs_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - -- ALTER SEQUENCE public.audit_logs_id_seq OWNED BY public.audit_logs.id; -- -- Name: budget_categories; Type: TABLE; Schema: public; Owner: - -- CREATE TABLE public.budget_categories ( id bigint NOT NULL, campaign_id bigint NOT NULL, name character varying(120) NOT NULL, color character varying(20) DEFAULT '#1E7A5F'::character varying NOT NULL, is_active boolean DEFAULT true NOT NULL, created_at timestamp(0) without time zone, updated_at timestamp(0) without time zone ); -- -- Name: budget_categories_id_seq; Type: SEQUENCE; Schema: public; Owner: - -- CREATE SEQUENCE public.budget_categories_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; -- -- Name: budget_categories_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - -- ALTER SEQUENCE public.budget_categories_id_seq OWNED BY public.budget_categories.id; -- -- Name: cache; Type: TABLE; Schema: public; Owner: - -- CREATE TABLE public.cache ( key character varying(255) NOT NULL, value text NOT NULL, expiration integer NOT NULL ); -- -- Name: cache_locks; Type: TABLE; Schema: public; Owner: - -- CREATE TABLE public.cache_locks ( key character varying(255) NOT NULL, owner character varying(255) NOT NULL, expiration integer NOT NULL ); -- -- Name: call_center_calls; Type: TABLE; Schema: public; Owner: - -- CREATE TABLE public.call_center_calls ( id bigint NOT NULL, campaign_id bigint NOT NULL, caller_id bigint NOT NULL, script_id bigint NOT NULL, phone_number character varying(255) NOT NULL, call_type character varying(255) NOT NULL, status character varying(255) NOT NULL, duration integer DEFAULT 0 NOT NULL, call_date timestamp(0) without time zone NOT NULL, notes text, outcome character varying(255), follow_up_required boolean DEFAULT false NOT NULL, follow_up_date timestamp(0) without time zone, priority character varying(255) DEFAULT 'medium'::character varying NOT NULL, tags json, metadata json, created_at timestamp(0) without time zone, updated_at timestamp(0) without time zone, deleted_at timestamp(0) without time zone, voter_id bigint, CONSTRAINT call_center_calls_call_type_check CHECK (((call_type)::text = ANY (ARRAY[('inbound'::character varying)::text, ('outbound'::character varying)::text]))), CONSTRAINT call_center_calls_priority_check CHECK (((priority)::text = ANY (ARRAY[('low'::character varying)::text, ('medium'::character varying)::text, ('high'::character varying)::text, ('urgent'::character varying)::text]))), CONSTRAINT call_center_calls_status_check CHECK (((status)::text = ANY (ARRAY[('scheduled'::character varying)::text, ('in_progress'::character varying)::text, ('completed'::character varying)::text, ('failed'::character varying)::text, ('no_answer'::character varying)::text, ('busy'::character varying)::text]))) ); -- -- Name: call_center_calls_id_seq; Type: SEQUENCE; Schema: public; Owner: - -- CREATE SEQUENCE public.call_center_calls_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; -- -- Name: call_center_calls_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - -- ALTER SEQUENCE public.call_center_calls_id_seq OWNED BY public.call_center_calls.id; -- -- Name: call_center_scripts; Type: TABLE; Schema: public; Owner: - -- CREATE TABLE public.call_center_scripts ( id bigint NOT NULL, campaign_id bigint NOT NULL, name character varying(255) NOT NULL, description text, script_content text NOT NULL, script_type character varying(255) DEFAULT 'general'::character varying NOT NULL, is_active boolean DEFAULT true NOT NULL, version character varying(255) DEFAULT '1.0'::character varying NOT NULL, tags json, metadata json, created_at timestamp(0) without time zone, updated_at timestamp(0) without time zone, deleted_at timestamp(0) without time zone ); -- -- Name: call_center_scripts_id_seq; Type: SEQUENCE; Schema: public; Owner: - -- CREATE SEQUENCE public.call_center_scripts_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; -- -- Name: call_center_scripts_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - -- ALTER SEQUENCE public.call_center_scripts_id_seq OWNED BY public.call_center_scripts.id; -- -- Name: call_scripts; Type: TABLE; Schema: public; Owner: - -- CREATE TABLE public.call_scripts ( id bigint NOT NULL, campaign_id bigint NOT NULL, name character varying(255) NOT NULL, content text NOT NULL, objectives json, is_active boolean DEFAULT true NOT NULL, created_at timestamp(0) without time zone, updated_at timestamp(0) without time zone, deleted_at timestamp(0) without time zone ); -- -- Name: call_scripts_id_seq; Type: SEQUENCE; Schema: public; Owner: - -- CREATE SEQUENCE public.call_scripts_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; -- -- Name: call_scripts_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - -- ALTER SEQUENCE public.call_scripts_id_seq OWNED BY public.call_scripts.id; -- -- Name: calls; Type: TABLE; Schema: public; Owner: - -- CREATE TABLE public.calls ( id bigint NOT NULL, campaign_id bigint NOT NULL, caller_id bigint, call_script_id bigint, phone_number character varying(255) NOT NULL, contact_name character varying(255), duration_seconds integer DEFAULT 0 NOT NULL, outcome character varying(255) NOT NULL, notes text, scheduled_callback timestamp(0) without time zone, metadata json, called_at timestamp(0) without time zone NOT NULL, created_at timestamp(0) without time zone, updated_at timestamp(0) without time zone ); -- -- Name: calls_id_seq; Type: SEQUENCE; Schema: public; Owner: - -- CREATE SEQUENCE public.calls_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; -- -- Name: calls_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - -- ALTER SEQUENCE public.calls_id_seq OWNED BY public.calls.id; -- -- Name: campaign_funds; Type: TABLE; Schema: public; Owner: - -- CREATE TABLE public.campaign_funds ( id bigint NOT NULL, campaign_id bigint NOT NULL, name character varying(255) NOT NULL, description text, target_amount numeric(15,2) NOT NULL, current_amount numeric(15,2) DEFAULT '0'::numeric NOT NULL, is_active boolean DEFAULT true NOT NULL, fund_type character varying(255) DEFAULT 'general'::character varying NOT NULL, priority character varying(255) DEFAULT 'medium'::character varying NOT NULL, deadline date, metadata json, created_at timestamp(0) without time zone, updated_at timestamp(0) without time zone, deleted_at timestamp(0) without time zone, CONSTRAINT campaign_funds_priority_check CHECK (((priority)::text = ANY (ARRAY[('low'::character varying)::text, ('medium'::character varying)::text, ('high'::character varying)::text, ('urgent'::character varying)::text]))) ); -- -- Name: campaign_funds_id_seq; Type: SEQUENCE; Schema: public; Owner: - -- CREATE SEQUENCE public.campaign_funds_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; -- -- Name: campaign_funds_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - -- ALTER SEQUENCE public.campaign_funds_id_seq OWNED BY public.campaign_funds.id; -- -- Name: campaign_invitations; Type: TABLE; Schema: public; Owner: - -- CREATE TABLE public.campaign_invitations ( id bigint NOT NULL, campaign_id bigint NOT NULL, email character varying(255) NOT NULL, token character varying(255) NOT NULL, role character varying(255) DEFAULT 'volunteer'::character varying NOT NULL, invited_by bigint NOT NULL, expires_at timestamp(0) without time zone NOT NULL, accepted_at timestamp(0) without time zone, created_at timestamp(0) without time zone, updated_at timestamp(0) without time zone, CONSTRAINT campaign_invitations_role_check CHECK (((role)::text = ANY (ARRAY[('campaign_admin'::character varying)::text, ('coordinator'::character varying)::text, ('volunteer'::character varying)::text]))) ); -- -- Name: campaign_invitations_id_seq; Type: SEQUENCE; Schema: public; Owner: - -- CREATE SEQUENCE public.campaign_invitations_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; -- -- Name: campaign_invitations_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - -- ALTER SEQUENCE public.campaign_invitations_id_seq OWNED BY public.campaign_invitations.id; -- -- Name: campaign_user; Type: TABLE; Schema: public; Owner: - -- CREATE TABLE public.campaign_user ( id bigint NOT NULL, campaign_id bigint NOT NULL, user_id bigint NOT NULL, role character varying(255) DEFAULT 'volunteer'::character varying NOT NULL, is_active boolean DEFAULT true NOT NULL, joined_at timestamp(0) without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, created_at timestamp(0) without time zone, updated_at timestamp(0) without time zone ); -- -- Name: campaign_user_id_seq; Type: SEQUENCE; Schema: public; Owner: - -- CREATE SEQUENCE public.campaign_user_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; -- -- Name: campaign_user_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - -- ALTER SEQUENCE public.campaign_user_id_seq OWNED BY public.campaign_user.id; -- -- Name: campaigns; Type: TABLE; Schema: public; Owner: - -- CREATE TABLE public.campaigns ( id bigint NOT NULL, name character varying(255) NOT NULL, slug character varying(255) NOT NULL, email character varying(255) NOT NULL, candidate_name character varying(255) NOT NULL, level character varying(255) NOT NULL, jurisdiction character varying(255) NOT NULL, status character varying(255) DEFAULT 'draft'::character varying NOT NULL, plan character varying(255) DEFAULT 'starter'::character varying NOT NULL, trial_ends_at timestamp(0) without time zone, subscription_ends_at timestamp(0) without time zone, registration_number character varying(255), election_date date, funding_limit numeric(15,2), data json, created_at timestamp(0) without time zone, updated_at timestamp(0) without time zone, deleted_at timestamp(0) without time zone, whatsapp_api_key text, whatsapp_phone_id character varying(255), whatsapp_business_id character varying(255), facebook_api_key text, facebook_page_id character varying(255), twitter_api_key text, twitter_api_secret text, instagram_api_key text, tiktok_api_key text, youtube_api_key text, smtp_host character varying(255), smtp_port character varying(255), smtp_username character varying(255), smtp_password text, smtp_from_email character varying(255), smtp_from_name character varying(255), logo_url character varying(255), primary_color character varying(255) DEFAULT '#3B82F6'::character varying NOT NULL, secondary_color character varying(255) DEFAULT '#10B981'::character varying NOT NULL, owner_id bigint, max_users integer DEFAULT 10 NOT NULL, max_whatsapp_monthly integer DEFAULT 1000 NOT NULL, max_email_monthly integer DEFAULT 5000 NOT NULL, ai_features_enabled boolean DEFAULT false NOT NULL, gotv_enabled boolean DEFAULT true NOT NULL, social_monitoring_enabled boolean DEFAULT false NOT NULL, country_id bigint, state_id bigint, city_id bigint, environment_type character varying(20) DEFAULT 'client'::character varying NOT NULL, demo_expires_at timestamp(0) without time zone, provisioned_at timestamp(0) without time zone, CONSTRAINT campaigns_level_check CHECK (((level)::text = ANY (ARRAY[('municipal'::character varying)::text, ('regional'::character varying)::text, ('national'::character varying)::text]))), CONSTRAINT campaigns_plan_check CHECK (((plan)::text = ANY (ARRAY[('starter'::character varying)::text, ('pro'::character varying)::text, ('enterprise'::character varying)::text]))), CONSTRAINT campaigns_status_check CHECK (((status)::text = ANY (ARRAY[('draft'::character varying)::text, ('active'::character varying)::text, ('suspended'::character varying)::text, ('closed'::character varying)::text]))) ); -- -- Name: campaigns_id_seq; Type: SEQUENCE; Schema: public; Owner: - -- CREATE SEQUENCE public.campaigns_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; -- -- Name: campaigns_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - -- ALTER SEQUENCE public.campaigns_id_seq OWNED BY public.campaigns.id; -- -- Name: cities; Type: TABLE; Schema: public; Owner: - -- CREATE TABLE public.cities ( id bigint NOT NULL, state_id bigint NOT NULL, name character varying(100) NOT NULL, code character varying(10), is_capital boolean DEFAULT false NOT NULL, population integer, is_active boolean DEFAULT true NOT NULL, created_at timestamp(0) without time zone, updated_at timestamp(0) without time zone, latitude numeric(10,8), longitude numeric(11,8) ); -- -- Name: cities_id_seq; Type: SEQUENCE; Schema: public; Owner: - -- CREATE SEQUENCE public.cities_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; -- -- Name: cities_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - -- ALTER SEQUENCE public.cities_id_seq OWNED BY public.cities.id; -- -- Name: citizen_priorities; Type: TABLE; Schema: public; Owner: - -- CREATE TABLE public.citizen_priorities ( id bigint NOT NULL, campaign_id bigint NOT NULL, territory_id bigint, issue character varying(160) NOT NULL, measured_date date, priority_score numeric(5,2), mentions_count integer DEFAULT 0 NOT NULL, trend character varying(20), our_performance numeric(5,2), competitor_best_performance numeric(5,2), competitor_best_id bigint, metadata json, created_at timestamp(0) without time zone, updated_at timestamp(0) without time zone ); -- -- Name: citizen_priorities_id_seq; Type: SEQUENCE; Schema: public; Owner: - -- CREATE SEQUENCE public.citizen_priorities_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; -- -- Name: citizen_priorities_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - -- ALTER SEQUENCE public.citizen_priorities_id_seq OWNED BY public.citizen_priorities.id; -- -- Name: competitor_ad_snapshots; Type: TABLE; Schema: public; Owner: - -- CREATE TABLE public.competitor_ad_snapshots ( id bigint NOT NULL, political_competitor_id bigint NOT NULL, campaign_id bigint NOT NULL, ads_count integer DEFAULT 0 NOT NULL, active_ads integer DEFAULT 0 NOT NULL, total_spend bigint DEFAULT '0'::bigint NOT NULL, total_impressions bigint DEFAULT '0'::bigint NOT NULL, spend_by_region json, ads_by_platform json, demographic_summary json, source character varying(255) DEFAULT 'meta_ad_library'::character varying NOT NULL, fetched_at timestamp(0) without time zone NOT NULL, created_at timestamp(0) without time zone, updated_at timestamp(0) without time zone ); -- -- Name: competitor_ad_snapshots_id_seq; Type: SEQUENCE; Schema: public; Owner: - -- CREATE SEQUENCE public.competitor_ad_snapshots_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; -- -- Name: competitor_ad_snapshots_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - -- ALTER SEQUENCE public.competitor_ad_snapshots_id_seq OWNED BY public.competitor_ad_snapshots.id; -- -- Name: competitor_comparisons; Type: TABLE; Schema: public; Owner: - -- CREATE TABLE public.competitor_comparisons ( id bigint NOT NULL, campaign_id bigint NOT NULL, comparison_date date, territory_id bigint, our_score numeric(5,2), our_rank integer, leader_competitor_id bigint, leader_score numeric(5,2), gap_to_leader numeric(5,2), gap_change numeric(5,2), our_strengths json, our_weaknesses json, opportunities json, threats json, metadata json, created_at timestamp(0) without time zone, updated_at timestamp(0) without time zone ); -- -- Name: competitor_comparisons_id_seq; Type: SEQUENCE; Schema: public; Owner: - -- CREATE SEQUENCE public.competitor_comparisons_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; -- -- Name: competitor_comparisons_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - -- ALTER SEQUENCE public.competitor_comparisons_id_seq OWNED BY public.competitor_comparisons.id; -- -- Name: competitor_metric_snapshots; Type: TABLE; Schema: public; Owner: - -- CREATE TABLE public.competitor_metric_snapshots ( id bigint NOT NULL, political_competitor_id bigint NOT NULL, campaign_id bigint NOT NULL, platform character varying(30) NOT NULL, handle character varying(255), followers bigint DEFAULT '0'::bigint NOT NULL, posts_count integer DEFAULT 0 NOT NULL, engagement_rate numeric(6,3) DEFAULT '0'::numeric NOT NULL, avg_interactions bigint DEFAULT '0'::bigint NOT NULL, fetched_at timestamp(0) without time zone NOT NULL, created_at timestamp(0) without time zone, updated_at timestamp(0) without time zone ); -- -- Name: competitor_metric_snapshots_id_seq; Type: SEQUENCE; Schema: public; Owner: - -- CREATE SEQUENCE public.competitor_metric_snapshots_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; -- -- Name: competitor_metric_snapshots_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - -- ALTER SEQUENCE public.competitor_metric_snapshots_id_seq OWNED BY public.competitor_metric_snapshots.id; -- -- Name: confirmed_voters; Type: TABLE; Schema: public; Owner: - -- CREATE TABLE public.confirmed_voters ( id bigint NOT NULL, campaign_id bigint NOT NULL, qr_citizen_lead_id bigint, full_name character varying(255) NOT NULL, phone character varying(40), email character varying(160), polling_station_id bigint, territory_id bigint, address character varying(255), commitment_level character varying(20) DEFAULT 'medio'::character varying NOT NULL, needs_transportation boolean DEFAULT false NOT NULL, needs_accompaniment boolean DEFAULT false NOT NULL, contact_preference character varying(30), confirmed_at timestamp(0) without time zone, confirmed_by bigint, voted boolean DEFAULT false NOT NULL, voted_at timestamp(0) without time zone, metadata json, created_at timestamp(0) without time zone, updated_at timestamp(0) without time zone ); -- -- Name: confirmed_voters_id_seq; Type: SEQUENCE; Schema: public; Owner: - -- CREATE SEQUENCE public.confirmed_voters_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; -- -- Name: confirmed_voters_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - -- ALTER SEQUENCE public.confirmed_voters_id_seq OWNED BY public.confirmed_voters.id; -- -- Name: content_a_i_s; Type: TABLE; Schema: public; Owner: - -- CREATE TABLE public.content_a_i_s ( id bigint NOT NULL, campaign_id bigint NOT NULL, title character varying(255) NOT NULL, content_type character varying(255) NOT NULL, content text NOT NULL, status character varying(255) NOT NULL, ai_model character varying(255) NOT NULL, prompt_used text NOT NULL, tone character varying(255) NOT NULL, target_audience character varying(255) NOT NULL, keywords json, word_count integer NOT NULL, created_at timestamp(0) without time zone, updated_at timestamp(0) without time zone, ai_provider_id bigint, CONSTRAINT content_a_i_s_content_type_check CHECK (((content_type)::text = ANY (ARRAY[('post'::character varying)::text, ('article'::character varying)::text, ('video_script'::character varying)::text, ('email'::character varying)::text, ('speech'::character varying)::text, ('ad_copy'::character varying)::text]))), CONSTRAINT content_a_i_s_status_check CHECK (((status)::text = ANY (ARRAY[('draft'::character varying)::text, ('review'::character varying)::text, ('approved'::character varying)::text, ('published'::character varying)::text]))), CONSTRAINT content_a_i_s_target_audience_check CHECK (((target_audience)::text = ANY (ARRAY[('general'::character varying)::text, ('young_voters'::character varying)::text, ('seniors'::character varying)::text, ('professionals'::character varying)::text, ('students'::character varying)::text]))), CONSTRAINT content_a_i_s_tone_check CHECK (((tone)::text = ANY (ARRAY[('professional'::character varying)::text, ('casual'::character varying)::text, ('inspirational'::character varying)::text, ('urgent'::character varying)::text, ('friendly'::character varying)::text]))) ); -- -- Name: content_a_i_s_id_seq; Type: SEQUENCE; Schema: public; Owner: - -- CREATE SEQUENCE public.content_a_i_s_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; -- -- Name: content_a_i_s_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - -- ALTER SEQUENCE public.content_a_i_s_id_seq OWNED BY public.content_a_i_s.id; -- -- Name: content_generations; Type: TABLE; Schema: public; Owner: - -- CREATE TABLE public.content_generations ( id bigint NOT NULL, ai_content_id bigint NOT NULL, content_template_id bigint, user_id bigint NOT NULL, prompt_text text NOT NULL, generated_content text NOT NULL, ai_model_used character varying(255) DEFAULT 'gpt-3.5-turbo'::character varying NOT NULL, generation_parameters json, processing_time_seconds integer, tokens_consumed integer, quality_metrics json, user_feedback character varying(255), is_approved boolean DEFAULT false NOT NULL, metadata json, created_at timestamp(0) without time zone, updated_at timestamp(0) without time zone, deleted_at timestamp(0) without time zone, CONSTRAINT content_generations_user_feedback_check CHECK (((user_feedback)::text = ANY (ARRAY[('excellent'::character varying)::text, ('good'::character varying)::text, ('average'::character varying)::text, ('poor'::character varying)::text]))) ); -- -- Name: content_generations_id_seq; Type: SEQUENCE; Schema: public; Owner: - -- CREATE SEQUENCE public.content_generations_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; -- -- Name: content_generations_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - -- ALTER SEQUENCE public.content_generations_id_seq OWNED BY public.content_generations.id; -- -- Name: content_templates; Type: TABLE; Schema: public; Owner: - -- CREATE TABLE public.content_templates ( id bigint NOT NULL, name character varying(255) NOT NULL, description text, content_type character varying(255) NOT NULL, template_text text NOT NULL, template_html text, prompt_template text NOT NULL, variables json, category character varying(255), difficulty_level character varying(255) DEFAULT 'intermediate'::character varying NOT NULL, estimated_tokens integer, is_active boolean DEFAULT true NOT NULL, usage_count integer DEFAULT 0 NOT NULL, success_rate numeric(3,2) DEFAULT '0'::numeric NOT NULL, metadata json, created_at timestamp(0) without time zone, updated_at timestamp(0) without time zone, deleted_at timestamp(0) without time zone, CONSTRAINT content_templates_content_type_check CHECK (((content_type)::text = ANY (ARRAY[('post'::character varying)::text, ('email'::character varying)::text, ('speech'::character varying)::text, ('proposal'::character varying)::text, ('press_release'::character varying)::text, ('social_media'::character varying)::text, ('campaign_material'::character varying)::text]))), CONSTRAINT content_templates_difficulty_level_check CHECK (((difficulty_level)::text = ANY (ARRAY[('beginner'::character varying)::text, ('intermediate'::character varying)::text, ('advanced'::character varying)::text]))) ); -- -- Name: content_templates_id_seq; Type: SEQUENCE; Schema: public; Owner: - -- CREATE SEQUENCE public.content_templates_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; -- -- Name: content_templates_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - -- ALTER SEQUENCE public.content_templates_id_seq OWNED BY public.content_templates.id; -- -- Name: countries; Type: TABLE; Schema: public; Owner: - -- CREATE TABLE public.countries ( id bigint NOT NULL, name character varying(100) NOT NULL, iso_code character varying(2) NOT NULL, phone_code character varying(10), currency character varying(10), is_active boolean DEFAULT true NOT NULL, created_at timestamp(0) without time zone, updated_at timestamp(0) without time zone ); -- -- Name: countries_id_seq; Type: SEQUENCE; Schema: public; Owner: - -- CREATE SEQUENCE public.countries_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; -- -- Name: countries_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - -- ALTER SEQUENCE public.countries_id_seq OWNED BY public.countries.id; -- -- Name: dashboards; Type: TABLE; Schema: public; Owner: - -- CREATE TABLE public.dashboards ( id bigint NOT NULL, campaign_id bigint NOT NULL, name character varying(160) NOT NULL, description text, slug character varying(120) NOT NULL, layout json, filters json, owner_id bigint, is_public boolean DEFAULT false NOT NULL, is_default boolean DEFAULT false NOT NULL, created_at timestamp(0) without time zone, updated_at timestamp(0) without time zone ); -- -- Name: dashboards_id_seq; Type: SEQUENCE; Schema: public; Owner: - -- CREATE SEQUENCE public.dashboards_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; -- -- Name: dashboards_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - -- ALTER SEQUENCE public.dashboards_id_seq OWNED BY public.dashboards.id; -- -- Name: debate_participants; Type: TABLE; Schema: public; Owner: - -- CREATE TABLE public.debate_participants ( id bigint NOT NULL, debate_id bigint NOT NULL, user_id bigint NOT NULL, role character varying(255) DEFAULT 'candidate'::character varying NOT NULL, confirmed_at timestamp(0) without time zone, declined_at timestamp(0) without time zone, created_at timestamp(0) without time zone, updated_at timestamp(0) without time zone, CONSTRAINT debate_participants_role_check CHECK (((role)::text = ANY (ARRAY[('candidate'::character varying)::text, ('moderator'::character varying)::text, ('observer'::character varying)::text]))) ); -- -- Name: debate_participants_id_seq; Type: SEQUENCE; Schema: public; Owner: - -- CREATE SEQUENCE public.debate_participants_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; -- -- Name: debate_participants_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - -- ALTER SEQUENCE public.debate_participants_id_seq OWNED BY public.debate_participants.id; -- -- Name: debate_questions; Type: TABLE; Schema: public; Owner: - -- CREATE TABLE public.debate_questions ( id bigint NOT NULL, question character varying(255) NOT NULL, category character varying(255) NOT NULL, difficulty character varying(255) DEFAULT 'medium'::character varying NOT NULL, suggested_answer text, keywords json, is_active boolean DEFAULT true NOT NULL, created_at timestamp(0) without time zone, updated_at timestamp(0) without time zone, debate_id bigint, question_text text, "order" smallint DEFAULT 0 NOT NULL, time_limit_seconds integer, is_required boolean DEFAULT false NOT NULL, metadata json ); -- -- Name: debate_questions_id_seq; Type: SEQUENCE; Schema: public; Owner: - -- CREATE SEQUENCE public.debate_questions_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; -- -- Name: debate_questions_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - -- ALTER SEQUENCE public.debate_questions_id_seq OWNED BY public.debate_questions.id; -- -- Name: debate_responses; Type: TABLE; Schema: public; Owner: - -- CREATE TABLE public.debate_responses ( id bigint NOT NULL, debate_id bigint NOT NULL, debate_question_id bigint NOT NULL, user_id bigint NOT NULL, response_text text NOT NULL, response_time_seconds integer, sentiment_score numeric(3,2), sentiment_label character varying(255), metadata json, created_at timestamp(0) without time zone, updated_at timestamp(0) without time zone, deleted_at timestamp(0) without time zone ); -- -- Name: debate_responses_id_seq; Type: SEQUENCE; Schema: public; Owner: - -- CREATE SEQUENCE public.debate_responses_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; -- -- Name: debate_responses_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - -- ALTER SEQUENCE public.debate_responses_id_seq OWNED BY public.debate_responses.id; -- -- Name: debate_sessions; Type: TABLE; Schema: public; Owner: - -- CREATE TABLE public.debate_sessions ( id bigint NOT NULL, campaign_id bigint NOT NULL, user_id bigint NOT NULL, debate_question_id bigint NOT NULL, user_answer text NOT NULL, ai_score numeric(5,2), ai_feedback text, competitor_answers json, time_taken_seconds integer NOT NULL, created_at timestamp(0) without time zone, updated_at timestamp(0) without time zone ); -- -- Name: debate_sessions_id_seq; Type: SEQUENCE; Schema: public; Owner: - -- CREATE SEQUENCE public.debate_sessions_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; -- -- Name: debate_sessions_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - -- ALTER SEQUENCE public.debate_sessions_id_seq OWNED BY public.debate_sessions.id; -- -- Name: debates; Type: TABLE; Schema: public; Owner: - -- CREATE TABLE public.debates ( id bigint NOT NULL, campaign_id bigint NOT NULL, title character varying(255) NOT NULL, description text, debate_date timestamp(0) without time zone NOT NULL, location character varying(255), moderator character varying(255), status character varying(255) DEFAULT 'scheduled'::character varying NOT NULL, duration_minutes integer DEFAULT 60 NOT NULL, max_participants integer DEFAULT 10 NOT NULL, registration_deadline timestamp(0) without time zone, streaming_url character varying(255), metadata json, created_at timestamp(0) without time zone, updated_at timestamp(0) without time zone, deleted_at timestamp(0) without time zone, CONSTRAINT debates_status_check CHECK (((status)::text = ANY (ARRAY[('scheduled'::character varying)::text, ('live'::character varying)::text, ('completed'::character varying)::text, ('cancelled'::character varying)::text]))) ); -- -- Name: debates_id_seq; Type: SEQUENCE; Schema: public; Owner: - -- CREATE SEQUENCE public.debates_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; -- -- Name: debates_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - -- ALTER SEQUENCE public.debates_id_seq OWNED BY public.debates.id; -- -- Name: demo_requests; Type: TABLE; Schema: public; Owner: - -- CREATE TABLE public.demo_requests ( id bigint NOT NULL, name character varying(255) NOT NULL, email character varying(255) NOT NULL, department character varying(255) NOT NULL, city character varying(255) NOT NULL, phone character varying(40) NOT NULL, token character varying(64), expires_at timestamp(0) without time zone NOT NULL, first_accessed_at timestamp(0) without time zone, last_accessed_at timestamp(0) without time zone, access_count integer DEFAULT 0 NOT NULL, status character varying(20) DEFAULT 'nuevo'::character varying NOT NULL, ip character varying(45), notes text, created_at timestamp(0) without time zone, updated_at timestamp(0) without time zone, campaign_id bigint, user_id bigint, provisioning_status character varying(20) DEFAULT 'pendiente'::character varying NOT NULL, provisioning_error text, provisioning_attempts smallint DEFAULT 0 NOT NULL, credentials_sent_at timestamp(0) without time zone, credentials_sent_count smallint DEFAULT 0 NOT NULL, converted_subscription_id bigint, converted_at timestamp(0) without time zone, utm_source character varying(60), utm_campaign character varying(60) ); -- -- Name: demo_requests_id_seq; Type: SEQUENCE; Schema: public; Owner: - -- CREATE SEQUENCE public.demo_requests_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; -- -- Name: demo_requests_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - -- ALTER SEQUENCE public.demo_requests_id_seq OWNED BY public.demo_requests.id; -- -- Name: domains; Type: TABLE; Schema: public; Owner: - -- CREATE TABLE public.domains ( id integer NOT NULL, domain character varying(255) NOT NULL, tenant_id bigint NOT NULL, created_at timestamp(0) without time zone, updated_at timestamp(0) without time zone ); -- -- Name: domains_id_seq; Type: SEQUENCE; Schema: public; Owner: - -- CREATE SEQUENCE public.domains_id_seq AS integer START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; -- -- Name: domains_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - -- ALTER SEQUENCE public.domains_id_seq OWNED BY public.domains.id; -- -- Name: donations; Type: TABLE; Schema: public; Owner: - -- CREATE TABLE public.donations ( id bigint NOT NULL, campaign_id bigint NOT NULL, donor_id bigint, amount numeric(12,2) NOT NULL, currency character varying(3) DEFAULT 'USD'::character varying NOT NULL, payment_method character varying(255) NOT NULL, transaction_id character varying(255), status character varying(255) NOT NULL, receipt_number character varying(255) NOT NULL, receipt_sent_at timestamp(0) without time zone, notes text, metadata json, donated_at timestamp(0) without time zone NOT NULL, created_at timestamp(0) without time zone, updated_at timestamp(0) without time zone ); -- -- Name: donations_id_seq; Type: SEQUENCE; Schema: public; Owner: - -- CREATE SEQUENCE public.donations_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; -- -- Name: donations_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - -- ALTER SEQUENCE public.donations_id_seq OWNED BY public.donations.id; -- -- Name: donors; Type: TABLE; Schema: public; Owner: - -- CREATE TABLE public.donors ( id bigint NOT NULL, campaign_id bigint NOT NULL, name character varying(255) NOT NULL, email character varying(255), phone character varying(255), identification character varying(255), address text, city character varying(255), is_anonymous boolean DEFAULT false NOT NULL, total_donated numeric(12,2) DEFAULT '0'::numeric NOT NULL, metadata json, created_at timestamp(0) without time zone, updated_at timestamp(0) without time zone, deleted_at timestamp(0) without time zone, state character varying(80), country character varying(80) DEFAULT 'Colombia'::character varying NOT NULL, postal_code character varying(20), donation_frequency character varying(20), last_donation_date date, is_active boolean DEFAULT true NOT NULL, preferred_payment_method character varying(30), notes text ); -- -- Name: donors_id_seq; Type: SEQUENCE; Schema: public; Owner: - -- CREATE SEQUENCE public.donors_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; -- -- Name: donors_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - -- ALTER SEQUENCE public.donors_id_seq OWNED BY public.donors.id; -- -- Name: electoral_zones; Type: TABLE; Schema: public; Owner: - -- CREATE TABLE public.electoral_zones ( id bigint NOT NULL, campaign_id bigint NOT NULL, city_id bigint, name character varying(255) NOT NULL, zone_type character varying(255) NOT NULL, geometry json, population integer, registered_voters integer, support_level numeric(5,2), priority character varying(255) DEFAULT 'medium'::character varying NOT NULL, metadata json, created_at timestamp(0) without time zone, updated_at timestamp(0) without time zone ); -- -- Name: electoral_zones_id_seq; Type: SEQUENCE; Schema: public; Owner: - -- CREATE SEQUENCE public.electoral_zones_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; -- -- Name: electoral_zones_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - -- ALTER SEQUENCE public.electoral_zones_id_seq OWNED BY public.electoral_zones.id; -- -- Name: email_campaigns; Type: TABLE; Schema: public; Owner: - -- CREATE TABLE public.email_campaigns ( id bigint NOT NULL, campaign_id bigint NOT NULL, name character varying(255) NOT NULL, subject character varying(255) NOT NULL, preview_text character varying(255), html_content text NOT NULL, text_content text, from_email character varying(255) NOT NULL, from_name character varying(255) NOT NULL, status character varying(255) DEFAULT 'draft'::character varying NOT NULL, scheduled_at timestamp(0) without time zone, sent_at timestamp(0) without time zone, recipients_count integer DEFAULT 0 NOT NULL, opens_count integer DEFAULT 0 NOT NULL, clicks_count integer DEFAULT 0 NOT NULL, metadata json, created_at timestamp(0) without time zone, updated_at timestamp(0) without time zone, deleted_at timestamp(0) without time zone, content text, emails_sent integer DEFAULT 0 NOT NULL, emails_opened integer DEFAULT 0 NOT NULL, emails_clicked integer DEFAULT 0 NOT NULL, open_rate numeric(5,2) DEFAULT 0 NOT NULL, click_rate numeric(5,2) DEFAULT 0 NOT NULL ); -- -- Name: email_campaigns_id_seq; Type: SEQUENCE; Schema: public; Owner: - -- CREATE SEQUENCE public.email_campaigns_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; -- -- Name: email_campaigns_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - -- ALTER SEQUENCE public.email_campaigns_id_seq OWNED BY public.email_campaigns.id; -- -- Name: email_clicks; Type: TABLE; Schema: public; Owner: - -- CREATE TABLE public.email_clicks ( id bigint NOT NULL, campaign_id bigint NOT NULL, email_send_id bigint NOT NULL, url text, ip_address character varying(45), user_agent character varying(255), clicked_at timestamp(0) without time zone, created_at timestamp(0) without time zone, updated_at timestamp(0) without time zone ); -- -- Name: email_clicks_id_seq; Type: SEQUENCE; Schema: public; Owner: - -- CREATE SEQUENCE public.email_clicks_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; -- -- Name: email_clicks_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - -- ALTER SEQUENCE public.email_clicks_id_seq OWNED BY public.email_clicks.id; -- -- Name: email_sends; Type: TABLE; Schema: public; Owner: - -- CREATE TABLE public.email_sends ( id bigint NOT NULL, email_campaign_id bigint NOT NULL, recipient_email character varying(255) NOT NULL, recipient_name character varying(255), status character varying(255) DEFAULT 'pending'::character varying NOT NULL, sent_at timestamp(0) without time zone, opened_at timestamp(0) without time zone, clicked_at timestamp(0) without time zone, bounced_at timestamp(0) without time zone, unsubscribed_at timestamp(0) without time zone, metadata json, created_at timestamp(0) without time zone, updated_at timestamp(0) without time zone, email_template_id bigint, to_email character varying(160), to_name character varying(160), qr_citizen_lead_id bigint, user_id bigint, variant character varying(20), subject character varying(255), message_id character varying(160), delivered_at timestamp(0) without time zone, error_message text ); -- -- Name: email_sends_id_seq; Type: SEQUENCE; Schema: public; Owner: - -- CREATE SEQUENCE public.email_sends_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; -- -- Name: email_sends_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - -- ALTER SEQUENCE public.email_sends_id_seq OWNED BY public.email_sends.id; -- -- Name: email_templates; Type: TABLE; Schema: public; Owner: - -- CREATE TABLE public.email_templates ( id bigint NOT NULL, campaign_id bigint NOT NULL, name character varying(160) NOT NULL, subject character varying(255), preview_text character varying(255), html_content text, text_content text, variables json, category character varying(60), is_active boolean DEFAULT true NOT NULL, thumbnail_url character varying(255), metadata json, created_at timestamp(0) without time zone, updated_at timestamp(0) without time zone ); -- -- Name: email_templates_id_seq; Type: SEQUENCE; Schema: public; Owner: - -- CREATE SEQUENCE public.email_templates_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; -- -- Name: email_templates_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - -- ALTER SEQUENCE public.email_templates_id_seq OWNED BY public.email_templates.id; -- -- Name: event_attendees; Type: TABLE; Schema: public; Owner: - -- CREATE TABLE public.event_attendees ( id bigint NOT NULL, event_id bigint NOT NULL, name character varying(255) NOT NULL, email character varying(255), phone character varying(255), registration_source character varying(255) NOT NULL, status character varying(255) DEFAULT 'registered'::character varying NOT NULL, qr_code character varying(255) NOT NULL, checked_in_at timestamp(0) without time zone, metadata json, created_at timestamp(0) without time zone, updated_at timestamp(0) without time zone ); -- -- Name: event_attendees_id_seq; Type: SEQUENCE; Schema: public; Owner: - -- CREATE SEQUENCE public.event_attendees_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; -- -- Name: event_attendees_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - -- ALTER SEQUENCE public.event_attendees_id_seq OWNED BY public.event_attendees.id; -- -- Name: event_registrations; Type: TABLE; Schema: public; Owner: - -- CREATE TABLE public.event_registrations ( id bigint NOT NULL, event_id bigint NOT NULL, user_id bigint NOT NULL, registration_date timestamp(0) without time zone NOT NULL, status character varying(255) DEFAULT 'confirmed'::character varying NOT NULL, notes text, attended boolean, check_in_time timestamp(0) without time zone, check_out_time timestamp(0) without time zone, metadata json, created_at timestamp(0) without time zone, updated_at timestamp(0) without time zone, deleted_at timestamp(0) without time zone, CONSTRAINT event_registrations_status_check CHECK (((status)::text = ANY (ARRAY[('confirmed'::character varying)::text, ('pending'::character varying)::text, ('cancelled'::character varying)::text, ('waitlist'::character varying)::text]))) ); -- -- Name: event_registrations_id_seq; Type: SEQUENCE; Schema: public; Owner: - -- CREATE SEQUENCE public.event_registrations_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; -- -- Name: event_registrations_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - -- ALTER SEQUENCE public.event_registrations_id_seq OWNED BY public.event_registrations.id; -- -- Name: events; Type: TABLE; Schema: public; Owner: - -- CREATE TABLE public.events ( id bigint NOT NULL, campaign_id bigint NOT NULL, name character varying(255) NOT NULL, description text, event_type character varying(255) NOT NULL, location character varying(255) NOT NULL, address text, latitude numeric(10,7), longitude numeric(10,7), capacity integer, start_at timestamp(0) without time zone NOT NULL, end_at timestamp(0) without time zone NOT NULL, is_public boolean DEFAULT true NOT NULL, status character varying(255) DEFAULT 'scheduled'::character varying NOT NULL, metadata json, created_at timestamp(0) without time zone, updated_at timestamp(0) without time zone, deleted_at timestamp(0) without time zone ); -- -- Name: events_id_seq; Type: SEQUENCE; Schema: public; Owner: - -- CREATE SEQUENCE public.events_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; -- -- Name: events_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - -- ALTER SEQUENCE public.events_id_seq OWNED BY public.events.id; -- -- Name: failed_jobs; Type: TABLE; Schema: public; Owner: - -- CREATE TABLE public.failed_jobs ( id bigint NOT NULL, uuid character varying(255) NOT NULL, connection text NOT NULL, queue text NOT NULL, payload text NOT NULL, exception text NOT NULL, failed_at timestamp(0) without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL ); -- -- Name: failed_jobs_id_seq; Type: SEQUENCE; Schema: public; Owner: - -- CREATE SEQUENCE public.failed_jobs_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; -- -- Name: failed_jobs_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - -- ALTER SEQUENCE public.failed_jobs_id_seq OWNED BY public.failed_jobs.id; -- -- Name: gotv_activities; Type: TABLE; Schema: public; Owner: - -- CREATE TABLE public.gotv_activities ( id bigint NOT NULL, campaign_id bigint NOT NULL, gotv_brigade_id bigint, polling_station_id bigint, confirmed_voter_id bigint, activity_type character varying(40) NOT NULL, result character varying(40), notes text, volunteer_id bigint, activity_at timestamp(0) without time zone, latitude numeric(10,7), longitude numeric(10,7), metadata json, created_at timestamp(0) without time zone, updated_at timestamp(0) without time zone ); -- -- Name: gotv_activities_id_seq; Type: SEQUENCE; Schema: public; Owner: - -- CREATE SEQUENCE public.gotv_activities_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; -- -- Name: gotv_activities_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - -- ALTER SEQUENCE public.gotv_activities_id_seq OWNED BY public.gotv_activities.id; -- -- Name: gotv_brigades; Type: TABLE; Schema: public; Owner: - -- CREATE TABLE public.gotv_brigades ( id bigint NOT NULL, campaign_id bigint NOT NULL, name character varying(160) NOT NULL, territory_id bigint, leader_id bigint, member_ids json, members_count integer DEFAULT 0 NOT NULL, assigned_polling_stations json, status character varying(20) DEFAULT 'activa'::character varying NOT NULL, metadata json, created_at timestamp(0) without time zone, updated_at timestamp(0) without time zone ); -- -- Name: gotv_brigades_id_seq; Type: SEQUENCE; Schema: public; Owner: - -- CREATE SEQUENCE public.gotv_brigades_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; -- -- Name: gotv_brigades_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - -- ALTER SEQUENCE public.gotv_brigades_id_seq OWNED BY public.gotv_brigades.id; -- -- Name: gotv_incidents; Type: TABLE; Schema: public; Owner: - -- CREATE TABLE public.gotv_incidents ( id bigint NOT NULL, campaign_id bigint NOT NULL, polling_station_id bigint, type character varying(40) NOT NULL, severity character varying(20) DEFAULT 'media'::character varying NOT NULL, title character varying(255), description text, photo_url character varying(255), reported_by bigint, status character varying(20) DEFAULT 'abierto'::character varying NOT NULL, assigned_to bigint, reported_at timestamp(0) without time zone, resolved_at timestamp(0) without time zone, metadata json, created_at timestamp(0) without time zone, updated_at timestamp(0) without time zone ); -- -- Name: gotv_incidents_id_seq; Type: SEQUENCE; Schema: public; Owner: - -- CREATE SEQUENCE public.gotv_incidents_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; -- -- Name: gotv_incidents_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - -- ALTER SEQUENCE public.gotv_incidents_id_seq OWNED BY public.gotv_incidents.id; -- -- Name: job_batches; Type: TABLE; Schema: public; Owner: - -- CREATE TABLE public.job_batches ( id character varying(255) NOT NULL, name character varying(255) NOT NULL, total_jobs integer NOT NULL, pending_jobs integer NOT NULL, failed_jobs integer NOT NULL, failed_job_ids text NOT NULL, options text, cancelled_at integer, created_at integer NOT NULL, finished_at integer ); -- -- Name: jobs; Type: TABLE; Schema: public; Owner: - -- CREATE TABLE public.jobs ( id bigint NOT NULL, queue character varying(255) NOT NULL, payload text NOT NULL, attempts smallint NOT NULL, reserved_at integer, available_at integer NOT NULL, created_at integer NOT NULL ); -- -- Name: jobs_id_seq; Type: SEQUENCE; Schema: public; Owner: - -- CREATE SEQUENCE public.jobs_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; -- -- Name: jobs_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - -- ALTER SEQUENCE public.jobs_id_seq OWNED BY public.jobs.id; -- -- Name: kpi_values; Type: TABLE; Schema: public; Owner: - -- CREATE TABLE public.kpi_values ( id bigint NOT NULL, campaign_id bigint NOT NULL, kpi_id bigint NOT NULL, date date NOT NULL, value numeric(15,2), metadata json, created_at timestamp(0) without time zone, updated_at timestamp(0) without time zone ); -- -- Name: kpi_values_id_seq; Type: SEQUENCE; Schema: public; Owner: - -- CREATE SEQUENCE public.kpi_values_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; -- -- Name: kpi_values_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - -- ALTER SEQUENCE public.kpi_values_id_seq OWNED BY public.kpi_values.id; -- -- Name: kpis; Type: TABLE; Schema: public; Owner: - -- CREATE TABLE public.kpis ( id bigint NOT NULL, campaign_id bigint NOT NULL, name character varying(160) NOT NULL, slug character varying(120) NOT NULL, description text, category character varying(60), formula text, unit character varying(30), trend character varying(20), target_value numeric(15,2), warning_threshold numeric(15,2), critical_threshold numeric(15,2), is_active boolean DEFAULT true NOT NULL, created_at timestamp(0) without time zone, updated_at timestamp(0) without time zone ); -- -- Name: kpis_id_seq; Type: SEQUENCE; Schema: public; Owner: - -- CREATE SEQUENCE public.kpis_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; -- -- Name: kpis_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - -- ALTER SEQUENCE public.kpis_id_seq OWNED BY public.kpis.id; -- -- Name: membership_plans; Type: TABLE; Schema: public; Owner: - -- CREATE TABLE public.membership_plans ( id bigint NOT NULL, name character varying(255) NOT NULL, slug character varying(255) NOT NULL, price bigint NOT NULL, billing_period character varying(20) NOT NULL, features json, is_active boolean DEFAULT true NOT NULL, created_at timestamp(0) without time zone, updated_at timestamp(0) without time zone, description text, duration_days integer DEFAULT 30 NOT NULL, max_users smallint DEFAULT 5 NOT NULL, max_voters integer DEFAULT 50000 NOT NULL, max_whatsapp_monthly integer DEFAULT 0 NOT NULL, max_email_monthly integer DEFAULT 0 NOT NULL, is_featured boolean DEFAULT false NOT NULL, sort_order smallint DEFAULT 0 NOT NULL ); -- -- Name: membership_plans_id_seq; Type: SEQUENCE; Schema: public; Owner: - -- CREATE SEQUENCE public.membership_plans_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; -- -- Name: membership_plans_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - -- ALTER SEQUENCE public.membership_plans_id_seq OWNED BY public.membership_plans.id; -- -- Name: migrations; Type: TABLE; Schema: public; Owner: - -- CREATE TABLE public.migrations ( id integer NOT NULL, migration character varying(255) NOT NULL, batch integer NOT NULL ); -- -- Name: migrations_id_seq; Type: SEQUENCE; Schema: public; Owner: - -- CREATE SEQUENCE public.migrations_id_seq AS integer START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; -- -- Name: migrations_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - -- ALTER SEQUENCE public.migrations_id_seq OWNED BY public.migrations.id; -- -- Name: model_has_permissions; Type: TABLE; Schema: public; Owner: - -- CREATE TABLE public.model_has_permissions ( permission_id bigint NOT NULL, model_type character varying(255) NOT NULL, model_id bigint NOT NULL ); -- -- Name: model_has_roles; Type: TABLE; Schema: public; Owner: - -- CREATE TABLE public.model_has_roles ( role_id bigint NOT NULL, model_type character varying(255) NOT NULL, model_id bigint NOT NULL ); -- -- Name: password_reset_tokens; Type: TABLE; Schema: public; Owner: - -- CREATE TABLE public.password_reset_tokens ( email character varying(255) NOT NULL, token character varying(255) NOT NULL, created_at timestamp(0) without time zone ); -- -- Name: payment_gateways; Type: TABLE; Schema: public; Owner: - -- CREATE TABLE public.payment_gateways ( id bigint NOT NULL, campaign_id bigint NOT NULL, provider character varying(20) NOT NULL, credentials text NOT NULL, is_active boolean DEFAULT false NOT NULL, is_test_mode boolean DEFAULT true NOT NULL, status character varying(20) DEFAULT 'sin_probar'::character varying NOT NULL, last_tested_at timestamp(0) without time zone, created_at timestamp(0) without time zone, updated_at timestamp(0) without time zone ); -- -- Name: payment_gateways_id_seq; Type: SEQUENCE; Schema: public; Owner: - -- CREATE SEQUENCE public.payment_gateways_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; -- -- Name: payment_gateways_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - -- ALTER SEQUENCE public.payment_gateways_id_seq OWNED BY public.payment_gateways.id; -- -- Name: permissions; Type: TABLE; Schema: public; Owner: - -- CREATE TABLE public.permissions ( id bigint NOT NULL, name character varying(255) NOT NULL, guard_name character varying(255) NOT NULL, created_at timestamp(0) without time zone, updated_at timestamp(0) without time zone ); -- -- Name: permissions_id_seq; Type: SEQUENCE; Schema: public; Owner: - -- CREATE SEQUENCE public.permissions_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; -- -- Name: permissions_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - -- ALTER SEQUENCE public.permissions_id_seq OWNED BY public.permissions.id; -- -- Name: personal_access_tokens; Type: TABLE; Schema: public; Owner: - -- CREATE TABLE public.personal_access_tokens ( id bigint NOT NULL, tokenable_type character varying(255) NOT NULL, tokenable_id bigint NOT NULL, name text NOT NULL, token character varying(64) NOT NULL, abilities text, last_used_at timestamp(0) without time zone, expires_at timestamp(0) without time zone, created_at timestamp(0) without time zone, updated_at timestamp(0) without time zone ); -- -- Name: personal_access_tokens_id_seq; Type: SEQUENCE; Schema: public; Owner: - -- CREATE SEQUENCE public.personal_access_tokens_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; -- -- Name: personal_access_tokens_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - -- ALTER SEQUENCE public.personal_access_tokens_id_seq OWNED BY public.personal_access_tokens.id; -- -- Name: platform_activities; Type: TABLE; Schema: public; Owner: - -- CREATE TABLE public.platform_activities ( id bigint NOT NULL, campaign_id bigint, user_id bigint, action character varying(120) NOT NULL, model_type character varying(160), model_id bigint, properties json, ip_address character varying(45), user_agent character varying(255), created_at timestamp(0) without time zone, updated_at timestamp(0) without time zone ); -- -- Name: platform_activities_id_seq; Type: SEQUENCE; Schema: public; Owner: - -- CREATE SEQUENCE public.platform_activities_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; -- -- Name: platform_activities_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - -- ALTER SEQUENCE public.platform_activities_id_seq OWNED BY public.platform_activities.id; -- -- Name: platform_payment_gateways; Type: TABLE; Schema: public; Owner: - -- CREATE TABLE public.platform_payment_gateways ( id bigint NOT NULL, provider character varying(20) NOT NULL, credentials text NOT NULL, is_active boolean DEFAULT false NOT NULL, is_test_mode boolean DEFAULT true NOT NULL, status character varying(20) DEFAULT 'sin_probar'::character varying NOT NULL, last_tested_at timestamp(0) without time zone, created_at timestamp(0) without time zone, updated_at timestamp(0) without time zone ); -- -- Name: platform_payment_gateways_id_seq; Type: SEQUENCE; Schema: public; Owner: - -- CREATE SEQUENCE public.platform_payment_gateways_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; -- -- Name: platform_payment_gateways_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - -- ALTER SEQUENCE public.platform_payment_gateways_id_seq OWNED BY public.platform_payment_gateways.id; -- -- Name: political_competitors; Type: TABLE; Schema: public; Owner: - -- CREATE TABLE public.political_competitors ( id bigint NOT NULL, campaign_id bigint, name character varying(255) NOT NULL, party character varying(255), level character varying(255) DEFAULT 'municipal'::character varying NOT NULL, jurisdiction character varying(255), bio text, photo_url character varying(255), social_handles json, total_followers integer DEFAULT 0 NOT NULL, latest_poll_result numeric(5,2), is_active boolean DEFAULT true NOT NULL, created_at timestamp(0) without time zone, updated_at timestamp(0) without time zone, is_main_candidate boolean DEFAULT false NOT NULL, CONSTRAINT political_competitors_level_check CHECK (((level)::text = ANY (ARRAY[('municipal'::character varying)::text, ('departmental'::character varying)::text, ('national'::character varying)::text]))) ); -- -- Name: political_competitors_id_seq; Type: SEQUENCE; Schema: public; Owner: - -- CREATE SEQUENCE public.political_competitors_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; -- -- Name: political_competitors_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - -- ALTER SEQUENCE public.political_competitors_id_seq OWNED BY public.political_competitors.id; -- -- Name: poll_results; Type: TABLE; Schema: public; Owner: - -- CREATE TABLE public.poll_results ( id bigint NOT NULL, popularity_poll_id bigint NOT NULL, political_competitor_id bigint NOT NULL, percentage numeric(5,2) NOT NULL, votes_count integer, created_at timestamp(0) without time zone, updated_at timestamp(0) without time zone, candidate_name character varying(160), vote_intention numeric(5,2), favorability numeric(5,2), unfavorability numeric(5,2), recognition numeric(5,2), rank smallint, demographics_breakdown json ); -- -- Name: poll_results_id_seq; Type: SEQUENCE; Schema: public; Owner: - -- CREATE SEQUENCE public.poll_results_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; -- -- Name: poll_results_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - -- ALTER SEQUENCE public.poll_results_id_seq OWNED BY public.poll_results.id; -- -- Name: polling_places; Type: TABLE; Schema: public; Owner: - -- CREATE TABLE public.polling_places ( id bigint NOT NULL, electoral_zone_id bigint NOT NULL, name character varying(255) NOT NULL, code character varying(255) NOT NULL, address text NOT NULL, latitude numeric(10,7) NOT NULL, longitude numeric(10,7) NOT NULL, registered_voters integer DEFAULT 0 NOT NULL, metadata json, created_at timestamp(0) without time zone, updated_at timestamp(0) without time zone ); -- -- Name: polling_places_id_seq; Type: SEQUENCE; Schema: public; Owner: - -- CREATE SEQUENCE public.polling_places_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; -- -- Name: polling_places_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - -- ALTER SEQUENCE public.polling_places_id_seq OWNED BY public.polling_places.id; -- -- Name: polling_station_turnout; Type: TABLE; Schema: public; Owner: - -- CREATE TABLE public.polling_station_turnout ( id bigint NOT NULL, campaign_id bigint NOT NULL, polling_station_id bigint NOT NULL, check_time timestamp(0) without time zone, voters_so_far integer DEFAULT 0 NOT NULL, estimated_supporters_voted integer DEFAULT 0 NOT NULL, turnout_percentage numeric(5,2), our_turnout_percentage numeric(5,2), status character varying(20) DEFAULT 'reportado'::character varying NOT NULL, reported_by bigint, notes text, reported_at timestamp(0) without time zone, created_at timestamp(0) without time zone, updated_at timestamp(0) without time zone ); -- -- Name: polling_station_turnout_id_seq; Type: SEQUENCE; Schema: public; Owner: - -- CREATE SEQUENCE public.polling_station_turnout_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; -- -- Name: polling_station_turnout_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - -- ALTER SEQUENCE public.polling_station_turnout_id_seq OWNED BY public.polling_station_turnout.id; -- -- Name: polling_stations; Type: TABLE; Schema: public; Owner: - -- CREATE TABLE public.polling_stations ( id bigint NOT NULL, campaign_id bigint NOT NULL, code character varying(60), name character varying(255) NOT NULL, territory_id bigint, address character varying(255), latitude numeric(10,7), longitude numeric(10,7), registered_voters integer DEFAULT 0 NOT NULL, estimated_supporters integer DEFAULT 0 NOT NULL, priority character varying(20) DEFAULT 'media'::character varying NOT NULL, metadata json, created_at timestamp(0) without time zone, updated_at timestamp(0) without time zone ); -- -- Name: polling_stations_id_seq; Type: SEQUENCE; Schema: public; Owner: - -- CREATE SEQUENCE public.polling_stations_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; -- -- Name: polling_stations_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - -- ALTER SEQUENCE public.polling_stations_id_seq OWNED BY public.polling_stations.id; -- -- Name: popularity_metrics; Type: TABLE; Schema: public; Owner: - -- CREATE TABLE public.popularity_metrics ( id bigint NOT NULL, campaign_id bigint NOT NULL, metric_date date NOT NULL, period character varying(20), territory_id bigint, our_vote_intention numeric(5,2), our_favorability numeric(5,2), our_recognition numeric(5,2), our_rank integer, social_followers_total integer DEFAULT 0 NOT NULL, social_followers_growth integer DEFAULT 0 NOT NULL, social_engagement_total integer DEFAULT 0 NOT NULL, social_sentiment_avg numeric(5,2), website_visits integer DEFAULT 0 NOT NULL, volunteer_signups integer DEFAULT 0 NOT NULL, donations_count integer DEFAULT 0 NOT NULL, donations_amount numeric(15,2) DEFAULT 0 NOT NULL, door_knocks integer DEFAULT 0 NOT NULL, events_attendance integer DEFAULT 0 NOT NULL, pqrs_submitted integer DEFAULT 0 NOT NULL, proposals_supported integer DEFAULT 0 NOT NULL, popularity_score numeric(5,2), momentum_score numeric(5,2), trend character varying(20), metadata json, created_at timestamp(0) without time zone, updated_at timestamp(0) without time zone ); -- -- Name: popularity_metrics_id_seq; Type: SEQUENCE; Schema: public; Owner: - -- CREATE SEQUENCE public.popularity_metrics_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; -- -- Name: popularity_metrics_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - -- ALTER SEQUENCE public.popularity_metrics_id_seq OWNED BY public.popularity_metrics.id; -- -- Name: popularity_polls; Type: TABLE; Schema: public; Owner: - -- CREATE TABLE public.popularity_polls ( id bigint NOT NULL, campaign_id bigint NOT NULL, poll_name character varying(255) NOT NULL, organization character varying(255), poll_date date NOT NULL, sample_size integer, margin_of_error numeric(5,2), confidence_level numeric(5,2), methodology text, status character varying(255) DEFAULT 'published'::character varying NOT NULL, metadata json, created_at timestamp(0) without time zone, updated_at timestamp(0) without time zone, deleted_at timestamp(0) without time zone, name character varying(255), description text, type character varying(40), source character varying(40), territory_id bigint, margin_error numeric(5,2), CONSTRAINT popularity_polls_status_check CHECK (((status)::text = ANY (ARRAY[('draft'::character varying)::text, ('published'::character varying)::text, ('archived'::character varying)::text]))) ); -- -- Name: popularity_polls_id_seq; Type: SEQUENCE; Schema: public; Owner: - -- CREATE SEQUENCE public.popularity_polls_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; -- -- Name: popularity_polls_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - -- ALTER SEQUENCE public.popularity_polls_id_seq OWNED BY public.popularity_polls.id; -- -- Name: poster_campaigns; Type: TABLE; Schema: public; Owner: - -- CREATE TABLE public.poster_campaigns ( id bigint NOT NULL, campaign_id bigint NOT NULL, name character varying(160) NOT NULL, description text, type character varying(60), territory_id bigint, start_date date, end_date date, status character varying(20) DEFAULT 'activa'::character varying NOT NULL, total_posters integer DEFAULT 0 NOT NULL, metadata json, created_at timestamp(0) without time zone, updated_at timestamp(0) without time zone ); -- -- Name: poster_campaigns_id_seq; Type: SEQUENCE; Schema: public; Owner: - -- CREATE SEQUENCE public.poster_campaigns_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; -- -- Name: poster_campaigns_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - -- ALTER SEQUENCE public.poster_campaigns_id_seq OWNED BY public.poster_campaigns.id; -- -- Name: poster_qr_codes; Type: TABLE; Schema: public; Owner: - -- CREATE TABLE public.poster_qr_codes ( id bigint NOT NULL, campaign_id bigint NOT NULL, poster_campaign_id bigint, code character varying(64) NOT NULL, url character varying(255), territory_id bigint, location_name character varying(255), latitude numeric(10,7), longitude numeric(10,7), poster_batch character varying(60), placed_at date, placed_by bigint, status character varying(20) DEFAULT 'activo'::character varying NOT NULL, metadata json, created_at timestamp(0) without time zone, updated_at timestamp(0) without time zone ); -- -- Name: poster_qr_codes_id_seq; Type: SEQUENCE; Schema: public; Owner: - -- CREATE SEQUENCE public.poster_qr_codes_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; -- -- Name: poster_qr_codes_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - -- ALTER SEQUENCE public.poster_qr_codes_id_seq OWNED BY public.poster_qr_codes.id; -- -- Name: poster_qr_scans; Type: TABLE; Schema: public; Owner: - -- CREATE TABLE public.poster_qr_scans ( id bigint NOT NULL, campaign_id bigint NOT NULL, poster_qr_code_id bigint, poster_campaign_id bigint, territory_id bigint, scanned_at timestamp(0) without time zone, ip_address character varying(45), user_agent character varying(255), device_type character varying(30), os character varying(40), browser character varying(40), scan_latitude numeric(10,7), scan_longitude numeric(10,7), city character varying(120), region character varying(120), country character varying(80), time_on_page integer, clicked_cta boolean DEFAULT false NOT NULL, cta_action character varying(60), shared boolean DEFAULT false NOT NULL, share_platform character varying(40), utm_source character varying(60), utm_medium character varying(60), utm_campaign character varying(60), metadata json, created_at timestamp(0) without time zone, updated_at timestamp(0) without time zone ); -- -- Name: poster_qr_scans_id_seq; Type: SEQUENCE; Schema: public; Owner: - -- CREATE SEQUENCE public.poster_qr_scans_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; -- -- Name: poster_qr_scans_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - -- ALTER SEQUENCE public.poster_qr_scans_id_seq OWNED BY public.poster_qr_scans.id; -- -- Name: pqrs; Type: TABLE; Schema: public; Owner: - -- CREATE TABLE public.pqrs ( id bigint NOT NULL, campaign_id bigint NOT NULL, ticket_number character varying(40) NOT NULL, type character varying(20) DEFAULT 'peticion'::character varying NOT NULL, category_id bigint, citizen_name character varying(160), citizen_email character varying(160), citizen_phone character varying(40), territory_id bigint, subject character varying(255), description text, priority character varying(20) DEFAULT 'media'::character varying NOT NULL, status character varying(20) DEFAULT 'abierta'::character varying NOT NULL, assigned_to bigint, resolution text, resolved_at timestamp(0) without time zone, consent_data boolean DEFAULT false NOT NULL, consent_data_at timestamp(0) without time zone, consent_ip character varying(45), created_at timestamp(0) without time zone, updated_at timestamp(0) without time zone ); -- -- Name: pqrs_categories; Type: TABLE; Schema: public; Owner: - -- CREATE TABLE public.pqrs_categories ( id bigint NOT NULL, campaign_id bigint NOT NULL, name character varying(120) NOT NULL, color character varying(20) DEFAULT '#1E7A5F'::character varying NOT NULL, is_active boolean DEFAULT true NOT NULL, created_at timestamp(0) without time zone, updated_at timestamp(0) without time zone ); -- -- Name: pqrs_categories_id_seq; Type: SEQUENCE; Schema: public; Owner: - -- CREATE SEQUENCE public.pqrs_categories_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; -- -- Name: pqrs_categories_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - -- ALTER SEQUENCE public.pqrs_categories_id_seq OWNED BY public.pqrs_categories.id; -- -- Name: pqrs_id_seq; Type: SEQUENCE; Schema: public; Owner: - -- CREATE SEQUENCE public.pqrs_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; -- -- Name: pqrs_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - -- ALTER SEQUENCE public.pqrs_id_seq OWNED BY public.pqrs.id; -- -- Name: predictive_variables; Type: TABLE; Schema: public; Owner: - -- CREATE TABLE public.predictive_variables ( id bigint NOT NULL, campaign_id bigint NOT NULL, variable_name character varying(120) NOT NULL, variable_type character varying(40), current_value numeric(10,2), weight numeric(5,2), description text, created_at timestamp(0) without time zone, updated_at timestamp(0) without time zone ); -- -- Name: predictive_variables_id_seq; Type: SEQUENCE; Schema: public; Owner: - -- CREATE SEQUENCE public.predictive_variables_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; -- -- Name: predictive_variables_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - -- ALTER SEQUENCE public.predictive_variables_id_seq OWNED BY public.predictive_variables.id; -- -- Name: preliminary_results; Type: TABLE; Schema: public; Owner: - -- CREATE TABLE public.preliminary_results ( id bigint NOT NULL, campaign_id bigint NOT NULL, polling_station_id bigint NOT NULL, total_votes integer DEFAULT 0 NOT NULL, our_votes integer DEFAULT 0 NOT NULL, null_votes integer DEFAULT 0 NOT NULL, blank_votes integer DEFAULT 0 NOT NULL, acta_photo_url character varying(255), verified boolean DEFAULT false NOT NULL, reported_by bigint, reported_at timestamp(0) without time zone, all_candidates_votes json, metadata json, created_at timestamp(0) without time zone, updated_at timestamp(0) without time zone ); -- -- Name: preliminary_results_id_seq; Type: SEQUENCE; Schema: public; Owner: - -- CREATE SEQUENCE public.preliminary_results_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; -- -- Name: preliminary_results_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - -- ALTER SEQUENCE public.preliminary_results_id_seq OWNED BY public.preliminary_results.id; -- -- Name: proposal_amendments; Type: TABLE; Schema: public; Owner: - -- CREATE TABLE public.proposal_amendments ( id bigint NOT NULL, campaign_id bigint NOT NULL, proposal_id bigint NOT NULL, user_id bigint, title character varying(255), description text, changes json, status character varying(20) DEFAULT 'propuesta'::character varying NOT NULL, supports integer DEFAULT 0 NOT NULL, created_at timestamp(0) without time zone, updated_at timestamp(0) without time zone ); -- -- Name: proposal_amendments_id_seq; Type: SEQUENCE; Schema: public; Owner: - -- CREATE SEQUENCE public.proposal_amendments_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; -- -- Name: proposal_amendments_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - -- ALTER SEQUENCE public.proposal_amendments_id_seq OWNED BY public.proposal_amendments.id; -- -- Name: proposal_categories; Type: TABLE; Schema: public; Owner: - -- CREATE TABLE public.proposal_categories ( id bigint NOT NULL, name character varying(255) NOT NULL, description text, icon character varying(255), color character varying(255) DEFAULT '#8B5CF6'::character varying NOT NULL, created_at timestamp(0) without time zone, updated_at timestamp(0) without time zone ); -- -- Name: proposal_categories_id_seq; Type: SEQUENCE; Schema: public; Owner: - -- CREATE SEQUENCE public.proposal_categories_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; -- -- Name: proposal_categories_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - -- ALTER SEQUENCE public.proposal_categories_id_seq OWNED BY public.proposal_categories.id; -- -- Name: proposal_comments; Type: TABLE; Schema: public; Owner: - -- CREATE TABLE public.proposal_comments ( id bigint NOT NULL, proposal_id bigint NOT NULL, user_id bigint NOT NULL, parent_id bigint, content text NOT NULL, likes integer DEFAULT 0 NOT NULL, is_official_response boolean DEFAULT false NOT NULL, created_at timestamp(0) without time zone, updated_at timestamp(0) without time zone, deleted_at timestamp(0) without time zone ); -- -- Name: proposal_comments_id_seq; Type: SEQUENCE; Schema: public; Owner: - -- CREATE SEQUENCE public.proposal_comments_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; -- -- Name: proposal_comments_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - -- ALTER SEQUENCE public.proposal_comments_id_seq OWNED BY public.proposal_comments.id; -- -- Name: proposal_supports; Type: TABLE; Schema: public; Owner: - -- CREATE TABLE public.proposal_supports ( id bigint NOT NULL, proposal_id bigint NOT NULL, user_id bigint NOT NULL, created_at timestamp(0) without time zone, updated_at timestamp(0) without time zone ); -- -- Name: proposal_supports_id_seq; Type: SEQUENCE; Schema: public; Owner: - -- CREATE SEQUENCE public.proposal_supports_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; -- -- Name: proposal_supports_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - -- ALTER SEQUENCE public.proposal_supports_id_seq OWNED BY public.proposal_supports.id; -- -- Name: proposal_versions; Type: TABLE; Schema: public; Owner: - -- CREATE TABLE public.proposal_versions ( id bigint NOT NULL, proposal_id bigint NOT NULL, version_number integer NOT NULL, content text NOT NULL, created_by bigint NOT NULL, change_notes text, created_at timestamp(0) without time zone, updated_at timestamp(0) without time zone ); -- -- Name: proposal_versions_id_seq; Type: SEQUENCE; Schema: public; Owner: - -- CREATE SEQUENCE public.proposal_versions_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; -- -- Name: proposal_versions_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - -- ALTER SEQUENCE public.proposal_versions_id_seq OWNED BY public.proposal_versions.id; -- -- Name: proposals; Type: TABLE; Schema: public; Owner: - -- CREATE TABLE public.proposals ( id bigint NOT NULL, campaign_id bigint NOT NULL, title character varying(255) NOT NULL, category character varying(255) NOT NULL, description text NOT NULL, estimated_cost numeric(15,2), status character varying(255) DEFAULT 'draft'::character varying NOT NULL, published_at timestamp(0) without time zone, metadata json, created_at timestamp(0) without time zone, updated_at timestamp(0) without time zone, deleted_at timestamp(0) without time zone, summary text, content text, category_id bigint, author_id bigint, supports integer DEFAULT 0 NOT NULL, comments_count integer DEFAULT 0 NOT NULL, allow_comments boolean DEFAULT true NOT NULL, allow_amendments boolean DEFAULT true NOT NULL, territory_id bigint, implementation_months integer, tags json, views integer DEFAULT 0 NOT NULL, priority character varying(20) DEFAULT 'media'::character varying NOT NULL, estimated_timeline character varying(60), supporting_evidence text, opposition_arguments text, created_by bigint, approved_by bigint, approved_at timestamp(0) without time zone, apoyos integer DEFAULT 0 NOT NULL ); -- -- Name: proposals_id_seq; Type: SEQUENCE; Schema: public; Owner: - -- CREATE SEQUENCE public.proposals_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; -- -- Name: proposals_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - -- ALTER SEQUENCE public.proposals_id_seq OWNED BY public.proposals.id; -- -- Name: public_surveys; Type: TABLE; Schema: public; Owner: - -- CREATE TABLE public.public_surveys ( id bigint NOT NULL, campaign_id bigint NOT NULL, survey_name character varying(160) NOT NULL, description text, qr_code character varying(64), is_active boolean DEFAULT true NOT NULL, start_date date, end_date date, max_responses integer, allow_multiple_responses boolean DEFAULT false NOT NULL, created_at timestamp(0) without time zone, updated_at timestamp(0) without time zone ); -- -- Name: public_surveys_id_seq; Type: SEQUENCE; Schema: public; Owner: - -- CREATE SEQUENCE public.public_surveys_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; -- -- Name: public_surveys_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - -- ALTER SEQUENCE public.public_surveys_id_seq OWNED BY public.public_surveys.id; -- -- Name: qr_campaigns; Type: TABLE; Schema: public; Owner: - -- CREATE TABLE public.qr_campaigns ( id bigint NOT NULL, campaign_id bigint NOT NULL, name character varying(160) NOT NULL, description text, target_url character varying(255), created_at timestamp(0) without time zone, updated_at timestamp(0) without time zone ); -- -- Name: qr_campaigns_id_seq; Type: SEQUENCE; Schema: public; Owner: - -- CREATE SEQUENCE public.qr_campaigns_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; -- -- Name: qr_campaigns_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - -- ALTER SEQUENCE public.qr_campaigns_id_seq OWNED BY public.qr_campaigns.id; -- -- Name: qr_citizen_leads; Type: TABLE; Schema: public; Owner: - -- CREATE TABLE public.qr_citizen_leads ( id bigint NOT NULL, campaign_id bigint NOT NULL, poster_qr_code_id bigint, poster_campaign_id bigint, territory_id bigint, full_name character varying(255), email character varying(160), phone character varying(40), document_type character varying(20), document_number character varying(40), birth_date date, gender character varying(20), address character varying(255), neighborhood character varying(120), city character varying(120), latitude numeric(10,7), longitude numeric(10,7), interests json, priority_issues json, occupation character varying(120), socioeconomic_level character varying(20), support_level character varying(20), wants_volunteer boolean DEFAULT false NOT NULL, wants_donate boolean DEFAULT false NOT NULL, wants_updates boolean DEFAULT false NOT NULL, consent_data_processing boolean DEFAULT false NOT NULL, consent_contact boolean DEFAULT false NOT NULL, consent_share_data boolean DEFAULT false NOT NULL, consent_ip character varying(45), consent_at timestamp(0) without time zone, source character varying(60), notes text, metadata json, scanned_at timestamp(0) without time zone, converted_at timestamp(0) without time zone, is_duplicate boolean DEFAULT false NOT NULL, duplicate_of bigint, created_at timestamp(0) without time zone, updated_at timestamp(0) without time zone ); -- -- Name: qr_citizen_leads_id_seq; Type: SEQUENCE; Schema: public; Owner: - -- CREATE SEQUENCE public.qr_citizen_leads_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; -- -- Name: qr_citizen_leads_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - -- ALTER SEQUENCE public.qr_citizen_leads_id_seq OWNED BY public.qr_citizen_leads.id; -- -- Name: qr_codes; Type: TABLE; Schema: public; Owner: - -- CREATE TABLE public.qr_codes ( id bigint NOT NULL, campaign_id bigint NOT NULL, qr_campaign_id bigint, territory_id bigint, code character varying(64) NOT NULL, label character varying(160), target_url character varying(255), is_active boolean DEFAULT true NOT NULL, created_at timestamp(0) without time zone, updated_at timestamp(0) without time zone ); -- -- Name: qr_codes_id_seq; Type: SEQUENCE; Schema: public; Owner: - -- CREATE SEQUENCE public.qr_codes_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; -- -- Name: qr_codes_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - -- ALTER SEQUENCE public.qr_codes_id_seq OWNED BY public.qr_codes.id; -- -- Name: qr_heatmap_data; Type: TABLE; Schema: public; Owner: - -- CREATE TABLE public.qr_heatmap_data ( id bigint NOT NULL, campaign_id bigint NOT NULL, location_name character varying(255) NOT NULL, address character varying(255), latitude numeric(10,8) NOT NULL, longitude numeric(11,8) NOT NULL, zone character varying(255), neighborhood character varying(255), total_scans integer DEFAULT 0 NOT NULL, unique_scans integer DEFAULT 0 NOT NULL, opinions_collected integer DEFAULT 0 NOT NULL, intensity_score numeric(5,2) DEFAULT '0'::numeric NOT NULL, demographics json, sentiment_data json, last_scan_at timestamp(0) without time zone, data_updated_at timestamp(0) without time zone, created_at timestamp(0) without time zone, updated_at timestamp(0) without time zone ); -- -- Name: qr_heatmap_data_id_seq; Type: SEQUENCE; Schema: public; Owner: - -- CREATE SEQUENCE public.qr_heatmap_data_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; -- -- Name: qr_heatmap_data_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - -- ALTER SEQUENCE public.qr_heatmap_data_id_seq OWNED BY public.qr_heatmap_data.id; -- -- Name: qr_heatmap_zones; Type: TABLE; Schema: public; Owner: - -- CREATE TABLE public.qr_heatmap_zones ( id bigint NOT NULL, campaign_id bigint NOT NULL, city_id bigint NOT NULL, zone_name character varying(255) NOT NULL, bounds json NOT NULL, total_scans integer DEFAULT 0 NOT NULL, positive_scans integer DEFAULT 0 NOT NULL, negative_scans integer DEFAULT 0 NOT NULL, neutral_scans integer DEFAULT 0 NOT NULL, avg_rating numeric(3,2), would_vote_percentage numeric(5,2), last_calculated_at date NOT NULL, created_at timestamp(0) without time zone, updated_at timestamp(0) without time zone ); -- -- Name: qr_heatmap_zones_id_seq; Type: SEQUENCE; Schema: public; Owner: - -- CREATE SEQUENCE public.qr_heatmap_zones_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; -- -- Name: qr_heatmap_zones_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - -- ALTER SEQUENCE public.qr_heatmap_zones_id_seq OWNED BY public.qr_heatmap_zones.id; -- -- Name: qr_hits; Type: TABLE; Schema: public; Owner: - -- CREATE TABLE public.qr_hits ( id bigint NOT NULL, campaign_id bigint NOT NULL, qr_code_id bigint NOT NULL, occurred_at timestamp(0) without time zone, ip_address character varying(45), user_agent character varying(255), referrer character varying(255), geom text, created_at timestamp(0) without time zone, updated_at timestamp(0) without time zone ); -- -- Name: qr_hits_id_seq; Type: SEQUENCE; Schema: public; Owner: - -- CREATE SEQUENCE public.qr_hits_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; -- -- Name: qr_hits_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - -- ALTER SEQUENCE public.qr_hits_id_seq OWNED BY public.qr_hits.id; -- -- Name: qr_lead_conversions; Type: TABLE; Schema: public; Owner: - -- CREATE TABLE public.qr_lead_conversions ( id bigint NOT NULL, campaign_id bigint NOT NULL, qr_citizen_lead_id bigint NOT NULL, conversion_type character varying(40) NOT NULL, conversion_value numeric(15,2), converted_at timestamp(0) without time zone, metadata json, created_at timestamp(0) without time zone, updated_at timestamp(0) without time zone ); -- -- Name: qr_lead_conversions_id_seq; Type: SEQUENCE; Schema: public; Owner: - -- CREATE SEQUENCE public.qr_lead_conversions_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; -- -- Name: qr_lead_conversions_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - -- ALTER SEQUENCE public.qr_lead_conversions_id_seq OWNED BY public.qr_lead_conversions.id; -- -- Name: qr_lead_interactions; Type: TABLE; Schema: public; Owner: - -- CREATE TABLE public.qr_lead_interactions ( id bigint NOT NULL, campaign_id bigint NOT NULL, qr_citizen_lead_id bigint NOT NULL, type character varying(40) NOT NULL, subject character varying(255), description text, result character varying(60), user_id bigint, interaction_at timestamp(0) without time zone, metadata json, created_at timestamp(0) without time zone, updated_at timestamp(0) without time zone ); -- -- Name: qr_lead_interactions_id_seq; Type: SEQUENCE; Schema: public; Owner: - -- CREATE SEQUENCE public.qr_lead_interactions_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; -- -- Name: qr_lead_interactions_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - -- ALTER SEQUENCE public.qr_lead_interactions_id_seq OWNED BY public.qr_lead_interactions.id; -- -- Name: qr_posters; Type: TABLE; Schema: public; Owner: - -- CREATE TABLE public.qr_posters ( id bigint NOT NULL, campaign_id bigint NOT NULL, name character varying(255) NOT NULL, description text, qr_code character varying(255) NOT NULL, short_url character varying(255) NOT NULL, country_id bigint NOT NULL, state_id bigint NOT NULL, city_id bigint NOT NULL, neighborhood character varying(255), exact_location text NOT NULL, latitude numeric(10,7) NOT NULL, longitude numeric(10,7) NOT NULL, poster_size character varying(255), installed_at date, expires_at date, is_active boolean DEFAULT true NOT NULL, total_scans integer DEFAULT 0 NOT NULL, metadata json, created_at timestamp(0) without time zone, updated_at timestamp(0) without time zone, deleted_at timestamp(0) without time zone ); -- -- Name: qr_posters_id_seq; Type: SEQUENCE; Schema: public; Owner: - -- CREATE SEQUENCE public.qr_posters_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; -- -- Name: qr_posters_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - -- ALTER SEQUENCE public.qr_posters_id_seq OWNED BY public.qr_posters.id; -- -- Name: qr_scans; Type: TABLE; Schema: public; Owner: - -- CREATE TABLE public.qr_scans ( id bigint NOT NULL, qr_poster_id bigint NOT NULL, campaign_id bigint NOT NULL, scanner_name character varying(255), scanner_email character varying(255), scanner_phone character varying(255), scanner_age_range character varying(255), scanner_gender character varying(255), scan_latitude numeric(10,7), scan_longitude numeric(10,7), opinion text, sentiment character varying(255), rating integer, would_vote boolean, interests json, ip_address inet, user_agent character varying(255), device_type character varying(255), browser character varying(255), os character varying(255), referrer character varying(255), shared_on_social boolean DEFAULT false NOT NULL, subscribed_to_updates boolean DEFAULT false NOT NULL, scanned_at timestamp(0) without time zone NOT NULL, created_at timestamp(0) without time zone, updated_at timestamp(0) without time zone ); -- -- Name: qr_scans_id_seq; Type: SEQUENCE; Schema: public; Owner: - -- CREATE SEQUENCE public.qr_scans_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; -- -- Name: qr_scans_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - -- ALTER SEQUENCE public.qr_scans_id_seq OWNED BY public.qr_scans.id; -- -- Name: regional_interests; Type: TABLE; Schema: public; Owner: - -- CREATE TABLE public.regional_interests ( id bigint NOT NULL, campaign_id bigint NOT NULL, territory_id bigint, poster_campaign_id bigint, interest_type character varying(60), interest_value character varying(160), engagement_score integer DEFAULT 0 NOT NULL, total_scans integer DEFAULT 0 NOT NULL, total_cta_clicks integer DEFAULT 0 NOT NULL, total_shares integer DEFAULT 0 NOT NULL, demographics json, last_interaction_at timestamp(0) without time zone, created_at timestamp(0) without time zone, updated_at timestamp(0) without time zone ); -- -- Name: regional_interests_id_seq; Type: SEQUENCE; Schema: public; Owner: - -- CREATE SEQUENCE public.regional_interests_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; -- -- Name: regional_interests_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - -- ALTER SEQUENCE public.regional_interests_id_seq OWNED BY public.regional_interests.id; -- -- Name: role_has_permissions; Type: TABLE; Schema: public; Owner: - -- CREATE TABLE public.role_has_permissions ( permission_id bigint NOT NULL, role_id bigint NOT NULL ); -- -- Name: roles; Type: TABLE; Schema: public; Owner: - -- CREATE TABLE public.roles ( id bigint NOT NULL, name character varying(255) NOT NULL, guard_name character varying(255) NOT NULL, created_at timestamp(0) without time zone, updated_at timestamp(0) without time zone ); -- -- Name: roles_id_seq; Type: SEQUENCE; Schema: public; Owner: - -- CREATE SEQUENCE public.roles_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; -- -- Name: roles_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - -- ALTER SEQUENCE public.roles_id_seq OWNED BY public.roles.id; -- -- Name: security_alerts; Type: TABLE; Schema: public; Owner: - -- CREATE TABLE public.security_alerts ( id bigint NOT NULL, user_id bigint, campaign_id bigint, alert_type character varying(255) NOT NULL, severity character varying(255) NOT NULL, title character varying(255) NOT NULL, description text NOT NULL, details json, status character varying(255) DEFAULT 'pending'::character varying NOT NULL, resolution_notes text, resolved_at timestamp(0) without time zone, resolved_by bigint, created_at timestamp(0) without time zone, updated_at timestamp(0) without time zone, CONSTRAINT security_alerts_severity_check CHECK (((severity)::text = ANY (ARRAY[('low'::character varying)::text, ('medium'::character varying)::text, ('high'::character varying)::text, ('critical'::character varying)::text]))), CONSTRAINT security_alerts_status_check CHECK (((status)::text = ANY (ARRAY[('pending'::character varying)::text, ('investigating'::character varying)::text, ('resolved'::character varying)::text, ('false_positive'::character varying)::text]))) ); -- -- Name: security_alerts_id_seq; Type: SEQUENCE; Schema: public; Owner: - -- CREATE SEQUENCE public.security_alerts_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; -- -- Name: security_alerts_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - -- ALTER SEQUENCE public.security_alerts_id_seq OWNED BY public.security_alerts.id; -- -- Name: sessions; Type: TABLE; Schema: public; Owner: - -- CREATE TABLE public.sessions ( id character varying(255) NOT NULL, user_id bigint, ip_address character varying(45), user_agent text, payload text NOT NULL, last_activity integer NOT NULL ); -- -- Name: social_accounts; Type: TABLE; Schema: public; Owner: - -- CREATE TABLE public.social_accounts ( id bigint NOT NULL, political_competitor_id bigint NOT NULL, platform character varying(255) NOT NULL, handle character varying(255) NOT NULL, account_id character varying(255), account_name character varying(255), profile_image_url text, followers_count integer DEFAULT 0 NOT NULL, following_count integer DEFAULT 0 NOT NULL, bio text, is_verified boolean DEFAULT false NOT NULL, last_scraped_at timestamp(0) without time zone, metadata json, created_at timestamp(0) without time zone, updated_at timestamp(0) without time zone, deleted_at timestamp(0) without time zone ); -- -- Name: social_accounts_id_seq; Type: SEQUENCE; Schema: public; Owner: - -- CREATE SEQUENCE public.social_accounts_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; -- -- Name: social_accounts_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - -- ALTER SEQUENCE public.social_accounts_id_seq OWNED BY public.social_accounts.id; -- -- Name: social_alerts; Type: TABLE; Schema: public; Owner: - -- CREATE TABLE public.social_alerts ( id bigint NOT NULL, political_competitor_id bigint NOT NULL, social_post_id bigint, type character varying(255) NOT NULL, severity character varying(255) NOT NULL, title character varying(255) NOT NULL, description text NOT NULL, metadata json, status character varying(255) DEFAULT 'pending'::character varying NOT NULL, resolution_notes text, resolved_at timestamp(0) without time zone, resolved_by bigint, created_at timestamp(0) without time zone, updated_at timestamp(0) without time zone, deleted_at timestamp(0) without time zone ); -- -- Name: social_alerts_id_seq; Type: SEQUENCE; Schema: public; Owner: - -- CREATE SEQUENCE public.social_alerts_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; -- -- Name: social_alerts_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - -- ALTER SEQUENCE public.social_alerts_id_seq OWNED BY public.social_alerts.id; -- -- Name: social_comments; Type: TABLE; Schema: public; Owner: - -- CREATE TABLE public.social_comments ( id bigint NOT NULL, campaign_id bigint NOT NULL, social_post_id bigint, comment_id character varying(120), author_name character varying(160), author_handle character varying(120), content text, commented_at timestamp(0) without time zone, likes_count integer DEFAULT 0 NOT NULL, replies_count integer DEFAULT 0 NOT NULL, sentiment character varying(20), sentiment_score numeric(5,2), is_spam boolean DEFAULT false NOT NULL, is_relevant boolean DEFAULT true NOT NULL, created_at timestamp(0) without time zone, updated_at timestamp(0) without time zone ); -- -- Name: social_comments_id_seq; Type: SEQUENCE; Schema: public; Owner: - -- CREATE SEQUENCE public.social_comments_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; -- -- Name: social_comments_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - -- ALTER SEQUENCE public.social_comments_id_seq OWNED BY public.social_comments.id; -- -- Name: social_media_posts; Type: TABLE; Schema: public; Owner: - -- CREATE TABLE public.social_media_posts ( id bigint NOT NULL, created_at timestamp(0) without time zone, updated_at timestamp(0) without time zone, campaign_id bigint, platform character varying(30), post_id character varying(160), content text, post_type character varying(30), likes integer DEFAULT 0 NOT NULL, shares integer DEFAULT 0 NOT NULL, comments integer DEFAULT 0 NOT NULL, sentiment character varying(20), engagement_rate numeric(6,2), posted_at timestamp(0) without time zone, metadata json ); -- -- Name: social_media_posts_id_seq; Type: SEQUENCE; Schema: public; Owner: - -- CREATE SEQUENCE public.social_media_posts_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; -- -- Name: social_media_posts_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - -- ALTER SEQUENCE public.social_media_posts_id_seq OWNED BY public.social_media_posts.id; -- -- Name: social_posts; Type: TABLE; Schema: public; Owner: - -- CREATE TABLE public.social_posts ( id bigint NOT NULL, political_competitor_id bigint NOT NULL, social_account_id bigint NOT NULL, platform character varying(255) NOT NULL, post_id character varying(255) NOT NULL, post_url character varying(255), content text, content_html text, media_urls json, hashtags json, mentions json, likes_count integer DEFAULT 0 NOT NULL, comments_count integer DEFAULT 0 NOT NULL, shares_count integer DEFAULT 0 NOT NULL, views_count integer DEFAULT 0 NOT NULL, engagement_rate numeric(8,2) DEFAULT '0'::numeric NOT NULL, ai_sentiment character varying(255), ai_sentiment_score numeric(5,2), ai_topics json, ai_entities json, ai_analyzed boolean DEFAULT false NOT NULL, published_at timestamp(0) without time zone, scraped_at timestamp(0) without time zone, raw_data json, created_at timestamp(0) without time zone, updated_at timestamp(0) without time zone, deleted_at timestamp(0) without time zone ); -- -- Name: social_posts_id_seq; Type: SEQUENCE; Schema: public; Owner: - -- CREATE SEQUENCE public.social_posts_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; -- -- Name: social_posts_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - -- ALTER SEQUENCE public.social_posts_id_seq OWNED BY public.social_posts.id; -- -- Name: social_trends; Type: TABLE; Schema: public; Owner: - -- CREATE TABLE public.social_trends ( id bigint NOT NULL, political_competitor_id bigint, keyword character varying(255) NOT NULL, type character varying(255) DEFAULT 'hashtag'::character varying NOT NULL, volume integer DEFAULT 0 NOT NULL, posts_count integer DEFAULT 0 NOT NULL, engagement_total integer DEFAULT 0 NOT NULL, sentiment character varying(255), sentiment_score numeric(5,2), top_posts json, trend_date date NOT NULL, created_at timestamp(0) without time zone, updated_at timestamp(0) without time zone, deleted_at timestamp(0) without time zone ); -- -- Name: social_trends_id_seq; Type: SEQUENCE; Schema: public; Owner: - -- CREATE SEQUENCE public.social_trends_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; -- -- Name: social_trends_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - -- ALTER SEQUENCE public.social_trends_id_seq OWNED BY public.social_trends.id; -- -- Name: states; Type: TABLE; Schema: public; Owner: - -- CREATE TABLE public.states ( id bigint NOT NULL, country_id bigint NOT NULL, name character varying(100) NOT NULL, code character varying(10), is_active boolean DEFAULT true NOT NULL, created_at timestamp(0) without time zone, updated_at timestamp(0) without time zone ); -- -- Name: states_id_seq; Type: SEQUENCE; Schema: public; Owner: - -- CREATE SEQUENCE public.states_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; -- -- Name: states_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - -- ALTER SEQUENCE public.states_id_seq OWNED BY public.states.id; -- -- Name: street_surveys; Type: TABLE; Schema: public; Owner: - -- CREATE TABLE public.street_surveys ( id bigint NOT NULL, name character varying(255), description text, created_by bigint, is_active boolean DEFAULT true NOT NULL, start_date date, end_date date, country_id bigint, state_id bigint, city_id bigint, questions json, settings json, created_at timestamp(0) without time zone, updated_at timestamp(0) without time zone, deleted_at timestamp(0) without time zone, campaign_id bigint, surveyor_id bigint, location character varying(255), neighborhood character varying(120), zone character varying(80), latitude numeric(10,7), longitude numeric(10,7), survey_date date, total_responses integer DEFAULT 0 NOT NULL, positive_responses integer DEFAULT 0 NOT NULL, negative_responses integer DEFAULT 0 NOT NULL, neutral_responses integer DEFAULT 0 NOT NULL, status character varying(20) DEFAULT 'completada'::character varying NOT NULL, notes text ); -- -- Name: street_surveys_id_seq; Type: SEQUENCE; Schema: public; Owner: - -- CREATE SEQUENCE public.street_surveys_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; -- -- Name: street_surveys_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - -- ALTER SEQUENCE public.street_surveys_id_seq OWNED BY public.street_surveys.id; -- -- Name: subscription_payments; Type: TABLE; Schema: public; Owner: - -- CREATE TABLE public.subscription_payments ( id bigint NOT NULL, subscription_id bigint NOT NULL, gateway character varying(20) NOT NULL, gateway_reference character varying(255), status character varying(20) DEFAULT 'pendiente'::character varying NOT NULL, amount bigint NOT NULL, currency character varying(3) DEFAULT 'COP'::character varying NOT NULL, payment_method character varying(40), payload json, processed_at timestamp(0) without time zone, created_at timestamp(0) without time zone, updated_at timestamp(0) without time zone ); -- -- Name: subscription_payments_id_seq; Type: SEQUENCE; Schema: public; Owner: - -- CREATE SEQUENCE public.subscription_payments_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; -- -- Name: subscription_payments_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - -- ALTER SEQUENCE public.subscription_payments_id_seq OWNED BY public.subscription_payments.id; -- -- Name: subscriptions; Type: TABLE; Schema: public; Owner: - -- CREATE TABLE public.subscriptions ( id bigint NOT NULL, campaign_id bigint, membership_plan_id bigint NOT NULL, status character varying(20) DEFAULT 'pendiente'::character varying NOT NULL, gateway character varying(20), transaction_id character varying(255), starts_at timestamp(0) without time zone, ends_at timestamp(0) without time zone, created_at timestamp(0) without time zone, updated_at timestamp(0) without time zone, user_id bigint, demo_request_id bigint, reference character varying(64) NOT NULL, amount bigint DEFAULT 0 NOT NULL, currency character varying(3) DEFAULT 'COP'::character varying NOT NULL, is_test boolean DEFAULT false NOT NULL, paid_at timestamp(0) without time zone, cancelled_at timestamp(0) without time zone, cancel_reason character varying(255), meta json ); -- -- Name: subscriptions_id_seq; Type: SEQUENCE; Schema: public; Owner: - -- CREATE SEQUENCE public.subscriptions_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; -- -- Name: subscriptions_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - -- ALTER SEQUENCE public.subscriptions_id_seq OWNED BY public.subscriptions.id; -- -- Name: survey_analyses; Type: TABLE; Schema: public; Owner: - -- CREATE TABLE public.survey_analyses ( id bigint NOT NULL, campaign_id bigint NOT NULL, survey_id bigint NOT NULL, analysis_date date, candidate_percentages json, top_reasons_by_candidate json, demographic_breakdown json, total_responses integer DEFAULT 0 NOT NULL, created_at timestamp(0) without time zone, updated_at timestamp(0) without time zone ); -- -- Name: survey_analyses_id_seq; Type: SEQUENCE; Schema: public; Owner: - -- CREATE SEQUENCE public.survey_analyses_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; -- -- Name: survey_analyses_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - -- ALTER SEQUENCE public.survey_analyses_id_seq OWNED BY public.survey_analyses.id; -- -- Name: survey_candidates; Type: TABLE; Schema: public; Owner: - -- CREATE TABLE public.survey_candidates ( id bigint NOT NULL, campaign_id bigint NOT NULL, survey_id bigint NOT NULL, candidate_name character varying(160) NOT NULL, political_party character varying(120), photo_url character varying(255), display_order smallint DEFAULT 0 NOT NULL, created_at timestamp(0) without time zone, updated_at timestamp(0) without time zone ); -- -- Name: survey_candidates_id_seq; Type: SEQUENCE; Schema: public; Owner: - -- CREATE SEQUENCE public.survey_candidates_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; -- -- Name: survey_candidates_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - -- ALTER SEQUENCE public.survey_candidates_id_seq OWNED BY public.survey_candidates.id; -- -- Name: survey_concerns; Type: TABLE; Schema: public; Owner: - -- CREATE TABLE public.survey_concerns ( id bigint NOT NULL, survey_response_id bigint NOT NULL, concern character varying(255) NOT NULL, priority integer DEFAULT 1 NOT NULL, notes text, created_at timestamp(0) without time zone, updated_at timestamp(0) without time zone ); -- -- Name: survey_concerns_id_seq; Type: SEQUENCE; Schema: public; Owner: - -- CREATE SEQUENCE public.survey_concerns_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; -- -- Name: survey_concerns_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - -- ALTER SEQUENCE public.survey_concerns_id_seq OWNED BY public.survey_concerns.id; -- -- Name: survey_reasons; Type: TABLE; Schema: public; Owner: - -- CREATE TABLE public.survey_reasons ( id bigint NOT NULL, campaign_id bigint NOT NULL, survey_id bigint NOT NULL, reason_text character varying(255) NOT NULL, reason_category character varying(60), display_order smallint DEFAULT 0 NOT NULL, created_at timestamp(0) without time zone, updated_at timestamp(0) without time zone ); -- -- Name: survey_reasons_id_seq; Type: SEQUENCE; Schema: public; Owner: - -- CREATE SEQUENCE public.survey_reasons_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; -- -- Name: survey_reasons_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - -- ALTER SEQUENCE public.survey_reasons_id_seq OWNED BY public.survey_reasons.id; -- -- Name: survey_responses; Type: TABLE; Schema: public; Owner: - -- CREATE TABLE public.survey_responses ( id bigint NOT NULL, street_survey_id bigint NOT NULL, surveyor_id bigint, respondent_age_range character varying(255), respondent_gender character varying(255), respondent_socioeconomic character varying(255), respondent_neighborhood character varying(255), country_id bigint NOT NULL, state_id bigint NOT NULL, city_id bigint NOT NULL, latitude numeric(10,7), longitude numeric(10,7), preferred_candidate_id bigint, answers json NOT NULL, device_info character varying(255), ip_address inet, completed_at timestamp(0) without time zone, created_at timestamp(0) without time zone, updated_at timestamp(0) without time zone, deleted_at timestamp(0) without time zone, survey_template_id bigint, consent_given boolean DEFAULT false NOT NULL, allow_contact boolean DEFAULT false NOT NULL, CONSTRAINT survey_responses_respondent_gender_check CHECK (((respondent_gender)::text = ANY (ARRAY[('male'::character varying)::text, ('female'::character varying)::text, ('other'::character varying)::text, ('prefer_not_say'::character varying)::text]))) ); -- -- Name: survey_responses_id_seq; Type: SEQUENCE; Schema: public; Owner: - -- CREATE SEQUENCE public.survey_responses_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; -- -- Name: survey_responses_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - -- ALTER SEQUENCE public.survey_responses_id_seq OWNED BY public.survey_responses.id; -- -- Name: survey_templates; Type: TABLE; Schema: public; Owner: - -- CREATE TABLE public.survey_templates ( id bigint NOT NULL, campaign_id bigint NOT NULL, name character varying(255) NOT NULL, description text, questions json NOT NULL, is_active boolean DEFAULT true NOT NULL, collect_contact boolean DEFAULT false NOT NULL, is_default boolean DEFAULT false NOT NULL, responses_count integer DEFAULT 0 NOT NULL, created_at timestamp(0) without time zone, updated_at timestamp(0) without time zone ); -- -- Name: survey_templates_id_seq; Type: SEQUENCE; Schema: public; Owner: - -- CREATE SEQUENCE public.survey_templates_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; -- -- Name: survey_templates_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - -- ALTER SEQUENCE public.survey_templates_id_seq OWNED BY public.survey_templates.id; -- -- Name: surveyor_activity_log; Type: TABLE; Schema: public; Owner: - -- CREATE TABLE public.surveyor_activity_log ( id bigint NOT NULL, surveyor_id bigint NOT NULL, street_survey_id bigint NOT NULL, started_at timestamp(0) without time zone NOT NULL, ended_at timestamp(0) without time zone, responses_count integer DEFAULT 0 NOT NULL, latitude numeric(10,7), longitude numeric(10,7), metadata json, created_at timestamp(0) without time zone, updated_at timestamp(0) without time zone ); -- -- Name: surveyor_activity_log_id_seq; Type: SEQUENCE; Schema: public; Owner: - -- CREATE SEQUENCE public.surveyor_activity_log_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; -- -- Name: surveyor_activity_log_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - -- ALTER SEQUENCE public.surveyor_activity_log_id_seq OWNED BY public.surveyor_activity_log.id; -- -- Name: tasks; Type: TABLE; Schema: public; Owner: - -- CREATE TABLE public.tasks ( id bigint NOT NULL, campaign_id bigint NOT NULL, assigned_to bigint NOT NULL, assigned_by bigint NOT NULL, title character varying(255) NOT NULL, description text NOT NULL, task_type character varying(255) NOT NULL, priority character varying(255) NOT NULL, status character varying(255) NOT NULL, due_date timestamp(0) without time zone, completed_at timestamp(0) without time zone, location character varying(255), estimated_hours numeric(5,2), actual_hours numeric(5,2), notes text, metadata json, created_at timestamp(0) without time zone, updated_at timestamp(0) without time zone, CONSTRAINT tasks_priority_check CHECK (((priority)::text = ANY (ARRAY[('low'::character varying)::text, ('medium'::character varying)::text, ('high'::character varying)::text, ('urgent'::character varying)::text]))), CONSTRAINT tasks_status_check CHECK (((status)::text = ANY (ARRAY[('pending'::character varying)::text, ('in_progress'::character varying)::text, ('completed'::character varying)::text, ('cancelled'::character varying)::text]))), CONSTRAINT tasks_task_type_check CHECK (((task_type)::text = ANY (ARRAY[('canvassing'::character varying)::text, ('phone_calls'::character varying)::text, ('event_support'::character varying)::text, ('data_entry'::character varying)::text, ('social_media'::character varying)::text, ('other'::character varying)::text]))) ); -- -- Name: tasks_id_seq; Type: SEQUENCE; Schema: public; Owner: - -- CREATE SEQUENCE public.tasks_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; -- -- Name: tasks_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - -- ALTER SEQUENCE public.tasks_id_seq OWNED BY public.tasks.id; -- -- Name: tenant_configurations; Type: TABLE; Schema: public; Owner: - -- CREATE TABLE public.tenant_configurations ( id bigint NOT NULL, campaign_id bigint NOT NULL, config_key character varying(120) NOT NULL, config_value text, is_encrypted boolean DEFAULT false NOT NULL, config_group character varying(60), created_at timestamp(0) without time zone, updated_at timestamp(0) without time zone ); -- -- Name: tenant_configurations_id_seq; Type: SEQUENCE; Schema: public; Owner: - -- CREATE SEQUENCE public.tenant_configurations_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; -- -- Name: tenant_configurations_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - -- ALTER SEQUENCE public.tenant_configurations_id_seq OWNED BY public.tenant_configurations.id; -- -- Name: tenant_integrations; Type: TABLE; Schema: public; Owner: - -- CREATE TABLE public.tenant_integrations ( id bigint NOT NULL, campaign_id bigint NOT NULL, integration_name character varying(120) NOT NULL, integration_type character varying(60), is_active boolean DEFAULT false NOT NULL, credentials text, settings json, last_sync_at timestamp(0) without time zone, status character varying(20) DEFAULT 'sin_configurar'::character varying NOT NULL, error_message text, created_at timestamp(0) without time zone, updated_at timestamp(0) without time zone ); -- -- Name: tenant_integrations_id_seq; Type: SEQUENCE; Schema: public; Owner: - -- CREATE SEQUENCE public.tenant_integrations_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; -- -- Name: tenant_integrations_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - -- ALTER SEQUENCE public.tenant_integrations_id_seq OWNED BY public.tenant_integrations.id; -- -- Name: territories; Type: TABLE; Schema: public; Owner: - -- CREATE TABLE public.territories ( id bigint NOT NULL, campaign_id bigint NOT NULL, name character varying(255) NOT NULL, code character varying(60), type character varying(40) DEFAULT 'comuna'::character varying NOT NULL, parent_id bigint, responsible_id bigint, target_voters integer DEFAULT 0 NOT NULL, notes text, is_active boolean DEFAULT true NOT NULL, boundary text, center text, created_at timestamp(0) without time zone, updated_at timestamp(0) without time zone ); -- -- Name: territories_id_seq; Type: SEQUENCE; Schema: public; Owner: - -- CREATE SEQUENCE public.territories_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; -- -- Name: territories_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - -- ALTER SEQUENCE public.territories_id_seq OWNED BY public.territories.id; -- -- Name: territory_demographic_profiles; Type: TABLE; Schema: public; Owner: - -- CREATE TABLE public.territory_demographic_profiles ( id bigint NOT NULL, campaign_id bigint NOT NULL, territory_id bigint NOT NULL, analysis_date date, total_leads integer DEFAULT 0 NOT NULL, male_count integer DEFAULT 0 NOT NULL, female_count integer DEFAULT 0 NOT NULL, avg_age numeric(5,2), socioeconomic_distribution json, top_interests json, top_priority_issues json, very_interested_count integer DEFAULT 0 NOT NULL, interested_count integer DEFAULT 0 NOT NULL, neutral_count integer DEFAULT 0 NOT NULL, volunteer_conversions integer DEFAULT 0 NOT NULL, donor_conversions integer DEFAULT 0 NOT NULL, event_attendee_conversions integer DEFAULT 0 NOT NULL, conversion_rate numeric(5,2), created_at timestamp(0) without time zone, updated_at timestamp(0) without time zone ); -- -- Name: territory_demographic_profiles_id_seq; Type: SEQUENCE; Schema: public; Owner: - -- CREATE SEQUENCE public.territory_demographic_profiles_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; -- -- Name: territory_demographic_profiles_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - -- ALTER SEQUENCE public.territory_demographic_profiles_id_seq OWNED BY public.territory_demographic_profiles.id; -- -- Name: territory_visits; Type: TABLE; Schema: public; Owner: - -- CREATE TABLE public.territory_visits ( id bigint NOT NULL, campaign_id bigint NOT NULL, territory_id bigint NOT NULL, user_id bigint, visited_at timestamp(0) without time zone, contacts_made integer DEFAULT 0 NOT NULL, flyers_distributed integer DEFAULT 0 NOT NULL, notes text, photo character varying(255), geom text, created_at timestamp(0) without time zone, updated_at timestamp(0) without time zone ); -- -- Name: territory_visits_id_seq; Type: SEQUENCE; Schema: public; Owner: - -- CREATE SEQUENCE public.territory_visits_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; -- -- Name: territory_visits_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - -- ALTER SEQUENCE public.territory_visits_id_seq OWNED BY public.territory_visits.id; -- -- Name: transactions; Type: TABLE; Schema: public; Owner: - -- CREATE TABLE public.transactions ( id bigint NOT NULL, campaign_id bigint NOT NULL, reference character varying(64), type character varying(20) NOT NULL, category_id bigint, amount numeric(15,2) NOT NULL, date date NOT NULL, description character varying(255), notes text, donor_name character varying(160), donor_id bigint, donor_email character varying(160), receipt_number character varying(60), receipt_file character varying(255), recorded_by bigint, status character varying(20) DEFAULT 'registrada'::character varying NOT NULL, approved_by bigint, approved_at timestamp(0) without time zone, created_at timestamp(0) without time zone, updated_at timestamp(0) without time zone ); -- -- Name: transactions_id_seq; Type: SEQUENCE; Schema: public; Owner: - -- CREATE SEQUENCE public.transactions_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; -- -- Name: transactions_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - -- ALTER SEQUENCE public.transactions_id_seq OWNED BY public.transactions.id; -- -- Name: users; Type: TABLE; Schema: public; Owner: - -- CREATE TABLE public.users ( id bigint NOT NULL, name character varying(255) NOT NULL, email character varying(255) NOT NULL, email_verified_at timestamp(0) without time zone, password character varying(255) NOT NULL, remember_token character varying(100), created_at timestamp(0) without time zone, updated_at timestamp(0) without time zone, phone character varying(255), is_active boolean DEFAULT true NOT NULL, consent_data boolean DEFAULT false NOT NULL, consent_data_at timestamp(0) without time zone, consent_contact boolean DEFAULT false NOT NULL, consent_contact_at timestamp(0) without time zone, consent_ip character varying(255), current_campaign_id bigint, bio text, avatar character varying(255) ); -- -- Name: users_id_seq; Type: SEQUENCE; Schema: public; Owner: - -- CREATE SEQUENCE public.users_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; -- -- Name: users_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - -- ALTER SEQUENCE public.users_id_seq OWNED BY public.users.id; -- -- Name: victory_predictions; Type: TABLE; Schema: public; Owner: - -- CREATE TABLE public.victory_predictions ( id bigint NOT NULL, campaign_id bigint NOT NULL, prediction_date date NOT NULL, predicted_percentage numeric(5,2) NOT NULL, confidence_level numeric(5,2) NOT NULL, data_points_count integer, variables_snapshot json, prediction_status character varying(255) DEFAULT 'active'::character varying NOT NULL, actual_percentage numeric(5,2), created_at timestamp(0) without time zone, updated_at timestamp(0) without time zone, CONSTRAINT victory_predictions_prediction_status_check CHECK (((prediction_status)::text = ANY (ARRAY[('draft'::character varying)::text, ('active'::character varying)::text, ('archived'::character varying)::text]))) ); -- -- Name: victory_predictions_id_seq; Type: SEQUENCE; Schema: public; Owner: - -- CREATE SEQUENCE public.victory_predictions_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; -- -- Name: victory_predictions_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - -- ALTER SEQUENCE public.victory_predictions_id_seq OWNED BY public.victory_predictions.id; -- -- Name: volunteer_activities; Type: TABLE; Schema: public; Owner: - -- CREATE TABLE public.volunteer_activities ( id bigint NOT NULL, campaign_id bigint NOT NULL, user_id bigint, team_id bigint, type character varying(40), description text, started_at timestamp(0) without time zone, ended_at timestamp(0) without time zone, duration_minutes integer, latitude numeric(10,7), longitude numeric(10,7), metadata json, created_at timestamp(0) without time zone, updated_at timestamp(0) without time zone ); -- -- Name: volunteer_activities_id_seq; Type: SEQUENCE; Schema: public; Owner: - -- CREATE SEQUENCE public.volunteer_activities_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; -- -- Name: volunteer_activities_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - -- ALTER SEQUENCE public.volunteer_activities_id_seq OWNED BY public.volunteer_activities.id; -- -- Name: volunteer_hours; Type: TABLE; Schema: public; Owner: - -- CREATE TABLE public.volunteer_hours ( id bigint NOT NULL, campaign_id bigint NOT NULL, user_id bigint NOT NULL, task_id bigint, date date NOT NULL, hours_worked numeric(5,2) NOT NULL, activity_type character varying(255) NOT NULL, description text NOT NULL, location character varying(255), verified_by bigint, verified_at timestamp(0) without time zone, notes text, created_at timestamp(0) without time zone, updated_at timestamp(0) without time zone, CONSTRAINT volunteer_hours_activity_type_check CHECK (((activity_type)::text = ANY (ARRAY[('canvassing'::character varying)::text, ('phone_calls'::character varying)::text, ('event_support'::character varying)::text, ('data_entry'::character varying)::text, ('social_media'::character varying)::text, ('other'::character varying)::text]))) ); -- -- Name: volunteer_hours_id_seq; Type: SEQUENCE; Schema: public; Owner: - -- CREATE SEQUENCE public.volunteer_hours_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; -- -- Name: volunteer_hours_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - -- ALTER SEQUENCE public.volunteer_hours_id_seq OWNED BY public.volunteer_hours.id; -- -- Name: volunteer_tasks; Type: TABLE; Schema: public; Owner: - -- CREATE TABLE public.volunteer_tasks ( id bigint NOT NULL, campaign_id bigint NOT NULL, volunteer_id bigint NOT NULL, assigned_by bigint, title character varying(255) NOT NULL, description text, task_type character varying(255) NOT NULL, priority character varying(255) DEFAULT 'medium'::character varying NOT NULL, status character varying(255) DEFAULT 'pending'::character varying NOT NULL, due_date date, completed_at timestamp(0) without time zone, hours_spent numeric(5,2) DEFAULT '0'::numeric NOT NULL, metadata json, created_at timestamp(0) without time zone, updated_at timestamp(0) without time zone ); -- -- Name: volunteer_tasks_id_seq; Type: SEQUENCE; Schema: public; Owner: - -- CREATE SEQUENCE public.volunteer_tasks_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; -- -- Name: volunteer_tasks_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - -- ALTER SEQUENCE public.volunteer_tasks_id_seq OWNED BY public.volunteer_tasks.id; -- -- Name: volunteer_teams; Type: TABLE; Schema: public; Owner: - -- CREATE TABLE public.volunteer_teams ( id bigint NOT NULL, campaign_id bigint NOT NULL, name character varying(120) NOT NULL, description text, leader_id bigint, color character varying(20) DEFAULT '#1E7A5F'::character varying NOT NULL, is_active boolean DEFAULT true NOT NULL, created_at timestamp(0) without time zone, updated_at timestamp(0) without time zone ); -- -- Name: volunteer_teams_id_seq; Type: SEQUENCE; Schema: public; Owner: - -- CREATE SEQUENCE public.volunteer_teams_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; -- -- Name: volunteer_teams_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - -- ALTER SEQUENCE public.volunteer_teams_id_seq OWNED BY public.volunteer_teams.id; -- -- Name: volunteers; Type: TABLE; Schema: public; Owner: - -- CREATE TABLE public.volunteers ( id bigint NOT NULL, campaign_id bigint NOT NULL, user_id bigint, name character varying(255) NOT NULL, email character varying(255) NOT NULL, phone character varying(255), skills json, availability json, total_hours numeric(8,2) DEFAULT '0'::numeric NOT NULL, status character varying(255) DEFAULT 'active'::character varying NOT NULL, joined_at date NOT NULL, metadata json, created_at timestamp(0) without time zone, updated_at timestamp(0) without time zone, deleted_at timestamp(0) without time zone, assigned_to bigint, notes text ); -- -- Name: volunteers_id_seq; Type: SEQUENCE; Schema: public; Owner: - -- CREATE SEQUENCE public.volunteers_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; -- -- Name: volunteers_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - -- ALTER SEQUENCE public.volunteers_id_seq OWNED BY public.volunteers.id; -- -- Name: voter_contacts; Type: TABLE; Schema: public; Owner: - -- CREATE TABLE public.voter_contacts ( id bigint NOT NULL, voter_id bigint NOT NULL, user_id bigint, contact_type character varying(255) NOT NULL, outcome character varying(255) NOT NULL, notes text, next_contact_at timestamp(0) without time zone, contacted_at timestamp(0) without time zone NOT NULL, created_at timestamp(0) without time zone, updated_at timestamp(0) without time zone ); -- -- Name: voter_contacts_id_seq; Type: SEQUENCE; Schema: public; Owner: - -- CREATE SEQUENCE public.voter_contacts_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; -- -- Name: voter_contacts_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - -- ALTER SEQUENCE public.voter_contacts_id_seq OWNED BY public.voter_contacts.id; -- -- Name: voters; Type: TABLE; Schema: public; Owner: - -- CREATE TABLE public.voters ( id bigint NOT NULL, campaign_id bigint NOT NULL, name character varying(255) NOT NULL, email character varying(255), phone character varying(255), identification character varying(255), address text, city character varying(255), neighborhood character varying(255), age_range character varying(255), gender character varying(255), voting_likelihood character varying(255), support_level character varying(255), tags json, notes text, last_contact_at timestamp(0) without time zone, metadata json, created_at timestamp(0) without time zone, updated_at timestamp(0) without time zone, deleted_at timestamp(0) without time zone, age_group character varying(20), education_level character varying(40), occupation character varying(80), registration_status character varying(20) DEFAULT 'pendiente'::character varying NOT NULL, last_contacted_at timestamp(0) without time zone, contact_method character varying(30) ); -- -- Name: voters_id_seq; Type: SEQUENCE; Schema: public; Owner: - -- CREATE SEQUENCE public.voters_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; -- -- Name: voters_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - -- ALTER SEQUENCE public.voters_id_seq OWNED BY public.voters.id; -- -- Name: webhook_events; Type: TABLE; Schema: public; Owner: - -- CREATE TABLE public.webhook_events ( id bigint NOT NULL, gateway character varying(20) NOT NULL, event_id character varying(255), event_type character varying(60), signature_valid boolean DEFAULT false NOT NULL, processed boolean DEFAULT false NOT NULL, error text, payload json, created_at timestamp(0) without time zone, updated_at timestamp(0) without time zone ); -- -- Name: webhook_events_id_seq; Type: SEQUENCE; Schema: public; Owner: - -- CREATE SEQUENCE public.webhook_events_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; -- -- Name: webhook_events_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - -- ALTER SEQUENCE public.webhook_events_id_seq OWNED BY public.webhook_events.id; -- -- Name: whatsapp_auto_replies; Type: TABLE; Schema: public; Owner: - -- CREATE TABLE public.whatsapp_auto_replies ( id bigint NOT NULL, campaign_id bigint NOT NULL, trigger character varying(160) NOT NULL, response text NOT NULL, is_active boolean DEFAULT true NOT NULL, priority integer DEFAULT 0 NOT NULL, conditions json, created_at timestamp(0) without time zone, updated_at timestamp(0) without time zone ); -- -- Name: whatsapp_auto_replies_id_seq; Type: SEQUENCE; Schema: public; Owner: - -- CREATE SEQUENCE public.whatsapp_auto_replies_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; -- -- Name: whatsapp_auto_replies_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - -- ALTER SEQUENCE public.whatsapp_auto_replies_id_seq OWNED BY public.whatsapp_auto_replies.id; -- -- Name: whatsapp_campaigns; Type: TABLE; Schema: public; Owner: - -- CREATE TABLE public.whatsapp_campaigns ( id bigint NOT NULL, campaign_id bigint NOT NULL, name character varying(160) NOT NULL, description text, whatsapp_template_id bigint, target_type character varying(40), target_filters json, estimated_recipients integer DEFAULT 0 NOT NULL, scheduled_at timestamp(0) without time zone, status character varying(20) DEFAULT 'borrador'::character varying NOT NULL, created_by bigint, metadata json, created_at timestamp(0) without time zone, updated_at timestamp(0) without time zone ); -- -- Name: whatsapp_campaigns_id_seq; Type: SEQUENCE; Schema: public; Owner: - -- CREATE SEQUENCE public.whatsapp_campaigns_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; -- -- Name: whatsapp_campaigns_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - -- ALTER SEQUENCE public.whatsapp_campaigns_id_seq OWNED BY public.whatsapp_campaigns.id; -- -- Name: whatsapp_conversation_messages; Type: TABLE; Schema: public; Owner: - -- CREATE TABLE public.whatsapp_conversation_messages ( id bigint NOT NULL, campaign_id bigint NOT NULL, whatsapp_conversation_id bigint NOT NULL, direction character varying(10) NOT NULL, content text, message_id character varying(120), sent_by bigint, "timestamp" timestamp(0) without time zone, metadata json, created_at timestamp(0) without time zone, updated_at timestamp(0) without time zone ); -- -- Name: whatsapp_conversation_messages_id_seq; Type: SEQUENCE; Schema: public; Owner: - -- CREATE SEQUENCE public.whatsapp_conversation_messages_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; -- -- Name: whatsapp_conversation_messages_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - -- ALTER SEQUENCE public.whatsapp_conversation_messages_id_seq OWNED BY public.whatsapp_conversation_messages.id; -- -- Name: whatsapp_conversations; Type: TABLE; Schema: public; Owner: - -- CREATE TABLE public.whatsapp_conversations ( id bigint NOT NULL, campaign_id bigint NOT NULL, phone character varying(40) NOT NULL, qr_citizen_lead_id bigint, status character varying(20) DEFAULT 'abierta'::character varying NOT NULL, assigned_to bigint, last_message_at timestamp(0) without time zone, created_at timestamp(0) without time zone, updated_at timestamp(0) without time zone ); -- -- Name: whatsapp_conversations_id_seq; Type: SEQUENCE; Schema: public; Owner: - -- CREATE SEQUENCE public.whatsapp_conversations_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; -- -- Name: whatsapp_conversations_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - -- ALTER SEQUENCE public.whatsapp_conversations_id_seq OWNED BY public.whatsapp_conversations.id; -- -- Name: whatsapp_messages; Type: TABLE; Schema: public; Owner: - -- CREATE TABLE public.whatsapp_messages ( id bigint NOT NULL, campaign_id bigint NOT NULL, whatsapp_campaign_id bigint, whatsapp_template_id bigint, to_phone character varying(40) NOT NULL, to_name character varying(160), qr_citizen_lead_id bigint, user_id bigint, content text, message_id character varying(120), status character varying(20) DEFAULT 'pendiente'::character varying NOT NULL, sent_at timestamp(0) without time zone, delivered_at timestamp(0) without time zone, read_at timestamp(0) without time zone, error_message text, metadata json, created_at timestamp(0) without time zone, updated_at timestamp(0) without time zone ); -- -- Name: whatsapp_messages_id_seq; Type: SEQUENCE; Schema: public; Owner: - -- CREATE SEQUENCE public.whatsapp_messages_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; -- -- Name: whatsapp_messages_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - -- ALTER SEQUENCE public.whatsapp_messages_id_seq OWNED BY public.whatsapp_messages.id; -- -- Name: whatsapp_templates; Type: TABLE; Schema: public; Owner: - -- CREATE TABLE public.whatsapp_templates ( id bigint NOT NULL, campaign_id bigint NOT NULL, name character varying(160) NOT NULL, category character varying(60), content text NOT NULL, variables json, is_active boolean DEFAULT true NOT NULL, requires_approval boolean DEFAULT true NOT NULL, metadata json, created_at timestamp(0) without time zone, updated_at timestamp(0) without time zone ); -- -- Name: whatsapp_templates_id_seq; Type: SEQUENCE; Schema: public; Owner: - -- CREATE SEQUENCE public.whatsapp_templates_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; -- -- Name: whatsapp_templates_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - -- ALTER SEQUENCE public.whatsapp_templates_id_seq OWNED BY public.whatsapp_templates.id; -- -- Name: active_sessions id; Type: DEFAULT; Schema: public; Owner: - -- ALTER TABLE ONLY public.active_sessions ALTER COLUMN id SET DEFAULT nextval('public.active_sessions_id_seq'::regclass); -- -- Name: ai_contents id; Type: DEFAULT; Schema: public; Owner: - -- ALTER TABLE ONLY public.ai_contents ALTER COLUMN id SET DEFAULT nextval('public.ai_contents_id_seq'::regclass); -- -- Name: ai_providers id; Type: DEFAULT; Schema: public; Owner: - -- ALTER TABLE ONLY public.ai_providers ALTER COLUMN id SET DEFAULT nextval('public.ai_providers_id_seq'::regclass); -- -- Name: alert_triggers id; Type: DEFAULT; Schema: public; Owner: - -- ALTER TABLE ONLY public.alert_triggers ALTER COLUMN id SET DEFAULT nextval('public.alert_triggers_id_seq'::regclass); -- -- Name: alerts id; Type: DEFAULT; Schema: public; Owner: - -- ALTER TABLE ONLY public.alerts ALTER COLUMN id SET DEFAULT nextval('public.alerts_id_seq'::regclass); -- -- Name: audit_logs id; Type: DEFAULT; Schema: public; Owner: - -- ALTER TABLE ONLY public.audit_logs ALTER COLUMN id SET DEFAULT nextval('public.audit_logs_id_seq'::regclass); -- -- Name: budget_categories id; Type: DEFAULT; Schema: public; Owner: - -- ALTER TABLE ONLY public.budget_categories ALTER COLUMN id SET DEFAULT nextval('public.budget_categories_id_seq'::regclass); -- -- Name: call_center_calls id; Type: DEFAULT; Schema: public; Owner: - -- ALTER TABLE ONLY public.call_center_calls ALTER COLUMN id SET DEFAULT nextval('public.call_center_calls_id_seq'::regclass); -- -- Name: call_center_scripts id; Type: DEFAULT; Schema: public; Owner: - -- ALTER TABLE ONLY public.call_center_scripts ALTER COLUMN id SET DEFAULT nextval('public.call_center_scripts_id_seq'::regclass); -- -- Name: call_scripts id; Type: DEFAULT; Schema: public; Owner: - -- ALTER TABLE ONLY public.call_scripts ALTER COLUMN id SET DEFAULT nextval('public.call_scripts_id_seq'::regclass); -- -- Name: calls id; Type: DEFAULT; Schema: public; Owner: - -- ALTER TABLE ONLY public.calls ALTER COLUMN id SET DEFAULT nextval('public.calls_id_seq'::regclass); -- -- Name: campaign_funds id; Type: DEFAULT; Schema: public; Owner: - -- ALTER TABLE ONLY public.campaign_funds ALTER COLUMN id SET DEFAULT nextval('public.campaign_funds_id_seq'::regclass); -- -- Name: campaign_invitations id; Type: DEFAULT; Schema: public; Owner: - -- ALTER TABLE ONLY public.campaign_invitations ALTER COLUMN id SET DEFAULT nextval('public.campaign_invitations_id_seq'::regclass); -- -- Name: campaign_user id; Type: DEFAULT; Schema: public; Owner: - -- ALTER TABLE ONLY public.campaign_user ALTER COLUMN id SET DEFAULT nextval('public.campaign_user_id_seq'::regclass); -- -- Name: campaigns id; Type: DEFAULT; Schema: public; Owner: - -- ALTER TABLE ONLY public.campaigns ALTER COLUMN id SET DEFAULT nextval('public.campaigns_id_seq'::regclass); -- -- Name: cities id; Type: DEFAULT; Schema: public; Owner: - -- ALTER TABLE ONLY public.cities ALTER COLUMN id SET DEFAULT nextval('public.cities_id_seq'::regclass); -- -- Name: citizen_priorities id; Type: DEFAULT; Schema: public; Owner: - -- ALTER TABLE ONLY public.citizen_priorities ALTER COLUMN id SET DEFAULT nextval('public.citizen_priorities_id_seq'::regclass); -- -- Name: competitor_ad_snapshots id; Type: DEFAULT; Schema: public; Owner: - -- ALTER TABLE ONLY public.competitor_ad_snapshots ALTER COLUMN id SET DEFAULT nextval('public.competitor_ad_snapshots_id_seq'::regclass); -- -- Name: competitor_comparisons id; Type: DEFAULT; Schema: public; Owner: - -- ALTER TABLE ONLY public.competitor_comparisons ALTER COLUMN id SET DEFAULT nextval('public.competitor_comparisons_id_seq'::regclass); -- -- Name: competitor_metric_snapshots id; Type: DEFAULT; Schema: public; Owner: - -- ALTER TABLE ONLY public.competitor_metric_snapshots ALTER COLUMN id SET DEFAULT nextval('public.competitor_metric_snapshots_id_seq'::regclass); -- -- Name: confirmed_voters id; Type: DEFAULT; Schema: public; Owner: - -- ALTER TABLE ONLY public.confirmed_voters ALTER COLUMN id SET DEFAULT nextval('public.confirmed_voters_id_seq'::regclass); -- -- Name: content_a_i_s id; Type: DEFAULT; Schema: public; Owner: - -- ALTER TABLE ONLY public.content_a_i_s ALTER COLUMN id SET DEFAULT nextval('public.content_a_i_s_id_seq'::regclass); -- -- Name: content_generations id; Type: DEFAULT; Schema: public; Owner: - -- ALTER TABLE ONLY public.content_generations ALTER COLUMN id SET DEFAULT nextval('public.content_generations_id_seq'::regclass); -- -- Name: content_templates id; Type: DEFAULT; Schema: public; Owner: - -- ALTER TABLE ONLY public.content_templates ALTER COLUMN id SET DEFAULT nextval('public.content_templates_id_seq'::regclass); -- -- Name: countries id; Type: DEFAULT; Schema: public; Owner: - -- ALTER TABLE ONLY public.countries ALTER COLUMN id SET DEFAULT nextval('public.countries_id_seq'::regclass); -- -- Name: dashboards id; Type: DEFAULT; Schema: public; Owner: - -- ALTER TABLE ONLY public.dashboards ALTER COLUMN id SET DEFAULT nextval('public.dashboards_id_seq'::regclass); -- -- Name: debate_participants id; Type: DEFAULT; Schema: public; Owner: - -- ALTER TABLE ONLY public.debate_participants ALTER COLUMN id SET DEFAULT nextval('public.debate_participants_id_seq'::regclass); -- -- Name: debate_questions id; Type: DEFAULT; Schema: public; Owner: - -- ALTER TABLE ONLY public.debate_questions ALTER COLUMN id SET DEFAULT nextval('public.debate_questions_id_seq'::regclass); -- -- Name: debate_responses id; Type: DEFAULT; Schema: public; Owner: - -- ALTER TABLE ONLY public.debate_responses ALTER COLUMN id SET DEFAULT nextval('public.debate_responses_id_seq'::regclass); -- -- Name: debate_sessions id; Type: DEFAULT; Schema: public; Owner: - -- ALTER TABLE ONLY public.debate_sessions ALTER COLUMN id SET DEFAULT nextval('public.debate_sessions_id_seq'::regclass); -- -- Name: debates id; Type: DEFAULT; Schema: public; Owner: - -- ALTER TABLE ONLY public.debates ALTER COLUMN id SET DEFAULT nextval('public.debates_id_seq'::regclass); -- -- Name: demo_requests id; Type: DEFAULT; Schema: public; Owner: - -- ALTER TABLE ONLY public.demo_requests ALTER COLUMN id SET DEFAULT nextval('public.demo_requests_id_seq'::regclass); -- -- Name: domains id; Type: DEFAULT; Schema: public; Owner: - -- ALTER TABLE ONLY public.domains ALTER COLUMN id SET DEFAULT nextval('public.domains_id_seq'::regclass); -- -- Name: donations id; Type: DEFAULT; Schema: public; Owner: - -- ALTER TABLE ONLY public.donations ALTER COLUMN id SET DEFAULT nextval('public.donations_id_seq'::regclass); -- -- Name: donors id; Type: DEFAULT; Schema: public; Owner: - -- ALTER TABLE ONLY public.donors ALTER COLUMN id SET DEFAULT nextval('public.donors_id_seq'::regclass); -- -- Name: electoral_zones id; Type: DEFAULT; Schema: public; Owner: - -- ALTER TABLE ONLY public.electoral_zones ALTER COLUMN id SET DEFAULT nextval('public.electoral_zones_id_seq'::regclass); -- -- Name: email_campaigns id; Type: DEFAULT; Schema: public; Owner: - -- ALTER TABLE ONLY public.email_campaigns ALTER COLUMN id SET DEFAULT nextval('public.email_campaigns_id_seq'::regclass); -- -- Name: email_clicks id; Type: DEFAULT; Schema: public; Owner: - -- ALTER TABLE ONLY public.email_clicks ALTER COLUMN id SET DEFAULT nextval('public.email_clicks_id_seq'::regclass); -- -- Name: email_sends id; Type: DEFAULT; Schema: public; Owner: - -- ALTER TABLE ONLY public.email_sends ALTER COLUMN id SET DEFAULT nextval('public.email_sends_id_seq'::regclass); -- -- Name: email_templates id; Type: DEFAULT; Schema: public; Owner: - -- ALTER TABLE ONLY public.email_templates ALTER COLUMN id SET DEFAULT nextval('public.email_templates_id_seq'::regclass); -- -- Name: event_attendees id; Type: DEFAULT; Schema: public; Owner: - -- ALTER TABLE ONLY public.event_attendees ALTER COLUMN id SET DEFAULT nextval('public.event_attendees_id_seq'::regclass); -- -- Name: event_registrations id; Type: DEFAULT; Schema: public; Owner: - -- ALTER TABLE ONLY public.event_registrations ALTER COLUMN id SET DEFAULT nextval('public.event_registrations_id_seq'::regclass); -- -- Name: events id; Type: DEFAULT; Schema: public; Owner: - -- ALTER TABLE ONLY public.events ALTER COLUMN id SET DEFAULT nextval('public.events_id_seq'::regclass); -- -- Name: failed_jobs id; Type: DEFAULT; Schema: public; Owner: - -- ALTER TABLE ONLY public.failed_jobs ALTER COLUMN id SET DEFAULT nextval('public.failed_jobs_id_seq'::regclass); -- -- Name: gotv_activities id; Type: DEFAULT; Schema: public; Owner: - -- ALTER TABLE ONLY public.gotv_activities ALTER COLUMN id SET DEFAULT nextval('public.gotv_activities_id_seq'::regclass); -- -- Name: gotv_brigades id; Type: DEFAULT; Schema: public; Owner: - -- ALTER TABLE ONLY public.gotv_brigades ALTER COLUMN id SET DEFAULT nextval('public.gotv_brigades_id_seq'::regclass); -- -- Name: gotv_incidents id; Type: DEFAULT; Schema: public; Owner: - -- ALTER TABLE ONLY public.gotv_incidents ALTER COLUMN id SET DEFAULT nextval('public.gotv_incidents_id_seq'::regclass); -- -- Name: jobs id; Type: DEFAULT; Schema: public; Owner: - -- ALTER TABLE ONLY public.jobs ALTER COLUMN id SET DEFAULT nextval('public.jobs_id_seq'::regclass); -- -- Name: kpi_values id; Type: DEFAULT; Schema: public; Owner: - -- ALTER TABLE ONLY public.kpi_values ALTER COLUMN id SET DEFAULT nextval('public.kpi_values_id_seq'::regclass); -- -- Name: kpis id; Type: DEFAULT; Schema: public; Owner: - -- ALTER TABLE ONLY public.kpis ALTER COLUMN id SET DEFAULT nextval('public.kpis_id_seq'::regclass); -- -- Name: membership_plans id; Type: DEFAULT; Schema: public; Owner: - -- ALTER TABLE ONLY public.membership_plans ALTER COLUMN id SET DEFAULT nextval('public.membership_plans_id_seq'::regclass); -- -- Name: migrations id; Type: DEFAULT; Schema: public; Owner: - -- ALTER TABLE ONLY public.migrations ALTER COLUMN id SET DEFAULT nextval('public.migrations_id_seq'::regclass); -- -- Name: payment_gateways id; Type: DEFAULT; Schema: public; Owner: - -- ALTER TABLE ONLY public.payment_gateways ALTER COLUMN id SET DEFAULT nextval('public.payment_gateways_id_seq'::regclass); -- -- Name: permissions id; Type: DEFAULT; Schema: public; Owner: - -- ALTER TABLE ONLY public.permissions ALTER COLUMN id SET DEFAULT nextval('public.permissions_id_seq'::regclass); -- -- Name: personal_access_tokens id; Type: DEFAULT; Schema: public; Owner: - -- ALTER TABLE ONLY public.personal_access_tokens ALTER COLUMN id SET DEFAULT nextval('public.personal_access_tokens_id_seq'::regclass); -- -- Name: platform_activities id; Type: DEFAULT; Schema: public; Owner: - -- ALTER TABLE ONLY public.platform_activities ALTER COLUMN id SET DEFAULT nextval('public.platform_activities_id_seq'::regclass); -- -- Name: platform_payment_gateways id; Type: DEFAULT; Schema: public; Owner: - -- ALTER TABLE ONLY public.platform_payment_gateways ALTER COLUMN id SET DEFAULT nextval('public.platform_payment_gateways_id_seq'::regclass); -- -- Name: political_competitors id; Type: DEFAULT; Schema: public; Owner: - -- ALTER TABLE ONLY public.political_competitors ALTER COLUMN id SET DEFAULT nextval('public.political_competitors_id_seq'::regclass); -- -- Name: poll_results id; Type: DEFAULT; Schema: public; Owner: - -- ALTER TABLE ONLY public.poll_results ALTER COLUMN id SET DEFAULT nextval('public.poll_results_id_seq'::regclass); -- -- Name: polling_places id; Type: DEFAULT; Schema: public; Owner: - -- ALTER TABLE ONLY public.polling_places ALTER COLUMN id SET DEFAULT nextval('public.polling_places_id_seq'::regclass); -- -- Name: polling_station_turnout id; Type: DEFAULT; Schema: public; Owner: - -- ALTER TABLE ONLY public.polling_station_turnout ALTER COLUMN id SET DEFAULT nextval('public.polling_station_turnout_id_seq'::regclass); -- -- Name: polling_stations id; Type: DEFAULT; Schema: public; Owner: - -- ALTER TABLE ONLY public.polling_stations ALTER COLUMN id SET DEFAULT nextval('public.polling_stations_id_seq'::regclass); -- -- Name: popularity_metrics id; Type: DEFAULT; Schema: public; Owner: - -- ALTER TABLE ONLY public.popularity_metrics ALTER COLUMN id SET DEFAULT nextval('public.popularity_metrics_id_seq'::regclass); -- -- Name: popularity_polls id; Type: DEFAULT; Schema: public; Owner: - -- ALTER TABLE ONLY public.popularity_polls ALTER COLUMN id SET DEFAULT nextval('public.popularity_polls_id_seq'::regclass); -- -- Name: poster_campaigns id; Type: DEFAULT; Schema: public; Owner: - -- ALTER TABLE ONLY public.poster_campaigns ALTER COLUMN id SET DEFAULT nextval('public.poster_campaigns_id_seq'::regclass); -- -- Name: poster_qr_codes id; Type: DEFAULT; Schema: public; Owner: - -- ALTER TABLE ONLY public.poster_qr_codes ALTER COLUMN id SET DEFAULT nextval('public.poster_qr_codes_id_seq'::regclass); -- -- Name: poster_qr_scans id; Type: DEFAULT; Schema: public; Owner: - -- ALTER TABLE ONLY public.poster_qr_scans ALTER COLUMN id SET DEFAULT nextval('public.poster_qr_scans_id_seq'::regclass); -- -- Name: pqrs id; Type: DEFAULT; Schema: public; Owner: - -- ALTER TABLE ONLY public.pqrs ALTER COLUMN id SET DEFAULT nextval('public.pqrs_id_seq'::regclass); -- -- Name: pqrs_categories id; Type: DEFAULT; Schema: public; Owner: - -- ALTER TABLE ONLY public.pqrs_categories ALTER COLUMN id SET DEFAULT nextval('public.pqrs_categories_id_seq'::regclass); -- -- Name: predictive_variables id; Type: DEFAULT; Schema: public; Owner: - -- ALTER TABLE ONLY public.predictive_variables ALTER COLUMN id SET DEFAULT nextval('public.predictive_variables_id_seq'::regclass); -- -- Name: preliminary_results id; Type: DEFAULT; Schema: public; Owner: - -- ALTER TABLE ONLY public.preliminary_results ALTER COLUMN id SET DEFAULT nextval('public.preliminary_results_id_seq'::regclass); -- -- Name: proposal_amendments id; Type: DEFAULT; Schema: public; Owner: - -- ALTER TABLE ONLY public.proposal_amendments ALTER COLUMN id SET DEFAULT nextval('public.proposal_amendments_id_seq'::regclass); -- -- Name: proposal_categories id; Type: DEFAULT; Schema: public; Owner: - -- ALTER TABLE ONLY public.proposal_categories ALTER COLUMN id SET DEFAULT nextval('public.proposal_categories_id_seq'::regclass); -- -- Name: proposal_comments id; Type: DEFAULT; Schema: public; Owner: - -- ALTER TABLE ONLY public.proposal_comments ALTER COLUMN id SET DEFAULT nextval('public.proposal_comments_id_seq'::regclass); -- -- Name: proposal_supports id; Type: DEFAULT; Schema: public; Owner: - -- ALTER TABLE ONLY public.proposal_supports ALTER COLUMN id SET DEFAULT nextval('public.proposal_supports_id_seq'::regclass); -- -- Name: proposal_versions id; Type: DEFAULT; Schema: public; Owner: - -- ALTER TABLE ONLY public.proposal_versions ALTER COLUMN id SET DEFAULT nextval('public.proposal_versions_id_seq'::regclass); -- -- Name: proposals id; Type: DEFAULT; Schema: public; Owner: - -- ALTER TABLE ONLY public.proposals ALTER COLUMN id SET DEFAULT nextval('public.proposals_id_seq'::regclass); -- -- Name: public_surveys id; Type: DEFAULT; Schema: public; Owner: - -- ALTER TABLE ONLY public.public_surveys ALTER COLUMN id SET DEFAULT nextval('public.public_surveys_id_seq'::regclass); -- -- Name: qr_campaigns id; Type: DEFAULT; Schema: public; Owner: - -- ALTER TABLE ONLY public.qr_campaigns ALTER COLUMN id SET DEFAULT nextval('public.qr_campaigns_id_seq'::regclass); -- -- Name: qr_citizen_leads id; Type: DEFAULT; Schema: public; Owner: - -- ALTER TABLE ONLY public.qr_citizen_leads ALTER COLUMN id SET DEFAULT nextval('public.qr_citizen_leads_id_seq'::regclass); -- -- Name: qr_codes id; Type: DEFAULT; Schema: public; Owner: - -- ALTER TABLE ONLY public.qr_codes ALTER COLUMN id SET DEFAULT nextval('public.qr_codes_id_seq'::regclass); -- -- Name: qr_heatmap_data id; Type: DEFAULT; Schema: public; Owner: - -- ALTER TABLE ONLY public.qr_heatmap_data ALTER COLUMN id SET DEFAULT nextval('public.qr_heatmap_data_id_seq'::regclass); -- -- Name: qr_heatmap_zones id; Type: DEFAULT; Schema: public; Owner: - -- ALTER TABLE ONLY public.qr_heatmap_zones ALTER COLUMN id SET DEFAULT nextval('public.qr_heatmap_zones_id_seq'::regclass); -- -- Name: qr_hits id; Type: DEFAULT; Schema: public; Owner: - -- ALTER TABLE ONLY public.qr_hits ALTER COLUMN id SET DEFAULT nextval('public.qr_hits_id_seq'::regclass); -- -- Name: qr_lead_conversions id; Type: DEFAULT; Schema: public; Owner: - -- ALTER TABLE ONLY public.qr_lead_conversions ALTER COLUMN id SET DEFAULT nextval('public.qr_lead_conversions_id_seq'::regclass); -- -- Name: qr_lead_interactions id; Type: DEFAULT; Schema: public; Owner: - -- ALTER TABLE ONLY public.qr_lead_interactions ALTER COLUMN id SET DEFAULT nextval('public.qr_lead_interactions_id_seq'::regclass); -- -- Name: qr_posters id; Type: DEFAULT; Schema: public; Owner: - -- ALTER TABLE ONLY public.qr_posters ALTER COLUMN id SET DEFAULT nextval('public.qr_posters_id_seq'::regclass); -- -- Name: qr_scans id; Type: DEFAULT; Schema: public; Owner: - -- ALTER TABLE ONLY public.qr_scans ALTER COLUMN id SET DEFAULT nextval('public.qr_scans_id_seq'::regclass); -- -- Name: regional_interests id; Type: DEFAULT; Schema: public; Owner: - -- ALTER TABLE ONLY public.regional_interests ALTER COLUMN id SET DEFAULT nextval('public.regional_interests_id_seq'::regclass); -- -- Name: roles id; Type: DEFAULT; Schema: public; Owner: - -- ALTER TABLE ONLY public.roles ALTER COLUMN id SET DEFAULT nextval('public.roles_id_seq'::regclass); -- -- Name: security_alerts id; Type: DEFAULT; Schema: public; Owner: - -- ALTER TABLE ONLY public.security_alerts ALTER COLUMN id SET DEFAULT nextval('public.security_alerts_id_seq'::regclass); -- -- Name: social_accounts id; Type: DEFAULT; Schema: public; Owner: - -- ALTER TABLE ONLY public.social_accounts ALTER COLUMN id SET DEFAULT nextval('public.social_accounts_id_seq'::regclass); -- -- Name: social_alerts id; Type: DEFAULT; Schema: public; Owner: - -- ALTER TABLE ONLY public.social_alerts ALTER COLUMN id SET DEFAULT nextval('public.social_alerts_id_seq'::regclass); -- -- Name: social_comments id; Type: DEFAULT; Schema: public; Owner: - -- ALTER TABLE ONLY public.social_comments ALTER COLUMN id SET DEFAULT nextval('public.social_comments_id_seq'::regclass); -- -- Name: social_media_posts id; Type: DEFAULT; Schema: public; Owner: - -- ALTER TABLE ONLY public.social_media_posts ALTER COLUMN id SET DEFAULT nextval('public.social_media_posts_id_seq'::regclass); -- -- Name: social_posts id; Type: DEFAULT; Schema: public; Owner: - -- ALTER TABLE ONLY public.social_posts ALTER COLUMN id SET DEFAULT nextval('public.social_posts_id_seq'::regclass); -- -- Name: social_trends id; Type: DEFAULT; Schema: public; Owner: - -- ALTER TABLE ONLY public.social_trends ALTER COLUMN id SET DEFAULT nextval('public.social_trends_id_seq'::regclass); -- -- Name: states id; Type: DEFAULT; Schema: public; Owner: - -- ALTER TABLE ONLY public.states ALTER COLUMN id SET DEFAULT nextval('public.states_id_seq'::regclass); -- -- Name: street_surveys id; Type: DEFAULT; Schema: public; Owner: - -- ALTER TABLE ONLY public.street_surveys ALTER COLUMN id SET DEFAULT nextval('public.street_surveys_id_seq'::regclass); -- -- Name: subscription_payments id; Type: DEFAULT; Schema: public; Owner: - -- ALTER TABLE ONLY public.subscription_payments ALTER COLUMN id SET DEFAULT nextval('public.subscription_payments_id_seq'::regclass); -- -- Name: subscriptions id; Type: DEFAULT; Schema: public; Owner: - -- ALTER TABLE ONLY public.subscriptions ALTER COLUMN id SET DEFAULT nextval('public.subscriptions_id_seq'::regclass); -- -- Name: survey_analyses id; Type: DEFAULT; Schema: public; Owner: - -- ALTER TABLE ONLY public.survey_analyses ALTER COLUMN id SET DEFAULT nextval('public.survey_analyses_id_seq'::regclass); -- -- Name: survey_candidates id; Type: DEFAULT; Schema: public; Owner: - -- ALTER TABLE ONLY public.survey_candidates ALTER COLUMN id SET DEFAULT nextval('public.survey_candidates_id_seq'::regclass); -- -- Name: survey_concerns id; Type: DEFAULT; Schema: public; Owner: - -- ALTER TABLE ONLY public.survey_concerns ALTER COLUMN id SET DEFAULT nextval('public.survey_concerns_id_seq'::regclass); -- -- Name: survey_reasons id; Type: DEFAULT; Schema: public; Owner: - -- ALTER TABLE ONLY public.survey_reasons ALTER COLUMN id SET DEFAULT nextval('public.survey_reasons_id_seq'::regclass); -- -- Name: survey_responses id; Type: DEFAULT; Schema: public; Owner: - -- ALTER TABLE ONLY public.survey_responses ALTER COLUMN id SET DEFAULT nextval('public.survey_responses_id_seq'::regclass); -- -- Name: survey_templates id; Type: DEFAULT; Schema: public; Owner: - -- ALTER TABLE ONLY public.survey_templates ALTER COLUMN id SET DEFAULT nextval('public.survey_templates_id_seq'::regclass); -- -- Name: surveyor_activity_log id; Type: DEFAULT; Schema: public; Owner: - -- ALTER TABLE ONLY public.surveyor_activity_log ALTER COLUMN id SET DEFAULT nextval('public.surveyor_activity_log_id_seq'::regclass); -- -- Name: tasks id; Type: DEFAULT; Schema: public; Owner: - -- ALTER TABLE ONLY public.tasks ALTER COLUMN id SET DEFAULT nextval('public.tasks_id_seq'::regclass); -- -- Name: tenant_configurations id; Type: DEFAULT; Schema: public; Owner: - -- ALTER TABLE ONLY public.tenant_configurations ALTER COLUMN id SET DEFAULT nextval('public.tenant_configurations_id_seq'::regclass); -- -- Name: tenant_integrations id; Type: DEFAULT; Schema: public; Owner: - -- ALTER TABLE ONLY public.tenant_integrations ALTER COLUMN id SET DEFAULT nextval('public.tenant_integrations_id_seq'::regclass); -- -- Name: territories id; Type: DEFAULT; Schema: public; Owner: - -- ALTER TABLE ONLY public.territories ALTER COLUMN id SET DEFAULT nextval('public.territories_id_seq'::regclass); -- -- Name: territory_demographic_profiles id; Type: DEFAULT; Schema: public; Owner: - -- ALTER TABLE ONLY public.territory_demographic_profiles ALTER COLUMN id SET DEFAULT nextval('public.territory_demographic_profiles_id_seq'::regclass); -- -- Name: territory_visits id; Type: DEFAULT; Schema: public; Owner: - -- ALTER TABLE ONLY public.territory_visits ALTER COLUMN id SET DEFAULT nextval('public.territory_visits_id_seq'::regclass); -- -- Name: transactions id; Type: DEFAULT; Schema: public; Owner: - -- ALTER TABLE ONLY public.transactions ALTER COLUMN id SET DEFAULT nextval('public.transactions_id_seq'::regclass); -- -- Name: users id; Type: DEFAULT; Schema: public; Owner: - -- ALTER TABLE ONLY public.users ALTER COLUMN id SET DEFAULT nextval('public.users_id_seq'::regclass); -- -- Name: victory_predictions id; Type: DEFAULT; Schema: public; Owner: - -- ALTER TABLE ONLY public.victory_predictions ALTER COLUMN id SET DEFAULT nextval('public.victory_predictions_id_seq'::regclass); -- -- Name: volunteer_activities id; Type: DEFAULT; Schema: public; Owner: - -- ALTER TABLE ONLY public.volunteer_activities ALTER COLUMN id SET DEFAULT nextval('public.volunteer_activities_id_seq'::regclass); -- -- Name: volunteer_hours id; Type: DEFAULT; Schema: public; Owner: - -- ALTER TABLE ONLY public.volunteer_hours ALTER COLUMN id SET DEFAULT nextval('public.volunteer_hours_id_seq'::regclass); -- -- Name: volunteer_tasks id; Type: DEFAULT; Schema: public; Owner: - -- ALTER TABLE ONLY public.volunteer_tasks ALTER COLUMN id SET DEFAULT nextval('public.volunteer_tasks_id_seq'::regclass); -- -- Name: volunteer_teams id; Type: DEFAULT; Schema: public; Owner: - -- ALTER TABLE ONLY public.volunteer_teams ALTER COLUMN id SET DEFAULT nextval('public.volunteer_teams_id_seq'::regclass); -- -- Name: volunteers id; Type: DEFAULT; Schema: public; Owner: - -- ALTER TABLE ONLY public.volunteers ALTER COLUMN id SET DEFAULT nextval('public.volunteers_id_seq'::regclass); -- -- Name: voter_contacts id; Type: DEFAULT; Schema: public; Owner: - -- ALTER TABLE ONLY public.voter_contacts ALTER COLUMN id SET DEFAULT nextval('public.voter_contacts_id_seq'::regclass); -- -- Name: voters id; Type: DEFAULT; Schema: public; Owner: - -- ALTER TABLE ONLY public.voters ALTER COLUMN id SET DEFAULT nextval('public.voters_id_seq'::regclass); -- -- Name: webhook_events id; Type: DEFAULT; Schema: public; Owner: - -- ALTER TABLE ONLY public.webhook_events ALTER COLUMN id SET DEFAULT nextval('public.webhook_events_id_seq'::regclass); -- -- Name: whatsapp_auto_replies id; Type: DEFAULT; Schema: public; Owner: - -- ALTER TABLE ONLY public.whatsapp_auto_replies ALTER COLUMN id SET DEFAULT nextval('public.whatsapp_auto_replies_id_seq'::regclass); -- -- Name: whatsapp_campaigns id; Type: DEFAULT; Schema: public; Owner: - -- ALTER TABLE ONLY public.whatsapp_campaigns ALTER COLUMN id SET DEFAULT nextval('public.whatsapp_campaigns_id_seq'::regclass); -- -- Name: whatsapp_conversation_messages id; Type: DEFAULT; Schema: public; Owner: - -- ALTER TABLE ONLY public.whatsapp_conversation_messages ALTER COLUMN id SET DEFAULT nextval('public.whatsapp_conversation_messages_id_seq'::regclass); -- -- Name: whatsapp_conversations id; Type: DEFAULT; Schema: public; Owner: - -- ALTER TABLE ONLY public.whatsapp_conversations ALTER COLUMN id SET DEFAULT nextval('public.whatsapp_conversations_id_seq'::regclass); -- -- Name: whatsapp_messages id; Type: DEFAULT; Schema: public; Owner: - -- ALTER TABLE ONLY public.whatsapp_messages ALTER COLUMN id SET DEFAULT nextval('public.whatsapp_messages_id_seq'::regclass); -- -- Name: whatsapp_templates id; Type: DEFAULT; Schema: public; Owner: - -- ALTER TABLE ONLY public.whatsapp_templates ALTER COLUMN id SET DEFAULT nextval('public.whatsapp_templates_id_seq'::regclass); -- -- Name: active_sessions active_sessions_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.active_sessions ADD CONSTRAINT active_sessions_pkey PRIMARY KEY (id); -- -- Name: active_sessions active_sessions_session_id_unique; Type: CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.active_sessions ADD CONSTRAINT active_sessions_session_id_unique UNIQUE (session_id); -- -- Name: ai_contents ai_contents_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.ai_contents ADD CONSTRAINT ai_contents_pkey PRIMARY KEY (id); -- -- Name: ai_providers ai_providers_campaign_id_provider_unique; Type: CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.ai_providers ADD CONSTRAINT ai_providers_campaign_id_provider_unique UNIQUE (campaign_id, provider); -- -- Name: ai_providers ai_providers_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.ai_providers ADD CONSTRAINT ai_providers_pkey PRIMARY KEY (id); -- -- Name: alert_triggers alert_triggers_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.alert_triggers ADD CONSTRAINT alert_triggers_pkey PRIMARY KEY (id); -- -- Name: alerts alerts_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.alerts ADD CONSTRAINT alerts_pkey PRIMARY KEY (id); -- -- Name: audit_logs audit_logs_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.audit_logs ADD CONSTRAINT audit_logs_pkey PRIMARY KEY (id); -- -- Name: budget_categories budget_categories_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.budget_categories ADD CONSTRAINT budget_categories_pkey PRIMARY KEY (id); -- -- Name: cache_locks cache_locks_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.cache_locks ADD CONSTRAINT cache_locks_pkey PRIMARY KEY (key); -- -- Name: cache cache_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.cache ADD CONSTRAINT cache_pkey PRIMARY KEY (key); -- -- Name: call_center_calls call_center_calls_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.call_center_calls ADD CONSTRAINT call_center_calls_pkey PRIMARY KEY (id); -- -- Name: call_center_scripts call_center_scripts_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.call_center_scripts ADD CONSTRAINT call_center_scripts_pkey PRIMARY KEY (id); -- -- Name: call_scripts call_scripts_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.call_scripts ADD CONSTRAINT call_scripts_pkey PRIMARY KEY (id); -- -- Name: calls calls_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.calls ADD CONSTRAINT calls_pkey PRIMARY KEY (id); -- -- Name: campaign_funds campaign_funds_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.campaign_funds ADD CONSTRAINT campaign_funds_pkey PRIMARY KEY (id); -- -- Name: campaign_invitations campaign_invitations_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.campaign_invitations ADD CONSTRAINT campaign_invitations_pkey PRIMARY KEY (id); -- -- Name: campaign_invitations campaign_invitations_token_unique; Type: CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.campaign_invitations ADD CONSTRAINT campaign_invitations_token_unique UNIQUE (token); -- -- Name: campaign_user campaign_user_campaign_id_user_id_unique; Type: CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.campaign_user ADD CONSTRAINT campaign_user_campaign_id_user_id_unique UNIQUE (campaign_id, user_id); -- -- Name: campaign_user campaign_user_campaign_user_unique; Type: CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.campaign_user ADD CONSTRAINT campaign_user_campaign_user_unique UNIQUE (campaign_id, user_id); -- -- Name: campaign_user campaign_user_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.campaign_user ADD CONSTRAINT campaign_user_pkey PRIMARY KEY (id); -- -- Name: campaigns campaigns_email_unique; Type: CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.campaigns ADD CONSTRAINT campaigns_email_unique UNIQUE (email); -- -- Name: campaigns campaigns_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.campaigns ADD CONSTRAINT campaigns_pkey PRIMARY KEY (id); -- -- Name: campaigns campaigns_slug_unique; Type: CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.campaigns ADD CONSTRAINT campaigns_slug_unique UNIQUE (slug); -- -- Name: cities cities_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.cities ADD CONSTRAINT cities_pkey PRIMARY KEY (id); -- -- Name: citizen_priorities citizen_priorities_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.citizen_priorities ADD CONSTRAINT citizen_priorities_pkey PRIMARY KEY (id); -- -- Name: competitor_ad_snapshots competitor_ad_snapshots_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.competitor_ad_snapshots ADD CONSTRAINT competitor_ad_snapshots_pkey PRIMARY KEY (id); -- -- Name: competitor_comparisons competitor_comparisons_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.competitor_comparisons ADD CONSTRAINT competitor_comparisons_pkey PRIMARY KEY (id); -- -- Name: competitor_metric_snapshots competitor_metric_snapshots_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.competitor_metric_snapshots ADD CONSTRAINT competitor_metric_snapshots_pkey PRIMARY KEY (id); -- -- Name: confirmed_voters confirmed_voters_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.confirmed_voters ADD CONSTRAINT confirmed_voters_pkey PRIMARY KEY (id); -- -- Name: content_a_i_s content_a_i_s_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.content_a_i_s ADD CONSTRAINT content_a_i_s_pkey PRIMARY KEY (id); -- -- Name: content_generations content_generations_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.content_generations ADD CONSTRAINT content_generations_pkey PRIMARY KEY (id); -- -- Name: content_templates content_templates_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.content_templates ADD CONSTRAINT content_templates_pkey PRIMARY KEY (id); -- -- Name: countries countries_iso_code_unique; Type: CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.countries ADD CONSTRAINT countries_iso_code_unique UNIQUE (iso_code); -- -- Name: countries countries_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.countries ADD CONSTRAINT countries_pkey PRIMARY KEY (id); -- -- Name: dashboards dashboards_campaign_slug_unique; Type: CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.dashboards ADD CONSTRAINT dashboards_campaign_slug_unique UNIQUE (campaign_id, slug); -- -- Name: dashboards dashboards_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.dashboards ADD CONSTRAINT dashboards_pkey PRIMARY KEY (id); -- -- Name: debate_participants debate_participants_debate_id_user_id_unique; Type: CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.debate_participants ADD CONSTRAINT debate_participants_debate_id_user_id_unique UNIQUE (debate_id, user_id); -- -- Name: debate_participants debate_participants_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.debate_participants ADD CONSTRAINT debate_participants_pkey PRIMARY KEY (id); -- -- Name: debate_questions debate_questions_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.debate_questions ADD CONSTRAINT debate_questions_pkey PRIMARY KEY (id); -- -- Name: debate_responses debate_responses_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.debate_responses ADD CONSTRAINT debate_responses_pkey PRIMARY KEY (id); -- -- Name: debate_sessions debate_sessions_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.debate_sessions ADD CONSTRAINT debate_sessions_pkey PRIMARY KEY (id); -- -- Name: debates debates_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.debates ADD CONSTRAINT debates_pkey PRIMARY KEY (id); -- -- Name: demo_requests demo_requests_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.demo_requests ADD CONSTRAINT demo_requests_pkey PRIMARY KEY (id); -- -- Name: demo_requests demo_requests_token_unique; Type: CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.demo_requests ADD CONSTRAINT demo_requests_token_unique UNIQUE (token); -- -- Name: domains domains_domain_unique; Type: CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.domains ADD CONSTRAINT domains_domain_unique UNIQUE (domain); -- -- Name: domains domains_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.domains ADD CONSTRAINT domains_pkey PRIMARY KEY (id); -- -- Name: donations donations_campaign_receipt_unique; Type: CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.donations ADD CONSTRAINT donations_campaign_receipt_unique UNIQUE (campaign_id, receipt_number); -- -- Name: donations donations_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.donations ADD CONSTRAINT donations_pkey PRIMARY KEY (id); -- -- Name: donors donors_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.donors ADD CONSTRAINT donors_pkey PRIMARY KEY (id); -- -- Name: electoral_zones electoral_zones_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.electoral_zones ADD CONSTRAINT electoral_zones_pkey PRIMARY KEY (id); -- -- Name: email_campaigns email_campaigns_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.email_campaigns ADD CONSTRAINT email_campaigns_pkey PRIMARY KEY (id); -- -- Name: email_clicks email_clicks_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.email_clicks ADD CONSTRAINT email_clicks_pkey PRIMARY KEY (id); -- -- Name: email_sends email_sends_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.email_sends ADD CONSTRAINT email_sends_pkey PRIMARY KEY (id); -- -- Name: email_templates email_templates_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.email_templates ADD CONSTRAINT email_templates_pkey PRIMARY KEY (id); -- -- Name: event_attendees event_attendees_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.event_attendees ADD CONSTRAINT event_attendees_pkey PRIMARY KEY (id); -- -- Name: event_attendees event_attendees_qr_code_unique; Type: CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.event_attendees ADD CONSTRAINT event_attendees_qr_code_unique UNIQUE (qr_code); -- -- Name: event_registrations event_registrations_event_id_user_id_unique; Type: CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.event_registrations ADD CONSTRAINT event_registrations_event_id_user_id_unique UNIQUE (event_id, user_id); -- -- Name: event_registrations event_registrations_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.event_registrations ADD CONSTRAINT event_registrations_pkey PRIMARY KEY (id); -- -- Name: events events_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.events ADD CONSTRAINT events_pkey PRIMARY KEY (id); -- -- Name: failed_jobs failed_jobs_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.failed_jobs ADD CONSTRAINT failed_jobs_pkey PRIMARY KEY (id); -- -- Name: failed_jobs failed_jobs_uuid_unique; Type: CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.failed_jobs ADD CONSTRAINT failed_jobs_uuid_unique UNIQUE (uuid); -- -- Name: gotv_activities gotv_activities_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.gotv_activities ADD CONSTRAINT gotv_activities_pkey PRIMARY KEY (id); -- -- Name: gotv_brigades gotv_brigades_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.gotv_brigades ADD CONSTRAINT gotv_brigades_pkey PRIMARY KEY (id); -- -- Name: gotv_incidents gotv_incidents_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.gotv_incidents ADD CONSTRAINT gotv_incidents_pkey PRIMARY KEY (id); -- -- Name: job_batches job_batches_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.job_batches ADD CONSTRAINT job_batches_pkey PRIMARY KEY (id); -- -- Name: jobs jobs_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.jobs ADD CONSTRAINT jobs_pkey PRIMARY KEY (id); -- -- Name: kpi_values kpi_values_kpi_date_unique; Type: CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.kpi_values ADD CONSTRAINT kpi_values_kpi_date_unique UNIQUE (kpi_id, date); -- -- Name: kpi_values kpi_values_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.kpi_values ADD CONSTRAINT kpi_values_pkey PRIMARY KEY (id); -- -- Name: kpis kpis_campaign_slug_unique; Type: CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.kpis ADD CONSTRAINT kpis_campaign_slug_unique UNIQUE (campaign_id, slug); -- -- Name: kpis kpis_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.kpis ADD CONSTRAINT kpis_pkey PRIMARY KEY (id); -- -- Name: membership_plans membership_plans_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.membership_plans ADD CONSTRAINT membership_plans_pkey PRIMARY KEY (id); -- -- Name: membership_plans membership_plans_slug_unique; Type: CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.membership_plans ADD CONSTRAINT membership_plans_slug_unique UNIQUE (slug); -- -- Name: migrations migrations_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.migrations ADD CONSTRAINT migrations_pkey PRIMARY KEY (id); -- -- Name: model_has_permissions model_has_permissions_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.model_has_permissions ADD CONSTRAINT model_has_permissions_pkey PRIMARY KEY (permission_id, model_id, model_type); -- -- Name: model_has_roles model_has_roles_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.model_has_roles ADD CONSTRAINT model_has_roles_pkey PRIMARY KEY (role_id, model_id, model_type); -- -- Name: password_reset_tokens password_reset_tokens_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.password_reset_tokens ADD CONSTRAINT password_reset_tokens_pkey PRIMARY KEY (email); -- -- Name: payment_gateways payment_gateways_campaign_id_provider_unique; Type: CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.payment_gateways ADD CONSTRAINT payment_gateways_campaign_id_provider_unique UNIQUE (campaign_id, provider); -- -- Name: payment_gateways payment_gateways_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.payment_gateways ADD CONSTRAINT payment_gateways_pkey PRIMARY KEY (id); -- -- Name: permissions permissions_name_guard_name_unique; Type: CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.permissions ADD CONSTRAINT permissions_name_guard_name_unique UNIQUE (name, guard_name); -- -- Name: permissions permissions_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.permissions ADD CONSTRAINT permissions_pkey PRIMARY KEY (id); -- -- Name: personal_access_tokens personal_access_tokens_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.personal_access_tokens ADD CONSTRAINT personal_access_tokens_pkey PRIMARY KEY (id); -- -- Name: personal_access_tokens personal_access_tokens_token_unique; Type: CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.personal_access_tokens ADD CONSTRAINT personal_access_tokens_token_unique UNIQUE (token); -- -- Name: platform_activities platform_activities_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.platform_activities ADD CONSTRAINT platform_activities_pkey PRIMARY KEY (id); -- -- Name: platform_payment_gateways platform_payment_gateways_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.platform_payment_gateways ADD CONSTRAINT platform_payment_gateways_pkey PRIMARY KEY (id); -- -- Name: platform_payment_gateways platform_payment_gateways_provider_unique; Type: CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.platform_payment_gateways ADD CONSTRAINT platform_payment_gateways_provider_unique UNIQUE (provider); -- -- Name: political_competitors political_competitors_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.political_competitors ADD CONSTRAINT political_competitors_pkey PRIMARY KEY (id); -- -- Name: poll_results poll_competitor_unique; Type: CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.poll_results ADD CONSTRAINT poll_competitor_unique UNIQUE (popularity_poll_id, political_competitor_id); -- -- Name: poll_results poll_results_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.poll_results ADD CONSTRAINT poll_results_pkey PRIMARY KEY (id); -- -- Name: polling_places polling_places_code_unique; Type: CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.polling_places ADD CONSTRAINT polling_places_code_unique UNIQUE (code); -- -- Name: polling_places polling_places_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.polling_places ADD CONSTRAINT polling_places_pkey PRIMARY KEY (id); -- -- Name: polling_station_turnout polling_station_turnout_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.polling_station_turnout ADD CONSTRAINT polling_station_turnout_pkey PRIMARY KEY (id); -- -- Name: polling_stations polling_stations_campaign_code_unique; Type: CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.polling_stations ADD CONSTRAINT polling_stations_campaign_code_unique UNIQUE (campaign_id, code); -- -- Name: polling_stations polling_stations_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.polling_stations ADD CONSTRAINT polling_stations_pkey PRIMARY KEY (id); -- -- Name: popularity_metrics popularity_metrics_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.popularity_metrics ADD CONSTRAINT popularity_metrics_pkey PRIMARY KEY (id); -- -- Name: popularity_polls popularity_polls_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.popularity_polls ADD CONSTRAINT popularity_polls_pkey PRIMARY KEY (id); -- -- Name: poster_campaigns poster_campaigns_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.poster_campaigns ADD CONSTRAINT poster_campaigns_pkey PRIMARY KEY (id); -- -- Name: poster_qr_codes poster_qr_codes_code_unique; Type: CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.poster_qr_codes ADD CONSTRAINT poster_qr_codes_code_unique UNIQUE (code); -- -- Name: poster_qr_codes poster_qr_codes_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.poster_qr_codes ADD CONSTRAINT poster_qr_codes_pkey PRIMARY KEY (id); -- -- Name: poster_qr_scans poster_qr_scans_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.poster_qr_scans ADD CONSTRAINT poster_qr_scans_pkey PRIMARY KEY (id); -- -- Name: pqrs pqrs_campaign_ticket_unique; Type: CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.pqrs ADD CONSTRAINT pqrs_campaign_ticket_unique UNIQUE (campaign_id, ticket_number); -- -- Name: pqrs_categories pqrs_categories_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.pqrs_categories ADD CONSTRAINT pqrs_categories_pkey PRIMARY KEY (id); -- -- Name: pqrs pqrs_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.pqrs ADD CONSTRAINT pqrs_pkey PRIMARY KEY (id); -- -- Name: predictive_variables predictive_variables_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.predictive_variables ADD CONSTRAINT predictive_variables_pkey PRIMARY KEY (id); -- -- Name: preliminary_results preliminary_results_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.preliminary_results ADD CONSTRAINT preliminary_results_pkey PRIMARY KEY (id); -- -- Name: proposal_amendments proposal_amendments_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.proposal_amendments ADD CONSTRAINT proposal_amendments_pkey PRIMARY KEY (id); -- -- Name: proposal_categories proposal_categories_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.proposal_categories ADD CONSTRAINT proposal_categories_pkey PRIMARY KEY (id); -- -- Name: proposal_comments proposal_comments_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.proposal_comments ADD CONSTRAINT proposal_comments_pkey PRIMARY KEY (id); -- -- Name: proposal_supports proposal_supports_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.proposal_supports ADD CONSTRAINT proposal_supports_pkey PRIMARY KEY (id); -- -- Name: proposal_supports proposal_supports_proposal_id_user_id_unique; Type: CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.proposal_supports ADD CONSTRAINT proposal_supports_proposal_id_user_id_unique UNIQUE (proposal_id, user_id); -- -- Name: proposal_versions proposal_versions_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.proposal_versions ADD CONSTRAINT proposal_versions_pkey PRIMARY KEY (id); -- -- Name: proposals proposals_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.proposals ADD CONSTRAINT proposals_pkey PRIMARY KEY (id); -- -- Name: public_surveys public_surveys_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.public_surveys ADD CONSTRAINT public_surveys_pkey PRIMARY KEY (id); -- -- Name: public_surveys public_surveys_qr_code_unique; Type: CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.public_surveys ADD CONSTRAINT public_surveys_qr_code_unique UNIQUE (qr_code); -- -- Name: qr_campaigns qr_campaigns_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.qr_campaigns ADD CONSTRAINT qr_campaigns_pkey PRIMARY KEY (id); -- -- Name: qr_citizen_leads qr_citizen_leads_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.qr_citizen_leads ADD CONSTRAINT qr_citizen_leads_pkey PRIMARY KEY (id); -- -- Name: qr_codes qr_codes_code_unique; Type: CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.qr_codes ADD CONSTRAINT qr_codes_code_unique UNIQUE (code); -- -- Name: qr_codes qr_codes_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.qr_codes ADD CONSTRAINT qr_codes_pkey PRIMARY KEY (id); -- -- Name: qr_heatmap_data qr_heatmap_data_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.qr_heatmap_data ADD CONSTRAINT qr_heatmap_data_pkey PRIMARY KEY (id); -- -- Name: qr_heatmap_zones qr_heatmap_zones_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.qr_heatmap_zones ADD CONSTRAINT qr_heatmap_zones_pkey PRIMARY KEY (id); -- -- Name: qr_hits qr_hits_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.qr_hits ADD CONSTRAINT qr_hits_pkey PRIMARY KEY (id); -- -- Name: qr_lead_conversions qr_lead_conversions_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.qr_lead_conversions ADD CONSTRAINT qr_lead_conversions_pkey PRIMARY KEY (id); -- -- Name: qr_lead_interactions qr_lead_interactions_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.qr_lead_interactions ADD CONSTRAINT qr_lead_interactions_pkey PRIMARY KEY (id); -- -- Name: qr_posters qr_posters_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.qr_posters ADD CONSTRAINT qr_posters_pkey PRIMARY KEY (id); -- -- Name: qr_posters qr_posters_qr_code_unique; Type: CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.qr_posters ADD CONSTRAINT qr_posters_qr_code_unique UNIQUE (qr_code); -- -- Name: qr_posters qr_posters_short_url_unique; Type: CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.qr_posters ADD CONSTRAINT qr_posters_short_url_unique UNIQUE (short_url); -- -- Name: qr_scans qr_scans_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.qr_scans ADD CONSTRAINT qr_scans_pkey PRIMARY KEY (id); -- -- Name: regional_interests regional_interests_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.regional_interests ADD CONSTRAINT regional_interests_pkey PRIMARY KEY (id); -- -- Name: role_has_permissions role_has_permissions_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.role_has_permissions ADD CONSTRAINT role_has_permissions_pkey PRIMARY KEY (permission_id, role_id); -- -- Name: roles roles_name_guard_name_unique; Type: CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.roles ADD CONSTRAINT roles_name_guard_name_unique UNIQUE (name, guard_name); -- -- Name: roles roles_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.roles ADD CONSTRAINT roles_pkey PRIMARY KEY (id); -- -- Name: security_alerts security_alerts_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.security_alerts ADD CONSTRAINT security_alerts_pkey PRIMARY KEY (id); -- -- Name: sessions sessions_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.sessions ADD CONSTRAINT sessions_pkey PRIMARY KEY (id); -- -- Name: social_accounts social_accounts_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.social_accounts ADD CONSTRAINT social_accounts_pkey PRIMARY KEY (id); -- -- Name: social_accounts social_accounts_political_competitor_id_platform_handle_unique; Type: CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.social_accounts ADD CONSTRAINT social_accounts_political_competitor_id_platform_handle_unique UNIQUE (political_competitor_id, platform, handle); -- -- Name: social_alerts social_alerts_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.social_alerts ADD CONSTRAINT social_alerts_pkey PRIMARY KEY (id); -- -- Name: social_comments social_comments_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.social_comments ADD CONSTRAINT social_comments_pkey PRIMARY KEY (id); -- -- Name: social_media_posts social_media_posts_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.social_media_posts ADD CONSTRAINT social_media_posts_pkey PRIMARY KEY (id); -- -- Name: social_media_posts social_media_posts_platform_post_unique; Type: CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.social_media_posts ADD CONSTRAINT social_media_posts_platform_post_unique UNIQUE (platform, post_id); -- -- Name: social_posts social_posts_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.social_posts ADD CONSTRAINT social_posts_pkey PRIMARY KEY (id); -- -- Name: social_posts social_posts_post_id_unique; Type: CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.social_posts ADD CONSTRAINT social_posts_post_id_unique UNIQUE (post_id); -- -- Name: social_trends social_trends_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.social_trends ADD CONSTRAINT social_trends_pkey PRIMARY KEY (id); -- -- Name: states states_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.states ADD CONSTRAINT states_pkey PRIMARY KEY (id); -- -- Name: street_surveys street_surveys_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.street_surveys ADD CONSTRAINT street_surveys_pkey PRIMARY KEY (id); -- -- Name: subscription_payments subscription_payments_gateway_ref_unique; Type: CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.subscription_payments ADD CONSTRAINT subscription_payments_gateway_ref_unique UNIQUE (gateway, gateway_reference); -- -- Name: subscription_payments subscription_payments_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.subscription_payments ADD CONSTRAINT subscription_payments_pkey PRIMARY KEY (id); -- -- Name: subscriptions subscriptions_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.subscriptions ADD CONSTRAINT subscriptions_pkey PRIMARY KEY (id); -- -- Name: subscriptions subscriptions_reference_unique; Type: CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.subscriptions ADD CONSTRAINT subscriptions_reference_unique UNIQUE (reference); -- -- Name: survey_analyses survey_analyses_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.survey_analyses ADD CONSTRAINT survey_analyses_pkey PRIMARY KEY (id); -- -- Name: survey_candidates survey_candidates_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.survey_candidates ADD CONSTRAINT survey_candidates_pkey PRIMARY KEY (id); -- -- Name: survey_concerns survey_concerns_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.survey_concerns ADD CONSTRAINT survey_concerns_pkey PRIMARY KEY (id); -- -- Name: survey_reasons survey_reasons_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.survey_reasons ADD CONSTRAINT survey_reasons_pkey PRIMARY KEY (id); -- -- Name: survey_responses survey_responses_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.survey_responses ADD CONSTRAINT survey_responses_pkey PRIMARY KEY (id); -- -- Name: survey_templates survey_templates_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.survey_templates ADD CONSTRAINT survey_templates_pkey PRIMARY KEY (id); -- -- Name: surveyor_activity_log surveyor_activity_log_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.surveyor_activity_log ADD CONSTRAINT surveyor_activity_log_pkey PRIMARY KEY (id); -- -- Name: tasks tasks_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.tasks ADD CONSTRAINT tasks_pkey PRIMARY KEY (id); -- -- Name: tenant_configurations tenant_configurations_campaign_key_unique; Type: CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.tenant_configurations ADD CONSTRAINT tenant_configurations_campaign_key_unique UNIQUE (campaign_id, config_key); -- -- Name: tenant_configurations tenant_configurations_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.tenant_configurations ADD CONSTRAINT tenant_configurations_pkey PRIMARY KEY (id); -- -- Name: tenant_integrations tenant_integrations_campaign_name_unique; Type: CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.tenant_integrations ADD CONSTRAINT tenant_integrations_campaign_name_unique UNIQUE (campaign_id, integration_name); -- -- Name: tenant_integrations tenant_integrations_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.tenant_integrations ADD CONSTRAINT tenant_integrations_pkey PRIMARY KEY (id); -- -- Name: territories territories_campaign_code_unique; Type: CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.territories ADD CONSTRAINT territories_campaign_code_unique UNIQUE (campaign_id, code); -- -- Name: territories territories_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.territories ADD CONSTRAINT territories_pkey PRIMARY KEY (id); -- -- Name: territory_demographic_profiles territory_demographic_profiles_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.territory_demographic_profiles ADD CONSTRAINT territory_demographic_profiles_pkey PRIMARY KEY (id); -- -- Name: territory_visits territory_visits_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.territory_visits ADD CONSTRAINT territory_visits_pkey PRIMARY KEY (id); -- -- Name: transactions transactions_campaign_ref_unique; Type: CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.transactions ADD CONSTRAINT transactions_campaign_ref_unique UNIQUE (campaign_id, reference); -- -- Name: transactions transactions_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.transactions ADD CONSTRAINT transactions_pkey PRIMARY KEY (id); -- -- Name: users users_email_unique; Type: CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.users ADD CONSTRAINT users_email_unique UNIQUE (email); -- -- Name: users users_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.users ADD CONSTRAINT users_pkey PRIMARY KEY (id); -- -- Name: victory_predictions victory_predictions_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.victory_predictions ADD CONSTRAINT victory_predictions_pkey PRIMARY KEY (id); -- -- Name: volunteer_activities volunteer_activities_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.volunteer_activities ADD CONSTRAINT volunteer_activities_pkey PRIMARY KEY (id); -- -- Name: volunteer_hours volunteer_hours_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.volunteer_hours ADD CONSTRAINT volunteer_hours_pkey PRIMARY KEY (id); -- -- Name: volunteer_tasks volunteer_tasks_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.volunteer_tasks ADD CONSTRAINT volunteer_tasks_pkey PRIMARY KEY (id); -- -- Name: volunteer_teams volunteer_teams_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.volunteer_teams ADD CONSTRAINT volunteer_teams_pkey PRIMARY KEY (id); -- -- Name: volunteers volunteers_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.volunteers ADD CONSTRAINT volunteers_pkey PRIMARY KEY (id); -- -- Name: voter_contacts voter_contacts_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.voter_contacts ADD CONSTRAINT voter_contacts_pkey PRIMARY KEY (id); -- -- Name: voters voters_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.voters ADD CONSTRAINT voters_pkey PRIMARY KEY (id); -- -- Name: webhook_events webhook_events_gateway_event_unique; Type: CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.webhook_events ADD CONSTRAINT webhook_events_gateway_event_unique UNIQUE (gateway, event_id); -- -- Name: webhook_events webhook_events_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.webhook_events ADD CONSTRAINT webhook_events_pkey PRIMARY KEY (id); -- -- Name: whatsapp_auto_replies whatsapp_auto_replies_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.whatsapp_auto_replies ADD CONSTRAINT whatsapp_auto_replies_pkey PRIMARY KEY (id); -- -- Name: whatsapp_campaigns whatsapp_campaigns_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.whatsapp_campaigns ADD CONSTRAINT whatsapp_campaigns_pkey PRIMARY KEY (id); -- -- Name: whatsapp_conversation_messages whatsapp_conversation_messages_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.whatsapp_conversation_messages ADD CONSTRAINT whatsapp_conversation_messages_pkey PRIMARY KEY (id); -- -- Name: whatsapp_conversations whatsapp_conversations_campaign_phone_unique; Type: CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.whatsapp_conversations ADD CONSTRAINT whatsapp_conversations_campaign_phone_unique UNIQUE (campaign_id, phone); -- -- Name: whatsapp_conversations whatsapp_conversations_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.whatsapp_conversations ADD CONSTRAINT whatsapp_conversations_pkey PRIMARY KEY (id); -- -- Name: whatsapp_messages whatsapp_messages_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.whatsapp_messages ADD CONSTRAINT whatsapp_messages_pkey PRIMARY KEY (id); -- -- Name: whatsapp_templates whatsapp_templates_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.whatsapp_templates ADD CONSTRAINT whatsapp_templates_pkey PRIMARY KEY (id); -- -- Name: active_sessions_last_activity_index; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX active_sessions_last_activity_index ON public.active_sessions USING btree (last_activity); -- -- Name: active_sessions_user_id_last_activity_index; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX active_sessions_user_id_last_activity_index ON public.active_sessions USING btree (user_id, last_activity); -- -- Name: ai_providers_campaign_id_index; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX ai_providers_campaign_id_index ON public.ai_providers USING btree (campaign_id); -- -- Name: alert_triggers_alert_index; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX alert_triggers_alert_index ON public.alert_triggers USING btree (alert_id, triggered_at); -- -- Name: audit_logs_action_created_at_index; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX audit_logs_action_created_at_index ON public.audit_logs USING btree (action, created_at); -- -- Name: audit_logs_campaign_id_created_at_index; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX audit_logs_campaign_id_created_at_index ON public.audit_logs USING btree (campaign_id, created_at); -- -- Name: audit_logs_category_created_at_index; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX audit_logs_category_created_at_index ON public.audit_logs USING btree (category, created_at); -- -- Name: audit_logs_is_suspicious_index; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX audit_logs_is_suspicious_index ON public.audit_logs USING btree (is_suspicious); -- -- Name: audit_logs_model_type_model_id_index; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX audit_logs_model_type_model_id_index ON public.audit_logs USING btree (model_type, model_id); -- -- Name: audit_logs_requires_review_index; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX audit_logs_requires_review_index ON public.audit_logs USING btree (requires_review); -- -- Name: audit_logs_user_id_created_at_index; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX audit_logs_user_id_created_at_index ON public.audit_logs USING btree (user_id, created_at); -- -- Name: call_center_calls_caller_id_call_date_index; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX call_center_calls_caller_id_call_date_index ON public.call_center_calls USING btree (caller_id, call_date); -- -- Name: call_center_calls_campaign_id_call_date_index; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX call_center_calls_campaign_id_call_date_index ON public.call_center_calls USING btree (campaign_id, call_date); -- -- Name: call_center_calls_follow_up_required_follow_up_date_index; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX call_center_calls_follow_up_required_follow_up_date_index ON public.call_center_calls USING btree (follow_up_required, follow_up_date); -- -- Name: call_center_calls_status_call_date_index; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX call_center_calls_status_call_date_index ON public.call_center_calls USING btree (status, call_date); -- -- Name: call_center_calls_voter_id_index; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX call_center_calls_voter_id_index ON public.call_center_calls USING btree (voter_id); -- -- Name: call_center_scripts_campaign_id_is_active_index; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX call_center_scripts_campaign_id_is_active_index ON public.call_center_scripts USING btree (campaign_id, is_active); -- -- Name: calls_campaign_id_called_at_index; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX calls_campaign_id_called_at_index ON public.calls USING btree (campaign_id, called_at); -- -- Name: calls_outcome_index; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX calls_outcome_index ON public.calls USING btree (outcome); -- -- Name: campaign_funds_campaign_id_is_active_index; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX campaign_funds_campaign_id_is_active_index ON public.campaign_funds USING btree (campaign_id, is_active); -- -- Name: campaign_funds_fund_type_priority_index; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX campaign_funds_fund_type_priority_index ON public.campaign_funds USING btree (fund_type, priority); -- -- Name: campaigns_city_id_index; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX campaigns_city_id_index ON public.campaigns USING btree (city_id); -- -- Name: campaigns_country_id_index; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX campaigns_country_id_index ON public.campaigns USING btree (country_id); -- -- Name: campaigns_demo_expires_at_index; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX campaigns_demo_expires_at_index ON public.campaigns USING btree (demo_expires_at); -- -- Name: campaigns_environment_status_index; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX campaigns_environment_status_index ON public.campaigns USING btree (environment_type, status); -- -- Name: campaigns_owner_id_index; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX campaigns_owner_id_index ON public.campaigns USING btree (owner_id); -- -- Name: campaigns_state_id_index; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX campaigns_state_id_index ON public.campaigns USING btree (state_id); -- -- Name: cas_lookup_idx; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX cas_lookup_idx ON public.competitor_ad_snapshots USING btree (campaign_id, political_competitor_id, fetched_at); -- -- Name: cities_code_index; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX cities_code_index ON public.cities USING btree (code); -- -- Name: cities_is_active_index; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX cities_is_active_index ON public.cities USING btree (is_active); -- -- Name: cities_state_id_index; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX cities_state_id_index ON public.cities USING btree (state_id); -- -- Name: citizen_priorities_campaign_index; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX citizen_priorities_campaign_index ON public.citizen_priorities USING btree (campaign_id, measured_date); -- -- Name: cms_lookup_idx; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX cms_lookup_idx ON public.competitor_metric_snapshots USING btree (campaign_id, platform, fetched_at); -- -- Name: competitor_comparisons_campaign_index; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX competitor_comparisons_campaign_index ON public.competitor_comparisons USING btree (campaign_id, comparison_date); -- -- Name: confirmed_voters_campaign_voted_index; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX confirmed_voters_campaign_voted_index ON public.confirmed_voters USING btree (campaign_id, voted); -- -- Name: confirmed_voters_station_index; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX confirmed_voters_station_index ON public.confirmed_voters USING btree (polling_station_id); -- -- Name: content_a_i_s_campaign_id_status_index; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX content_a_i_s_campaign_id_status_index ON public.content_a_i_s USING btree (campaign_id, status); -- -- Name: content_a_i_s_content_type_index; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX content_a_i_s_content_type_index ON public.content_a_i_s USING btree (content_type); -- -- Name: content_a_i_s_created_at_index; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX content_a_i_s_created_at_index ON public.content_a_i_s USING btree (created_at); -- -- Name: countries_is_active_index; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX countries_is_active_index ON public.countries USING btree (is_active); -- -- Name: countries_iso_code_index; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX countries_iso_code_index ON public.countries USING btree (iso_code); -- -- Name: debate_questions_category_index; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX debate_questions_category_index ON public.debate_questions USING btree (category); -- -- Name: debate_questions_debate_id_index; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX debate_questions_debate_id_index ON public.debate_questions USING btree (debate_id); -- -- Name: debate_sessions_campaign_id_index; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX debate_sessions_campaign_id_index ON public.debate_sessions USING btree (campaign_id); -- -- Name: demo_requests_campaign_id_index; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX demo_requests_campaign_id_index ON public.demo_requests USING btree (campaign_id); -- -- Name: demo_requests_converted_at_index; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX demo_requests_converted_at_index ON public.demo_requests USING btree (converted_at); -- -- Name: demo_requests_email_index; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX demo_requests_email_index ON public.demo_requests USING btree (email); -- -- Name: demo_requests_expires_at_index; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX demo_requests_expires_at_index ON public.demo_requests USING btree (expires_at); -- -- Name: demo_requests_provisioning_status_index; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX demo_requests_provisioning_status_index ON public.demo_requests USING btree (provisioning_status); -- -- Name: demo_requests_status_index; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX demo_requests_status_index ON public.demo_requests USING btree (status); -- -- Name: donations_campaign_id_donated_at_index; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX donations_campaign_id_donated_at_index ON public.donations USING btree (campaign_id, donated_at); -- -- Name: donations_status_index; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX donations_status_index ON public.donations USING btree (status); -- -- Name: donors_campaign_id_index; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX donors_campaign_id_index ON public.donors USING btree (campaign_id); -- -- Name: electoral_zones_campaign_id_support_level_index; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX electoral_zones_campaign_id_support_level_index ON public.electoral_zones USING btree (campaign_id, support_level); -- -- Name: email_campaigns_campaign_id_status_index; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX email_campaigns_campaign_id_status_index ON public.email_campaigns USING btree (campaign_id, status); -- -- Name: email_clicks_send_index; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX email_clicks_send_index ON public.email_clicks USING btree (email_send_id); -- -- Name: email_sends_email_campaign_id_status_index; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX email_sends_email_campaign_id_status_index ON public.email_sends USING btree (email_campaign_id, status); -- -- Name: email_sends_message_id_index; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX email_sends_message_id_index ON public.email_sends USING btree (message_id); -- -- Name: email_sends_status_index; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX email_sends_status_index ON public.email_sends USING btree (status); -- -- Name: email_templates_campaign_id_index; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX email_templates_campaign_id_index ON public.email_templates USING btree (campaign_id); -- -- Name: event_attendees_event_id_status_index; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX event_attendees_event_id_status_index ON public.event_attendees USING btree (event_id, status); -- -- Name: event_registrations_attended_check_in_time_index; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX event_registrations_attended_check_in_time_index ON public.event_registrations USING btree (attended, check_in_time); -- -- Name: event_registrations_event_id_status_index; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX event_registrations_event_id_status_index ON public.event_registrations USING btree (event_id, status); -- -- Name: event_registrations_user_id_registration_date_index; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX event_registrations_user_id_registration_date_index ON public.event_registrations USING btree (user_id, registration_date); -- -- Name: events_campaign_id_start_at_index; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX events_campaign_id_start_at_index ON public.events USING btree (campaign_id, start_at); -- -- Name: gotv_activities_campaign_at_index; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX gotv_activities_campaign_at_index ON public.gotv_activities USING btree (campaign_id, activity_at); -- -- Name: gotv_brigades_campaign_id_index; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX gotv_brigades_campaign_id_index ON public.gotv_brigades USING btree (campaign_id); -- -- Name: gotv_incidents_campaign_status_index; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX gotv_incidents_campaign_status_index ON public.gotv_incidents USING btree (campaign_id, status); -- -- Name: jobs_queue_index; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX jobs_queue_index ON public.jobs USING btree (queue); -- -- Name: model_has_permissions_model_id_model_type_index; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX model_has_permissions_model_id_model_type_index ON public.model_has_permissions USING btree (model_id, model_type); -- -- Name: model_has_roles_model_id_model_type_index; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX model_has_roles_model_id_model_type_index ON public.model_has_roles USING btree (model_id, model_type); -- -- Name: payment_gateways_campaign_id_is_active_index; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX payment_gateways_campaign_id_is_active_index ON public.payment_gateways USING btree (campaign_id, is_active); -- -- Name: personal_access_tokens_expires_at_index; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX personal_access_tokens_expires_at_index ON public.personal_access_tokens USING btree (expires_at); -- -- Name: personal_access_tokens_tokenable_type_tokenable_id_index; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX personal_access_tokens_tokenable_type_tokenable_id_index ON public.personal_access_tokens USING btree (tokenable_type, tokenable_id); -- -- Name: platform_activities_model_index; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX platform_activities_model_index ON public.platform_activities USING btree (model_type, model_id); -- -- Name: platform_activities_user_index; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX platform_activities_user_index ON public.platform_activities USING btree (user_id, created_at); -- -- Name: political_competitors_campaign_id_index; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX political_competitors_campaign_id_index ON public.political_competitors USING btree (campaign_id); -- -- Name: political_competitors_is_main_candidate_index; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX political_competitors_is_main_candidate_index ON public.political_competitors USING btree (is_main_candidate); -- -- Name: political_competitors_level_index; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX political_competitors_level_index ON public.political_competitors USING btree (level); -- -- Name: polling_places_electoral_zone_id_index; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX polling_places_electoral_zone_id_index ON public.polling_places USING btree (electoral_zone_id); -- -- Name: polling_stations_campaign_id_index; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX polling_stations_campaign_id_index ON public.polling_stations USING btree (campaign_id); -- -- Name: popularity_metrics_campaign_date_index; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX popularity_metrics_campaign_date_index ON public.popularity_metrics USING btree (campaign_id, metric_date); -- -- Name: popularity_polls_campaign_id_index; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX popularity_polls_campaign_id_index ON public.popularity_polls USING btree (campaign_id); -- -- Name: popularity_polls_poll_date_index; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX popularity_polls_poll_date_index ON public.popularity_polls USING btree (poll_date); -- -- Name: poster_campaigns_campaign_id_index; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX poster_campaigns_campaign_id_index ON public.poster_campaigns USING btree (campaign_id); -- -- Name: poster_qr_codes_campaign_id_index; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX poster_qr_codes_campaign_id_index ON public.poster_qr_codes USING btree (campaign_id); -- -- Name: poster_qr_scans_campaign_scanned_index; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX poster_qr_scans_campaign_scanned_index ON public.poster_qr_scans USING btree (campaign_id, scanned_at); -- -- Name: poster_qr_scans_code_index; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX poster_qr_scans_code_index ON public.poster_qr_scans USING btree (poster_qr_code_id); -- -- Name: pqrs_assigned_to_index; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX pqrs_assigned_to_index ON public.pqrs USING btree (assigned_to); -- -- Name: pqrs_campaign_status_index; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX pqrs_campaign_status_index ON public.pqrs USING btree (campaign_id, status); -- -- Name: pqrs_categories_campaign_id_index; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX pqrs_categories_campaign_id_index ON public.pqrs_categories USING btree (campaign_id); -- -- Name: preliminary_results_campaign_index; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX preliminary_results_campaign_index ON public.preliminary_results USING btree (campaign_id); -- -- Name: proposal_amendments_proposal_index; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX proposal_amendments_proposal_index ON public.proposal_amendments USING btree (proposal_id); -- -- Name: proposal_versions_proposal_id_index; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX proposal_versions_proposal_id_index ON public.proposal_versions USING btree (proposal_id); -- -- Name: proposals_campaign_id_category_index; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX proposals_campaign_id_category_index ON public.proposals USING btree (campaign_id, category); -- -- Name: pst_campaign_check_index; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX pst_campaign_check_index ON public.polling_station_turnout USING btree (campaign_id, check_time); -- -- Name: public_surveys_campaign_id_index; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX public_surveys_campaign_id_index ON public.public_surveys USING btree (campaign_id); -- -- Name: qlc_campaign_type_index; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX qlc_campaign_type_index ON public.qr_lead_conversions USING btree (campaign_id, conversion_type); -- -- Name: qli_lead_index; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX qli_lead_index ON public.qr_lead_interactions USING btree (qr_citizen_lead_id); -- -- Name: qr_campaigns_campaign_id_index; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX qr_campaigns_campaign_id_index ON public.qr_campaigns USING btree (campaign_id); -- -- Name: qr_citizen_leads_campaign_index; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX qr_citizen_leads_campaign_index ON public.qr_citizen_leads USING btree (campaign_id); -- -- Name: qr_citizen_leads_document_index; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX qr_citizen_leads_document_index ON public.qr_citizen_leads USING btree (campaign_id, document_number); -- -- Name: qr_citizen_leads_phone_index; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX qr_citizen_leads_phone_index ON public.qr_citizen_leads USING btree (campaign_id, phone); -- -- Name: qr_codes_campaign_id_index; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX qr_codes_campaign_id_index ON public.qr_codes USING btree (campaign_id); -- -- Name: qr_heatmap_data_campaign_id_latitude_longitude_index; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX qr_heatmap_data_campaign_id_latitude_longitude_index ON public.qr_heatmap_data USING btree (campaign_id, latitude, longitude); -- -- Name: qr_heatmap_data_intensity_score_index; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX qr_heatmap_data_intensity_score_index ON public.qr_heatmap_data USING btree (intensity_score); -- -- Name: qr_heatmap_data_zone_neighborhood_index; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX qr_heatmap_data_zone_neighborhood_index ON public.qr_heatmap_data USING btree (zone, neighborhood); -- -- Name: qr_heatmap_zones_campaign_id_city_id_index; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX qr_heatmap_zones_campaign_id_city_id_index ON public.qr_heatmap_zones USING btree (campaign_id, city_id); -- -- Name: qr_hits_campaign_occurred_index; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX qr_hits_campaign_occurred_index ON public.qr_hits USING btree (campaign_id, occurred_at); -- -- Name: qr_posters_campaign_id_is_active_index; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX qr_posters_campaign_id_is_active_index ON public.qr_posters USING btree (campaign_id, is_active); -- -- Name: qr_posters_city_id_is_active_index; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX qr_posters_city_id_is_active_index ON public.qr_posters USING btree (city_id, is_active); -- -- Name: qr_posters_qr_code_index; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX qr_posters_qr_code_index ON public.qr_posters USING btree (qr_code); -- -- Name: qr_scans_campaign_id_scanned_at_index; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX qr_scans_campaign_id_scanned_at_index ON public.qr_scans USING btree (campaign_id, scanned_at); -- -- Name: qr_scans_qr_poster_id_scanned_at_index; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX qr_scans_qr_poster_id_scanned_at_index ON public.qr_scans USING btree (qr_poster_id, scanned_at); -- -- Name: qr_scans_scan_latitude_scan_longitude_index; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX qr_scans_scan_latitude_scan_longitude_index ON public.qr_scans USING btree (scan_latitude, scan_longitude); -- -- Name: qr_scans_sentiment_index; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX qr_scans_sentiment_index ON public.qr_scans USING btree (sentiment); -- -- Name: qr_scans_would_vote_index; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX qr_scans_would_vote_index ON public.qr_scans USING btree (would_vote); -- -- Name: regional_interests_campaign_index; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX regional_interests_campaign_index ON public.regional_interests USING btree (campaign_id); -- -- Name: security_alerts_alert_type_index; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX security_alerts_alert_type_index ON public.security_alerts USING btree (alert_type); -- -- Name: security_alerts_status_severity_created_at_index; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX security_alerts_status_severity_created_at_index ON public.security_alerts USING btree (status, severity, created_at); -- -- Name: sessions_last_activity_index; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX sessions_last_activity_index ON public.sessions USING btree (last_activity); -- -- Name: sessions_user_id_index; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX sessions_user_id_index ON public.sessions USING btree (user_id); -- -- Name: social_accounts_last_scraped_at_index; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX social_accounts_last_scraped_at_index ON public.social_accounts USING btree (last_scraped_at); -- -- Name: social_accounts_platform_index; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX social_accounts_platform_index ON public.social_accounts USING btree (platform); -- -- Name: social_alerts_created_at_index; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX social_alerts_created_at_index ON public.social_alerts USING btree (created_at); -- -- Name: social_alerts_political_competitor_id_status_index; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX social_alerts_political_competitor_id_status_index ON public.social_alerts USING btree (political_competitor_id, status); -- -- Name: social_alerts_severity_index; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX social_alerts_severity_index ON public.social_alerts USING btree (severity); -- -- Name: social_alerts_type_index; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX social_alerts_type_index ON public.social_alerts USING btree (type); -- -- Name: social_comments_campaign_index; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX social_comments_campaign_index ON public.social_comments USING btree (campaign_id, commented_at); -- -- Name: social_media_posts_campaign_posted_index; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX social_media_posts_campaign_posted_index ON public.social_media_posts USING btree (campaign_id, posted_at); -- -- Name: social_posts_ai_sentiment_index; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX social_posts_ai_sentiment_index ON public.social_posts USING btree (ai_sentiment); -- -- Name: social_posts_engagement_rate_index; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX social_posts_engagement_rate_index ON public.social_posts USING btree (engagement_rate); -- -- Name: social_posts_platform_index; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX social_posts_platform_index ON public.social_posts USING btree (platform); -- -- Name: social_posts_political_competitor_id_published_at_index; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX social_posts_political_competitor_id_published_at_index ON public.social_posts USING btree (political_competitor_id, published_at); -- -- Name: social_posts_published_at_index; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX social_posts_published_at_index ON public.social_posts USING btree (published_at); -- -- Name: social_trends_keyword_trend_date_index; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX social_trends_keyword_trend_date_index ON public.social_trends USING btree (keyword, trend_date); -- -- Name: social_trends_political_competitor_id_index; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX social_trends_political_competitor_id_index ON public.social_trends USING btree (political_competitor_id); -- -- Name: social_trends_trend_date_index; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX social_trends_trend_date_index ON public.social_trends USING btree (trend_date); -- -- Name: social_trends_volume_index; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX social_trends_volume_index ON public.social_trends USING btree (volume); -- -- Name: states_code_index; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX states_code_index ON public.states USING btree (code); -- -- Name: states_country_id_index; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX states_country_id_index ON public.states USING btree (country_id); -- -- Name: states_is_active_index; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX states_is_active_index ON public.states USING btree (is_active); -- -- Name: street_surveys_campaign_id_index; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX street_surveys_campaign_id_index ON public.street_surveys USING btree (campaign_id); -- -- Name: street_surveys_country_id_state_id_city_id_index; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX street_surveys_country_id_state_id_city_id_index ON public.street_surveys USING btree (country_id, state_id, city_id); -- -- Name: street_surveys_is_active_start_date_end_date_index; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX street_surveys_is_active_start_date_end_date_index ON public.street_surveys USING btree (is_active, start_date, end_date); -- -- Name: subscription_payments_processed_at_index; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX subscription_payments_processed_at_index ON public.subscription_payments USING btree (processed_at); -- -- Name: subscription_payments_sub_status_index; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX subscription_payments_sub_status_index ON public.subscription_payments USING btree (subscription_id, status); -- -- Name: subscriptions_campaign_id_index; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX subscriptions_campaign_id_index ON public.subscriptions USING btree (campaign_id); -- -- Name: subscriptions_status_ends_at_index; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX subscriptions_status_ends_at_index ON public.subscriptions USING btree (status, ends_at); -- -- Name: survey_analyses_survey_index; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX survey_analyses_survey_index ON public.survey_analyses USING btree (survey_id); -- -- Name: survey_candidates_survey_index; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX survey_candidates_survey_index ON public.survey_candidates USING btree (survey_id); -- -- Name: survey_concerns_concern_priority_index; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX survey_concerns_concern_priority_index ON public.survey_concerns USING btree (concern, priority); -- -- Name: survey_reasons_survey_index; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX survey_reasons_survey_index ON public.survey_reasons USING btree (survey_id); -- -- Name: survey_responses_country_id_state_id_city_id_index; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX survey_responses_country_id_state_id_city_id_index ON public.survey_responses USING btree (country_id, state_id, city_id); -- -- Name: survey_responses_preferred_candidate_id_index; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX survey_responses_preferred_candidate_id_index ON public.survey_responses USING btree (preferred_candidate_id); -- -- Name: survey_responses_respondent_age_range_index; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX survey_responses_respondent_age_range_index ON public.survey_responses USING btree (respondent_age_range); -- -- Name: survey_responses_respondent_gender_index; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX survey_responses_respondent_gender_index ON public.survey_responses USING btree (respondent_gender); -- -- Name: survey_responses_street_survey_id_created_at_index; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX survey_responses_street_survey_id_created_at_index ON public.survey_responses USING btree (street_survey_id, created_at); -- -- Name: survey_templates_campaign_id_is_active_index; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX survey_templates_campaign_id_is_active_index ON public.survey_templates USING btree (campaign_id, is_active); -- -- Name: surveyor_activity_log_surveyor_id_created_at_index; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX surveyor_activity_log_surveyor_id_created_at_index ON public.surveyor_activity_log USING btree (surveyor_id, created_at); -- -- Name: tasks_assigned_to_status_index; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX tasks_assigned_to_status_index ON public.tasks USING btree (assigned_to, status); -- -- Name: tasks_campaign_id_status_index; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX tasks_campaign_id_status_index ON public.tasks USING btree (campaign_id, status); -- -- Name: tasks_due_date_index; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX tasks_due_date_index ON public.tasks USING btree (due_date); -- -- Name: tdp_campaign_id_index; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX tdp_campaign_id_index ON public.territory_demographic_profiles USING btree (campaign_id); -- -- Name: territories_campaign_id_index; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX territories_campaign_id_index ON public.territories USING btree (campaign_id); -- -- Name: territories_parent_id_index; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX territories_parent_id_index ON public.territories USING btree (parent_id); -- -- Name: territory_visits_campaign_id_index; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX territory_visits_campaign_id_index ON public.territory_visits USING btree (campaign_id); -- -- Name: territory_visits_visited_at_index; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX territory_visits_visited_at_index ON public.territory_visits USING btree (visited_at); -- -- Name: transactions_campaign_date_index; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX transactions_campaign_date_index ON public.transactions USING btree (campaign_id, date); -- -- Name: victory_predictions_campaign_id_index; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX victory_predictions_campaign_id_index ON public.victory_predictions USING btree (campaign_id); -- -- Name: victory_predictions_prediction_date_index; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX victory_predictions_prediction_date_index ON public.victory_predictions USING btree (prediction_date); -- -- Name: volunteer_activities_campaign_index; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX volunteer_activities_campaign_index ON public.volunteer_activities USING btree (campaign_id, started_at); -- -- Name: volunteer_hours_campaign_id_user_id_date_index; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX volunteer_hours_campaign_id_user_id_date_index ON public.volunteer_hours USING btree (campaign_id, user_id, date); -- -- Name: volunteer_hours_date_index; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX volunteer_hours_date_index ON public.volunteer_hours USING btree (date); -- -- Name: volunteer_tasks_campaign_id_status_index; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX volunteer_tasks_campaign_id_status_index ON public.volunteer_tasks USING btree (campaign_id, status); -- -- Name: volunteer_tasks_volunteer_id_index; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX volunteer_tasks_volunteer_id_index ON public.volunteer_tasks USING btree (volunteer_id); -- -- Name: volunteers_campaign_id_status_index; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX volunteers_campaign_id_status_index ON public.volunteers USING btree (campaign_id, status); -- -- Name: voter_contacts_voter_id_contacted_at_index; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX voter_contacts_voter_id_contacted_at_index ON public.voter_contacts USING btree (voter_id, contacted_at); -- -- Name: voters_campaign_id_support_level_index; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX voters_campaign_id_support_level_index ON public.voters USING btree (campaign_id, support_level); -- -- Name: voters_voting_likelihood_index; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX voters_voting_likelihood_index ON public.voters USING btree (voting_likelihood); -- -- Name: wcm_conversation_index; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX wcm_conversation_index ON public.whatsapp_conversation_messages USING btree (whatsapp_conversation_id); -- -- Name: webhook_events_created_at_index; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX webhook_events_created_at_index ON public.webhook_events USING btree (created_at); -- -- Name: webhook_events_gateway_processed_index; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX webhook_events_gateway_processed_index ON public.webhook_events USING btree (gateway, processed); -- -- Name: whatsapp_auto_replies_campaign_index; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX whatsapp_auto_replies_campaign_index ON public.whatsapp_auto_replies USING btree (campaign_id, is_active); -- -- Name: whatsapp_campaigns_campaign_status_index; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX whatsapp_campaigns_campaign_status_index ON public.whatsapp_campaigns USING btree (campaign_id, status); -- -- Name: whatsapp_conversations_last_msg_index; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX whatsapp_conversations_last_msg_index ON public.whatsapp_conversations USING btree (campaign_id, last_message_at); -- -- Name: whatsapp_messages_campaign_status_index; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX whatsapp_messages_campaign_status_index ON public.whatsapp_messages USING btree (campaign_id, status); -- -- Name: whatsapp_messages_message_id_index; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX whatsapp_messages_message_id_index ON public.whatsapp_messages USING btree (message_id); -- -- Name: whatsapp_templates_campaign_id_index; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX whatsapp_templates_campaign_id_index ON public.whatsapp_templates USING btree (campaign_id); -- -- Name: active_sessions active_sessions_campaign_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.active_sessions ADD CONSTRAINT active_sessions_campaign_id_foreign FOREIGN KEY (campaign_id) REFERENCES public.campaigns(id) ON DELETE CASCADE; -- -- Name: active_sessions active_sessions_user_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.active_sessions ADD CONSTRAINT active_sessions_user_id_foreign FOREIGN KEY (user_id) REFERENCES public.users(id) ON DELETE CASCADE; -- -- Name: ai_contents ai_contents_campaign_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.ai_contents ADD CONSTRAINT ai_contents_campaign_id_foreign FOREIGN KEY (campaign_id) REFERENCES public.campaigns(id) ON DELETE CASCADE; -- -- Name: ai_contents ai_contents_user_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.ai_contents ADD CONSTRAINT ai_contents_user_id_foreign FOREIGN KEY (user_id) REFERENCES public.users(id) ON DELETE CASCADE; -- -- Name: ai_providers ai_providers_campaign_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.ai_providers ADD CONSTRAINT ai_providers_campaign_id_foreign FOREIGN KEY (campaign_id) REFERENCES public.campaigns(id) ON DELETE CASCADE; -- -- Name: alert_triggers alert_triggers_alert_foreign; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.alert_triggers ADD CONSTRAINT alert_triggers_alert_foreign FOREIGN KEY (alert_id) REFERENCES public.alerts(id) ON DELETE CASCADE; -- -- Name: alert_triggers alert_triggers_campaign_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.alert_triggers ADD CONSTRAINT alert_triggers_campaign_id_foreign FOREIGN KEY (campaign_id) REFERENCES public.campaigns(id) ON DELETE CASCADE; -- -- Name: alerts alerts_campaign_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.alerts ADD CONSTRAINT alerts_campaign_id_foreign FOREIGN KEY (campaign_id) REFERENCES public.campaigns(id) ON DELETE CASCADE; -- -- Name: alerts alerts_kpi_foreign; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.alerts ADD CONSTRAINT alerts_kpi_foreign FOREIGN KEY (kpi_id) REFERENCES public.kpis(id) ON DELETE CASCADE; -- -- Name: audit_logs audit_logs_campaign_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.audit_logs ADD CONSTRAINT audit_logs_campaign_id_foreign FOREIGN KEY (campaign_id) REFERENCES public.campaigns(id) ON DELETE CASCADE; -- -- Name: audit_logs audit_logs_reviewed_by_foreign; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.audit_logs ADD CONSTRAINT audit_logs_reviewed_by_foreign FOREIGN KEY (reviewed_by) REFERENCES public.users(id); -- -- Name: audit_logs audit_logs_user_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.audit_logs ADD CONSTRAINT audit_logs_user_id_foreign FOREIGN KEY (user_id) REFERENCES public.users(id) ON DELETE SET NULL; -- -- Name: budget_categories budget_categories_campaign_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.budget_categories ADD CONSTRAINT budget_categories_campaign_id_foreign FOREIGN KEY (campaign_id) REFERENCES public.campaigns(id) ON DELETE CASCADE; -- -- Name: call_center_calls call_center_calls_caller_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.call_center_calls ADD CONSTRAINT call_center_calls_caller_id_foreign FOREIGN KEY (caller_id) REFERENCES public.users(id) ON DELETE CASCADE; -- -- Name: call_center_calls call_center_calls_campaign_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.call_center_calls ADD CONSTRAINT call_center_calls_campaign_id_foreign FOREIGN KEY (campaign_id) REFERENCES public.campaigns(id) ON DELETE CASCADE; -- -- Name: call_center_calls call_center_calls_script_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.call_center_calls ADD CONSTRAINT call_center_calls_script_id_foreign FOREIGN KEY (script_id) REFERENCES public.call_center_scripts(id) ON DELETE CASCADE; -- -- Name: call_center_calls call_center_calls_voter_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.call_center_calls ADD CONSTRAINT call_center_calls_voter_id_foreign FOREIGN KEY (voter_id) REFERENCES public.voters(id) ON DELETE SET NULL; -- -- Name: call_center_scripts call_center_scripts_campaign_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.call_center_scripts ADD CONSTRAINT call_center_scripts_campaign_id_foreign FOREIGN KEY (campaign_id) REFERENCES public.campaigns(id) ON DELETE CASCADE; -- -- Name: call_scripts call_scripts_campaign_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.call_scripts ADD CONSTRAINT call_scripts_campaign_id_foreign FOREIGN KEY (campaign_id) REFERENCES public.campaigns(id) ON DELETE CASCADE; -- -- Name: calls calls_call_script_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.calls ADD CONSTRAINT calls_call_script_id_foreign FOREIGN KEY (call_script_id) REFERENCES public.call_scripts(id) ON DELETE SET NULL; -- -- Name: calls calls_caller_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.calls ADD CONSTRAINT calls_caller_id_foreign FOREIGN KEY (caller_id) REFERENCES public.users(id) ON DELETE SET NULL; -- -- Name: calls calls_campaign_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.calls ADD CONSTRAINT calls_campaign_id_foreign FOREIGN KEY (campaign_id) REFERENCES public.campaigns(id) ON DELETE CASCADE; -- -- Name: campaign_funds campaign_funds_campaign_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.campaign_funds ADD CONSTRAINT campaign_funds_campaign_id_foreign FOREIGN KEY (campaign_id) REFERENCES public.campaigns(id) ON DELETE CASCADE; -- -- Name: campaign_invitations campaign_invitations_campaign_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.campaign_invitations ADD CONSTRAINT campaign_invitations_campaign_id_foreign FOREIGN KEY (campaign_id) REFERENCES public.campaigns(id) ON DELETE CASCADE; -- -- Name: campaign_invitations campaign_invitations_invited_by_foreign; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.campaign_invitations ADD CONSTRAINT campaign_invitations_invited_by_foreign FOREIGN KEY (invited_by) REFERENCES public.users(id) ON DELETE CASCADE; -- -- Name: campaign_user campaign_user_campaign_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.campaign_user ADD CONSTRAINT campaign_user_campaign_id_foreign FOREIGN KEY (campaign_id) REFERENCES public.campaigns(id) ON DELETE CASCADE; -- -- Name: campaign_user campaign_user_user_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.campaign_user ADD CONSTRAINT campaign_user_user_id_foreign FOREIGN KEY (user_id) REFERENCES public.users(id) ON DELETE CASCADE; -- -- Name: campaigns campaigns_city_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.campaigns ADD CONSTRAINT campaigns_city_id_foreign FOREIGN KEY (city_id) REFERENCES public.cities(id) ON DELETE SET NULL; -- -- Name: campaigns campaigns_country_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.campaigns ADD CONSTRAINT campaigns_country_id_foreign FOREIGN KEY (country_id) REFERENCES public.countries(id) ON DELETE SET NULL; -- -- Name: campaigns campaigns_owner_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.campaigns ADD CONSTRAINT campaigns_owner_id_foreign FOREIGN KEY (owner_id) REFERENCES public.users(id) ON DELETE SET NULL; -- -- Name: campaigns campaigns_state_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.campaigns ADD CONSTRAINT campaigns_state_id_foreign FOREIGN KEY (state_id) REFERENCES public.states(id) ON DELETE SET NULL; -- -- Name: cities cities_state_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.cities ADD CONSTRAINT cities_state_id_foreign FOREIGN KEY (state_id) REFERENCES public.states(id) ON DELETE CASCADE; -- -- Name: citizen_priorities citizen_priorities_campaign_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.citizen_priorities ADD CONSTRAINT citizen_priorities_campaign_id_foreign FOREIGN KEY (campaign_id) REFERENCES public.campaigns(id) ON DELETE CASCADE; -- -- Name: competitor_ad_snapshots competitor_ad_snapshots_campaign_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.competitor_ad_snapshots ADD CONSTRAINT competitor_ad_snapshots_campaign_id_foreign FOREIGN KEY (campaign_id) REFERENCES public.campaigns(id) ON DELETE CASCADE; -- -- Name: competitor_ad_snapshots competitor_ad_snapshots_political_competitor_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.competitor_ad_snapshots ADD CONSTRAINT competitor_ad_snapshots_political_competitor_id_foreign FOREIGN KEY (political_competitor_id) REFERENCES public.political_competitors(id) ON DELETE CASCADE; -- -- Name: competitor_comparisons competitor_comparisons_campaign_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.competitor_comparisons ADD CONSTRAINT competitor_comparisons_campaign_id_foreign FOREIGN KEY (campaign_id) REFERENCES public.campaigns(id) ON DELETE CASCADE; -- -- Name: competitor_metric_snapshots competitor_metric_snapshots_campaign_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.competitor_metric_snapshots ADD CONSTRAINT competitor_metric_snapshots_campaign_id_foreign FOREIGN KEY (campaign_id) REFERENCES public.campaigns(id) ON DELETE CASCADE; -- -- Name: competitor_metric_snapshots competitor_metric_snapshots_political_competitor_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.competitor_metric_snapshots ADD CONSTRAINT competitor_metric_snapshots_political_competitor_id_foreign FOREIGN KEY (political_competitor_id) REFERENCES public.political_competitors(id) ON DELETE CASCADE; -- -- Name: confirmed_voters confirmed_voters_campaign_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.confirmed_voters ADD CONSTRAINT confirmed_voters_campaign_id_foreign FOREIGN KEY (campaign_id) REFERENCES public.campaigns(id) ON DELETE CASCADE; -- -- Name: confirmed_voters confirmed_voters_station_foreign; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.confirmed_voters ADD CONSTRAINT confirmed_voters_station_foreign FOREIGN KEY (polling_station_id) REFERENCES public.polling_stations(id) ON DELETE SET NULL; -- -- Name: confirmed_voters confirmed_voters_territory_foreign; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.confirmed_voters ADD CONSTRAINT confirmed_voters_territory_foreign FOREIGN KEY (territory_id) REFERENCES public.territories(id) ON DELETE SET NULL; -- -- Name: content_a_i_s content_a_i_s_ai_provider_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.content_a_i_s ADD CONSTRAINT content_a_i_s_ai_provider_id_foreign FOREIGN KEY (ai_provider_id) REFERENCES public.ai_providers(id) ON DELETE SET NULL; -- -- Name: content_a_i_s content_a_i_s_campaign_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.content_a_i_s ADD CONSTRAINT content_a_i_s_campaign_id_foreign FOREIGN KEY (campaign_id) REFERENCES public.campaigns(id) ON DELETE CASCADE; -- -- Name: content_generations content_generations_ai_content_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.content_generations ADD CONSTRAINT content_generations_ai_content_id_foreign FOREIGN KEY (ai_content_id) REFERENCES public.ai_contents(id) ON DELETE CASCADE; -- -- Name: content_generations content_generations_content_template_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.content_generations ADD CONSTRAINT content_generations_content_template_id_foreign FOREIGN KEY (content_template_id) REFERENCES public.content_templates(id) ON DELETE SET NULL; -- -- Name: content_generations content_generations_user_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.content_generations ADD CONSTRAINT content_generations_user_id_foreign FOREIGN KEY (user_id) REFERENCES public.users(id) ON DELETE CASCADE; -- -- Name: dashboards dashboards_campaign_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.dashboards ADD CONSTRAINT dashboards_campaign_id_foreign FOREIGN KEY (campaign_id) REFERENCES public.campaigns(id) ON DELETE CASCADE; -- -- Name: debate_participants debate_participants_debate_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.debate_participants ADD CONSTRAINT debate_participants_debate_id_foreign FOREIGN KEY (debate_id) REFERENCES public.debates(id) ON DELETE CASCADE; -- -- Name: debate_participants debate_participants_user_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.debate_participants ADD CONSTRAINT debate_participants_user_id_foreign FOREIGN KEY (user_id) REFERENCES public.users(id) ON DELETE CASCADE; -- -- Name: debate_questions debate_questions_debate_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.debate_questions ADD CONSTRAINT debate_questions_debate_id_foreign FOREIGN KEY (debate_id) REFERENCES public.debates(id) ON DELETE CASCADE; -- -- Name: debate_responses debate_responses_debate_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.debate_responses ADD CONSTRAINT debate_responses_debate_id_foreign FOREIGN KEY (debate_id) REFERENCES public.debates(id) ON DELETE CASCADE; -- -- Name: debate_responses debate_responses_debate_question_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.debate_responses ADD CONSTRAINT debate_responses_debate_question_id_foreign FOREIGN KEY (debate_question_id) REFERENCES public.debate_questions(id) ON DELETE CASCADE; -- -- Name: debate_responses debate_responses_user_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.debate_responses ADD CONSTRAINT debate_responses_user_id_foreign FOREIGN KEY (user_id) REFERENCES public.users(id) ON DELETE CASCADE; -- -- Name: debate_sessions debate_sessions_campaign_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.debate_sessions ADD CONSTRAINT debate_sessions_campaign_id_foreign FOREIGN KEY (campaign_id) REFERENCES public.campaigns(id) ON DELETE CASCADE; -- -- Name: debate_sessions debate_sessions_debate_question_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.debate_sessions ADD CONSTRAINT debate_sessions_debate_question_id_foreign FOREIGN KEY (debate_question_id) REFERENCES public.debate_questions(id); -- -- Name: debate_sessions debate_sessions_user_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.debate_sessions ADD CONSTRAINT debate_sessions_user_id_foreign FOREIGN KEY (user_id) REFERENCES public.users(id) ON DELETE CASCADE; -- -- Name: debates debates_campaign_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.debates ADD CONSTRAINT debates_campaign_id_foreign FOREIGN KEY (campaign_id) REFERENCES public.campaigns(id) ON DELETE CASCADE; -- -- Name: demo_requests demo_requests_campaign_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.demo_requests ADD CONSTRAINT demo_requests_campaign_id_foreign FOREIGN KEY (campaign_id) REFERENCES public.campaigns(id) ON DELETE SET NULL; -- -- Name: demo_requests demo_requests_converted_subscription_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.demo_requests ADD CONSTRAINT demo_requests_converted_subscription_id_foreign FOREIGN KEY (converted_subscription_id) REFERENCES public.subscriptions(id) ON DELETE SET NULL; -- -- Name: demo_requests demo_requests_user_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.demo_requests ADD CONSTRAINT demo_requests_user_id_foreign FOREIGN KEY (user_id) REFERENCES public.users(id) ON DELETE SET NULL; -- -- Name: domains domains_tenant_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.domains ADD CONSTRAINT domains_tenant_id_foreign FOREIGN KEY (tenant_id) REFERENCES public.campaigns(id) ON DELETE CASCADE; -- -- Name: donations donations_campaign_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.donations ADD CONSTRAINT donations_campaign_id_foreign FOREIGN KEY (campaign_id) REFERENCES public.campaigns(id) ON DELETE CASCADE; -- -- Name: donations donations_donor_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.donations ADD CONSTRAINT donations_donor_id_foreign FOREIGN KEY (donor_id) REFERENCES public.donors(id) ON DELETE SET NULL; -- -- Name: donors donors_campaign_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.donors ADD CONSTRAINT donors_campaign_id_foreign FOREIGN KEY (campaign_id) REFERENCES public.campaigns(id) ON DELETE CASCADE; -- -- Name: electoral_zones electoral_zones_campaign_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.electoral_zones ADD CONSTRAINT electoral_zones_campaign_id_foreign FOREIGN KEY (campaign_id) REFERENCES public.campaigns(id) ON DELETE CASCADE; -- -- Name: electoral_zones electoral_zones_city_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.electoral_zones ADD CONSTRAINT electoral_zones_city_id_foreign FOREIGN KEY (city_id) REFERENCES public.cities(id); -- -- Name: email_campaigns email_campaigns_campaign_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.email_campaigns ADD CONSTRAINT email_campaigns_campaign_id_foreign FOREIGN KEY (campaign_id) REFERENCES public.campaigns(id) ON DELETE CASCADE; -- -- Name: email_clicks email_clicks_campaign_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.email_clicks ADD CONSTRAINT email_clicks_campaign_id_foreign FOREIGN KEY (campaign_id) REFERENCES public.campaigns(id) ON DELETE CASCADE; -- -- Name: email_clicks email_clicks_send_foreign; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.email_clicks ADD CONSTRAINT email_clicks_send_foreign FOREIGN KEY (email_send_id) REFERENCES public.email_sends(id) ON DELETE CASCADE; -- -- Name: email_sends email_sends_email_campaign_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.email_sends ADD CONSTRAINT email_sends_email_campaign_id_foreign FOREIGN KEY (email_campaign_id) REFERENCES public.email_campaigns(id) ON DELETE CASCADE; -- -- Name: email_templates email_templates_campaign_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.email_templates ADD CONSTRAINT email_templates_campaign_id_foreign FOREIGN KEY (campaign_id) REFERENCES public.campaigns(id) ON DELETE CASCADE; -- -- Name: event_attendees event_attendees_event_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.event_attendees ADD CONSTRAINT event_attendees_event_id_foreign FOREIGN KEY (event_id) REFERENCES public.events(id) ON DELETE CASCADE; -- -- Name: event_registrations event_registrations_event_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.event_registrations ADD CONSTRAINT event_registrations_event_id_foreign FOREIGN KEY (event_id) REFERENCES public.events(id) ON DELETE CASCADE; -- -- Name: event_registrations event_registrations_user_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.event_registrations ADD CONSTRAINT event_registrations_user_id_foreign FOREIGN KEY (user_id) REFERENCES public.users(id) ON DELETE CASCADE; -- -- Name: events events_campaign_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.events ADD CONSTRAINT events_campaign_id_foreign FOREIGN KEY (campaign_id) REFERENCES public.campaigns(id) ON DELETE CASCADE; -- -- Name: gotv_activities gotv_activities_brigade_foreign; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.gotv_activities ADD CONSTRAINT gotv_activities_brigade_foreign FOREIGN KEY (gotv_brigade_id) REFERENCES public.gotv_brigades(id) ON DELETE SET NULL; -- -- Name: gotv_activities gotv_activities_campaign_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.gotv_activities ADD CONSTRAINT gotv_activities_campaign_id_foreign FOREIGN KEY (campaign_id) REFERENCES public.campaigns(id) ON DELETE CASCADE; -- -- Name: gotv_activities gotv_activities_station_foreign; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.gotv_activities ADD CONSTRAINT gotv_activities_station_foreign FOREIGN KEY (polling_station_id) REFERENCES public.polling_stations(id) ON DELETE SET NULL; -- -- Name: gotv_activities gotv_activities_voter_foreign; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.gotv_activities ADD CONSTRAINT gotv_activities_voter_foreign FOREIGN KEY (confirmed_voter_id) REFERENCES public.confirmed_voters(id) ON DELETE CASCADE; -- -- Name: gotv_brigades gotv_brigades_campaign_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.gotv_brigades ADD CONSTRAINT gotv_brigades_campaign_id_foreign FOREIGN KEY (campaign_id) REFERENCES public.campaigns(id) ON DELETE CASCADE; -- -- Name: gotv_brigades gotv_brigades_territory_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.gotv_brigades ADD CONSTRAINT gotv_brigades_territory_id_foreign FOREIGN KEY (territory_id) REFERENCES public.territories(id) ON DELETE SET NULL; -- -- Name: gotv_incidents gotv_incidents_campaign_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.gotv_incidents ADD CONSTRAINT gotv_incidents_campaign_id_foreign FOREIGN KEY (campaign_id) REFERENCES public.campaigns(id) ON DELETE CASCADE; -- -- Name: gotv_incidents gotv_incidents_station_foreign; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.gotv_incidents ADD CONSTRAINT gotv_incidents_station_foreign FOREIGN KEY (polling_station_id) REFERENCES public.polling_stations(id) ON DELETE SET NULL; -- -- Name: kpi_values kpi_values_campaign_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.kpi_values ADD CONSTRAINT kpi_values_campaign_id_foreign FOREIGN KEY (campaign_id) REFERENCES public.campaigns(id) ON DELETE CASCADE; -- -- Name: kpi_values kpi_values_kpi_foreign; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.kpi_values ADD CONSTRAINT kpi_values_kpi_foreign FOREIGN KEY (kpi_id) REFERENCES public.kpis(id) ON DELETE CASCADE; -- -- Name: kpis kpis_campaign_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.kpis ADD CONSTRAINT kpis_campaign_id_foreign FOREIGN KEY (campaign_id) REFERENCES public.campaigns(id) ON DELETE CASCADE; -- -- Name: model_has_permissions model_has_permissions_permission_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.model_has_permissions ADD CONSTRAINT model_has_permissions_permission_id_foreign FOREIGN KEY (permission_id) REFERENCES public.permissions(id) ON DELETE CASCADE; -- -- Name: model_has_roles model_has_roles_role_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.model_has_roles ADD CONSTRAINT model_has_roles_role_id_foreign FOREIGN KEY (role_id) REFERENCES public.roles(id) ON DELETE CASCADE; -- -- Name: payment_gateways payment_gateways_campaign_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.payment_gateways ADD CONSTRAINT payment_gateways_campaign_id_foreign FOREIGN KEY (campaign_id) REFERENCES public.campaigns(id) ON DELETE CASCADE; -- -- Name: platform_activities platform_activities_campaign_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.platform_activities ADD CONSTRAINT platform_activities_campaign_id_foreign FOREIGN KEY (campaign_id) REFERENCES public.campaigns(id) ON DELETE SET NULL; -- -- Name: political_competitors political_competitors_campaign_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.political_competitors ADD CONSTRAINT political_competitors_campaign_id_foreign FOREIGN KEY (campaign_id) REFERENCES public.campaigns(id) ON DELETE CASCADE; -- -- Name: poll_results poll_results_political_competitor_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.poll_results ADD CONSTRAINT poll_results_political_competitor_id_foreign FOREIGN KEY (political_competitor_id) REFERENCES public.political_competitors(id) ON DELETE CASCADE; -- -- Name: poll_results poll_results_popularity_poll_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.poll_results ADD CONSTRAINT poll_results_popularity_poll_id_foreign FOREIGN KEY (popularity_poll_id) REFERENCES public.popularity_polls(id) ON DELETE CASCADE; -- -- Name: polling_places polling_places_electoral_zone_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.polling_places ADD CONSTRAINT polling_places_electoral_zone_id_foreign FOREIGN KEY (electoral_zone_id) REFERENCES public.electoral_zones(id) ON DELETE CASCADE; -- -- Name: polling_stations polling_stations_campaign_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.polling_stations ADD CONSTRAINT polling_stations_campaign_id_foreign FOREIGN KEY (campaign_id) REFERENCES public.campaigns(id) ON DELETE CASCADE; -- -- Name: polling_stations polling_stations_territory_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.polling_stations ADD CONSTRAINT polling_stations_territory_id_foreign FOREIGN KEY (territory_id) REFERENCES public.territories(id) ON DELETE SET NULL; -- -- Name: popularity_metrics popularity_metrics_campaign_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.popularity_metrics ADD CONSTRAINT popularity_metrics_campaign_id_foreign FOREIGN KEY (campaign_id) REFERENCES public.campaigns(id) ON DELETE CASCADE; -- -- Name: popularity_polls popularity_polls_campaign_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.popularity_polls ADD CONSTRAINT popularity_polls_campaign_id_foreign FOREIGN KEY (campaign_id) REFERENCES public.campaigns(id) ON DELETE CASCADE; -- -- Name: poster_campaigns poster_campaigns_campaign_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.poster_campaigns ADD CONSTRAINT poster_campaigns_campaign_id_foreign FOREIGN KEY (campaign_id) REFERENCES public.campaigns(id) ON DELETE CASCADE; -- -- Name: poster_campaigns poster_campaigns_territory_foreign; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.poster_campaigns ADD CONSTRAINT poster_campaigns_territory_foreign FOREIGN KEY (territory_id) REFERENCES public.territories(id) ON DELETE SET NULL; -- -- Name: poster_qr_codes poster_qr_codes_campaign_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.poster_qr_codes ADD CONSTRAINT poster_qr_codes_campaign_id_foreign FOREIGN KEY (campaign_id) REFERENCES public.campaigns(id) ON DELETE CASCADE; -- -- Name: poster_qr_codes poster_qr_codes_pcampaign_foreign; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.poster_qr_codes ADD CONSTRAINT poster_qr_codes_pcampaign_foreign FOREIGN KEY (poster_campaign_id) REFERENCES public.poster_campaigns(id) ON DELETE CASCADE; -- -- Name: poster_qr_scans poster_qr_scans_campaign_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.poster_qr_scans ADD CONSTRAINT poster_qr_scans_campaign_id_foreign FOREIGN KEY (campaign_id) REFERENCES public.campaigns(id) ON DELETE CASCADE; -- -- Name: poster_qr_scans poster_qr_scans_code_foreign; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.poster_qr_scans ADD CONSTRAINT poster_qr_scans_code_foreign FOREIGN KEY (poster_qr_code_id) REFERENCES public.poster_qr_codes(id) ON DELETE CASCADE; -- -- Name: pqrs pqrs_campaign_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.pqrs ADD CONSTRAINT pqrs_campaign_id_foreign FOREIGN KEY (campaign_id) REFERENCES public.campaigns(id) ON DELETE CASCADE; -- -- Name: pqrs_categories pqrs_categories_campaign_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.pqrs_categories ADD CONSTRAINT pqrs_categories_campaign_id_foreign FOREIGN KEY (campaign_id) REFERENCES public.campaigns(id) ON DELETE CASCADE; -- -- Name: pqrs pqrs_category_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.pqrs ADD CONSTRAINT pqrs_category_id_foreign FOREIGN KEY (category_id) REFERENCES public.pqrs_categories(id) ON DELETE SET NULL; -- -- Name: pqrs pqrs_territory_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.pqrs ADD CONSTRAINT pqrs_territory_id_foreign FOREIGN KEY (territory_id) REFERENCES public.territories(id) ON DELETE SET NULL; -- -- Name: predictive_variables predictive_variables_campaign_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.predictive_variables ADD CONSTRAINT predictive_variables_campaign_id_foreign FOREIGN KEY (campaign_id) REFERENCES public.campaigns(id) ON DELETE CASCADE; -- -- Name: preliminary_results preliminary_results_campaign_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.preliminary_results ADD CONSTRAINT preliminary_results_campaign_id_foreign FOREIGN KEY (campaign_id) REFERENCES public.campaigns(id) ON DELETE CASCADE; -- -- Name: preliminary_results preliminary_results_station_foreign; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.preliminary_results ADD CONSTRAINT preliminary_results_station_foreign FOREIGN KEY (polling_station_id) REFERENCES public.polling_stations(id) ON DELETE CASCADE; -- -- Name: proposal_amendments proposal_amendments_campaign_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.proposal_amendments ADD CONSTRAINT proposal_amendments_campaign_id_foreign FOREIGN KEY (campaign_id) REFERENCES public.campaigns(id) ON DELETE CASCADE; -- -- Name: proposal_amendments proposal_amendments_proposal_foreign; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.proposal_amendments ADD CONSTRAINT proposal_amendments_proposal_foreign FOREIGN KEY (proposal_id) REFERENCES public.proposals(id) ON DELETE CASCADE; -- -- Name: proposal_comments proposal_comments_parent_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.proposal_comments ADD CONSTRAINT proposal_comments_parent_id_foreign FOREIGN KEY (parent_id) REFERENCES public.proposal_comments(id) ON DELETE CASCADE; -- -- Name: proposal_comments proposal_comments_proposal_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.proposal_comments ADD CONSTRAINT proposal_comments_proposal_id_foreign FOREIGN KEY (proposal_id) REFERENCES public.proposals(id) ON DELETE CASCADE; -- -- Name: proposal_comments proposal_comments_user_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.proposal_comments ADD CONSTRAINT proposal_comments_user_id_foreign FOREIGN KEY (user_id) REFERENCES public.users(id) ON DELETE CASCADE; -- -- Name: proposal_supports proposal_supports_proposal_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.proposal_supports ADD CONSTRAINT proposal_supports_proposal_id_foreign FOREIGN KEY (proposal_id) REFERENCES public.proposals(id) ON DELETE CASCADE; -- -- Name: proposal_supports proposal_supports_user_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.proposal_supports ADD CONSTRAINT proposal_supports_user_id_foreign FOREIGN KEY (user_id) REFERENCES public.users(id) ON DELETE CASCADE; -- -- Name: proposal_versions proposal_versions_created_by_foreign; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.proposal_versions ADD CONSTRAINT proposal_versions_created_by_foreign FOREIGN KEY (created_by) REFERENCES public.users(id); -- -- Name: proposal_versions proposal_versions_proposal_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.proposal_versions ADD CONSTRAINT proposal_versions_proposal_id_foreign FOREIGN KEY (proposal_id) REFERENCES public.proposals(id) ON DELETE CASCADE; -- -- Name: proposals proposals_author_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.proposals ADD CONSTRAINT proposals_author_id_foreign FOREIGN KEY (author_id) REFERENCES public.users(id) ON DELETE SET NULL; -- -- Name: proposals proposals_campaign_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.proposals ADD CONSTRAINT proposals_campaign_id_foreign FOREIGN KEY (campaign_id) REFERENCES public.campaigns(id) ON DELETE CASCADE; -- -- Name: proposals proposals_category_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.proposals ADD CONSTRAINT proposals_category_id_foreign FOREIGN KEY (category_id) REFERENCES public.proposal_categories(id) ON DELETE SET NULL; -- -- Name: polling_station_turnout pst_campaign_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.polling_station_turnout ADD CONSTRAINT pst_campaign_id_foreign FOREIGN KEY (campaign_id) REFERENCES public.campaigns(id) ON DELETE CASCADE; -- -- Name: polling_station_turnout pst_station_foreign; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.polling_station_turnout ADD CONSTRAINT pst_station_foreign FOREIGN KEY (polling_station_id) REFERENCES public.polling_stations(id) ON DELETE CASCADE; -- -- Name: public_surveys public_surveys_campaign_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.public_surveys ADD CONSTRAINT public_surveys_campaign_id_foreign FOREIGN KEY (campaign_id) REFERENCES public.campaigns(id) ON DELETE CASCADE; -- -- Name: qr_lead_conversions qlc_campaign_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.qr_lead_conversions ADD CONSTRAINT qlc_campaign_id_foreign FOREIGN KEY (campaign_id) REFERENCES public.campaigns(id) ON DELETE CASCADE; -- -- Name: qr_lead_conversions qlc_lead_foreign; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.qr_lead_conversions ADD CONSTRAINT qlc_lead_foreign FOREIGN KEY (qr_citizen_lead_id) REFERENCES public.qr_citizen_leads(id) ON DELETE CASCADE; -- -- Name: qr_lead_interactions qli_campaign_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.qr_lead_interactions ADD CONSTRAINT qli_campaign_id_foreign FOREIGN KEY (campaign_id) REFERENCES public.campaigns(id) ON DELETE CASCADE; -- -- Name: qr_lead_interactions qli_lead_foreign; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.qr_lead_interactions ADD CONSTRAINT qli_lead_foreign FOREIGN KEY (qr_citizen_lead_id) REFERENCES public.qr_citizen_leads(id) ON DELETE CASCADE; -- -- Name: qr_campaigns qr_campaigns_campaign_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.qr_campaigns ADD CONSTRAINT qr_campaigns_campaign_id_foreign FOREIGN KEY (campaign_id) REFERENCES public.campaigns(id) ON DELETE CASCADE; -- -- Name: qr_citizen_leads qr_citizen_leads_campaign_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.qr_citizen_leads ADD CONSTRAINT qr_citizen_leads_campaign_id_foreign FOREIGN KEY (campaign_id) REFERENCES public.campaigns(id) ON DELETE CASCADE; -- -- Name: qr_citizen_leads qr_citizen_leads_code_foreign; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.qr_citizen_leads ADD CONSTRAINT qr_citizen_leads_code_foreign FOREIGN KEY (poster_qr_code_id) REFERENCES public.poster_qr_codes(id) ON DELETE SET NULL; -- -- Name: qr_codes qr_codes_campaign_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.qr_codes ADD CONSTRAINT qr_codes_campaign_id_foreign FOREIGN KEY (campaign_id) REFERENCES public.campaigns(id) ON DELETE CASCADE; -- -- Name: qr_codes qr_codes_qr_campaign_foreign; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.qr_codes ADD CONSTRAINT qr_codes_qr_campaign_foreign FOREIGN KEY (qr_campaign_id) REFERENCES public.qr_campaigns(id) ON DELETE CASCADE; -- -- Name: qr_heatmap_data qr_heatmap_data_campaign_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.qr_heatmap_data ADD CONSTRAINT qr_heatmap_data_campaign_id_foreign FOREIGN KEY (campaign_id) REFERENCES public.campaigns(id) ON DELETE CASCADE; -- -- Name: qr_heatmap_zones qr_heatmap_zones_campaign_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.qr_heatmap_zones ADD CONSTRAINT qr_heatmap_zones_campaign_id_foreign FOREIGN KEY (campaign_id) REFERENCES public.campaigns(id) ON DELETE CASCADE; -- -- Name: qr_heatmap_zones qr_heatmap_zones_city_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.qr_heatmap_zones ADD CONSTRAINT qr_heatmap_zones_city_id_foreign FOREIGN KEY (city_id) REFERENCES public.cities(id); -- -- Name: qr_hits qr_hits_campaign_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.qr_hits ADD CONSTRAINT qr_hits_campaign_id_foreign FOREIGN KEY (campaign_id) REFERENCES public.campaigns(id) ON DELETE CASCADE; -- -- Name: qr_hits qr_hits_qr_code_foreign; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.qr_hits ADD CONSTRAINT qr_hits_qr_code_foreign FOREIGN KEY (qr_code_id) REFERENCES public.qr_codes(id) ON DELETE CASCADE; -- -- Name: qr_posters qr_posters_campaign_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.qr_posters ADD CONSTRAINT qr_posters_campaign_id_foreign FOREIGN KEY (campaign_id) REFERENCES public.campaigns(id) ON DELETE CASCADE; -- -- Name: qr_posters qr_posters_city_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.qr_posters ADD CONSTRAINT qr_posters_city_id_foreign FOREIGN KEY (city_id) REFERENCES public.cities(id); -- -- Name: qr_posters qr_posters_country_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.qr_posters ADD CONSTRAINT qr_posters_country_id_foreign FOREIGN KEY (country_id) REFERENCES public.countries(id); -- -- Name: qr_posters qr_posters_state_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.qr_posters ADD CONSTRAINT qr_posters_state_id_foreign FOREIGN KEY (state_id) REFERENCES public.states(id); -- -- Name: qr_scans qr_scans_campaign_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.qr_scans ADD CONSTRAINT qr_scans_campaign_id_foreign FOREIGN KEY (campaign_id) REFERENCES public.campaigns(id) ON DELETE CASCADE; -- -- Name: qr_scans qr_scans_qr_poster_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.qr_scans ADD CONSTRAINT qr_scans_qr_poster_id_foreign FOREIGN KEY (qr_poster_id) REFERENCES public.qr_posters(id) ON DELETE CASCADE; -- -- Name: regional_interests regional_interests_campaign_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.regional_interests ADD CONSTRAINT regional_interests_campaign_id_foreign FOREIGN KEY (campaign_id) REFERENCES public.campaigns(id) ON DELETE CASCADE; -- -- Name: regional_interests regional_interests_territory_foreign; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.regional_interests ADD CONSTRAINT regional_interests_territory_foreign FOREIGN KEY (territory_id) REFERENCES public.territories(id) ON DELETE CASCADE; -- -- Name: role_has_permissions role_has_permissions_permission_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.role_has_permissions ADD CONSTRAINT role_has_permissions_permission_id_foreign FOREIGN KEY (permission_id) REFERENCES public.permissions(id) ON DELETE CASCADE; -- -- Name: role_has_permissions role_has_permissions_role_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.role_has_permissions ADD CONSTRAINT role_has_permissions_role_id_foreign FOREIGN KEY (role_id) REFERENCES public.roles(id) ON DELETE CASCADE; -- -- Name: security_alerts security_alerts_campaign_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.security_alerts ADD CONSTRAINT security_alerts_campaign_id_foreign FOREIGN KEY (campaign_id) REFERENCES public.campaigns(id) ON DELETE CASCADE; -- -- Name: security_alerts security_alerts_resolved_by_foreign; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.security_alerts ADD CONSTRAINT security_alerts_resolved_by_foreign FOREIGN KEY (resolved_by) REFERENCES public.users(id); -- -- Name: security_alerts security_alerts_user_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.security_alerts ADD CONSTRAINT security_alerts_user_id_foreign FOREIGN KEY (user_id) REFERENCES public.users(id) ON DELETE SET NULL; -- -- Name: social_accounts social_accounts_political_competitor_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.social_accounts ADD CONSTRAINT social_accounts_political_competitor_id_foreign FOREIGN KEY (political_competitor_id) REFERENCES public.political_competitors(id) ON DELETE CASCADE; -- -- Name: social_alerts social_alerts_political_competitor_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.social_alerts ADD CONSTRAINT social_alerts_political_competitor_id_foreign FOREIGN KEY (political_competitor_id) REFERENCES public.political_competitors(id) ON DELETE CASCADE; -- -- Name: social_alerts social_alerts_resolved_by_foreign; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.social_alerts ADD CONSTRAINT social_alerts_resolved_by_foreign FOREIGN KEY (resolved_by) REFERENCES public.users(id); -- -- Name: social_alerts social_alerts_social_post_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.social_alerts ADD CONSTRAINT social_alerts_social_post_id_foreign FOREIGN KEY (social_post_id) REFERENCES public.social_posts(id) ON DELETE CASCADE; -- -- Name: social_comments social_comments_campaign_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.social_comments ADD CONSTRAINT social_comments_campaign_id_foreign FOREIGN KEY (campaign_id) REFERENCES public.campaigns(id) ON DELETE CASCADE; -- -- Name: social_media_posts social_media_posts_campaign_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.social_media_posts ADD CONSTRAINT social_media_posts_campaign_id_foreign FOREIGN KEY (campaign_id) REFERENCES public.campaigns(id) ON DELETE CASCADE; -- -- Name: social_posts social_posts_political_competitor_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.social_posts ADD CONSTRAINT social_posts_political_competitor_id_foreign FOREIGN KEY (political_competitor_id) REFERENCES public.political_competitors(id) ON DELETE CASCADE; -- -- Name: social_posts social_posts_social_account_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.social_posts ADD CONSTRAINT social_posts_social_account_id_foreign FOREIGN KEY (social_account_id) REFERENCES public.social_accounts(id) ON DELETE CASCADE; -- -- Name: social_trends social_trends_political_competitor_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.social_trends ADD CONSTRAINT social_trends_political_competitor_id_foreign FOREIGN KEY (political_competitor_id) REFERENCES public.political_competitors(id) ON DELETE CASCADE; -- -- Name: states states_country_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.states ADD CONSTRAINT states_country_id_foreign FOREIGN KEY (country_id) REFERENCES public.countries(id) ON DELETE CASCADE; -- -- Name: street_surveys street_surveys_city_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.street_surveys ADD CONSTRAINT street_surveys_city_id_foreign FOREIGN KEY (city_id) REFERENCES public.cities(id); -- -- Name: street_surveys street_surveys_country_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.street_surveys ADD CONSTRAINT street_surveys_country_id_foreign FOREIGN KEY (country_id) REFERENCES public.countries(id); -- -- Name: street_surveys street_surveys_created_by_foreign; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.street_surveys ADD CONSTRAINT street_surveys_created_by_foreign FOREIGN KEY (created_by) REFERENCES public.users(id); -- -- Name: street_surveys street_surveys_state_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.street_surveys ADD CONSTRAINT street_surveys_state_id_foreign FOREIGN KEY (state_id) REFERENCES public.states(id); -- -- Name: subscription_payments subscription_payments_subscription_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.subscription_payments ADD CONSTRAINT subscription_payments_subscription_id_foreign FOREIGN KEY (subscription_id) REFERENCES public.subscriptions(id) ON DELETE CASCADE; -- -- Name: subscriptions subscriptions_campaign_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.subscriptions ADD CONSTRAINT subscriptions_campaign_id_foreign FOREIGN KEY (campaign_id) REFERENCES public.campaigns(id) ON DELETE CASCADE; -- -- Name: subscriptions subscriptions_demo_request_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.subscriptions ADD CONSTRAINT subscriptions_demo_request_id_foreign FOREIGN KEY (demo_request_id) REFERENCES public.demo_requests(id) ON DELETE SET NULL; -- -- Name: subscriptions subscriptions_membership_plan_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.subscriptions ADD CONSTRAINT subscriptions_membership_plan_id_foreign FOREIGN KEY (membership_plan_id) REFERENCES public.membership_plans(id); -- -- Name: subscriptions subscriptions_user_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.subscriptions ADD CONSTRAINT subscriptions_user_id_foreign FOREIGN KEY (user_id) REFERENCES public.users(id) ON DELETE SET NULL; -- -- Name: survey_analyses survey_analyses_campaign_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.survey_analyses ADD CONSTRAINT survey_analyses_campaign_id_foreign FOREIGN KEY (campaign_id) REFERENCES public.campaigns(id) ON DELETE CASCADE; -- -- Name: survey_analyses survey_analyses_survey_foreign; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.survey_analyses ADD CONSTRAINT survey_analyses_survey_foreign FOREIGN KEY (survey_id) REFERENCES public.public_surveys(id) ON DELETE CASCADE; -- -- Name: survey_candidates survey_candidates_campaign_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.survey_candidates ADD CONSTRAINT survey_candidates_campaign_id_foreign FOREIGN KEY (campaign_id) REFERENCES public.campaigns(id) ON DELETE CASCADE; -- -- Name: survey_candidates survey_candidates_survey_foreign; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.survey_candidates ADD CONSTRAINT survey_candidates_survey_foreign FOREIGN KEY (survey_id) REFERENCES public.public_surveys(id) ON DELETE CASCADE; -- -- Name: survey_concerns survey_concerns_survey_response_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.survey_concerns ADD CONSTRAINT survey_concerns_survey_response_id_foreign FOREIGN KEY (survey_response_id) REFERENCES public.survey_responses(id) ON DELETE CASCADE; -- -- Name: survey_reasons survey_reasons_campaign_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.survey_reasons ADD CONSTRAINT survey_reasons_campaign_id_foreign FOREIGN KEY (campaign_id) REFERENCES public.campaigns(id) ON DELETE CASCADE; -- -- Name: survey_reasons survey_reasons_survey_foreign; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.survey_reasons ADD CONSTRAINT survey_reasons_survey_foreign FOREIGN KEY (survey_id) REFERENCES public.public_surveys(id) ON DELETE CASCADE; -- -- Name: survey_responses survey_responses_city_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.survey_responses ADD CONSTRAINT survey_responses_city_id_foreign FOREIGN KEY (city_id) REFERENCES public.cities(id); -- -- Name: survey_responses survey_responses_country_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.survey_responses ADD CONSTRAINT survey_responses_country_id_foreign FOREIGN KEY (country_id) REFERENCES public.countries(id); -- -- Name: survey_responses survey_responses_preferred_candidate_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.survey_responses ADD CONSTRAINT survey_responses_preferred_candidate_id_foreign FOREIGN KEY (preferred_candidate_id) REFERENCES public.political_competitors(id); -- -- Name: survey_responses survey_responses_state_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.survey_responses ADD CONSTRAINT survey_responses_state_id_foreign FOREIGN KEY (state_id) REFERENCES public.states(id); -- -- Name: survey_responses survey_responses_street_survey_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.survey_responses ADD CONSTRAINT survey_responses_street_survey_id_foreign FOREIGN KEY (street_survey_id) REFERENCES public.street_surveys(id) ON DELETE CASCADE; -- -- Name: survey_responses survey_responses_survey_template_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.survey_responses ADD CONSTRAINT survey_responses_survey_template_id_foreign FOREIGN KEY (survey_template_id) REFERENCES public.survey_templates(id) ON DELETE SET NULL; -- -- Name: survey_responses survey_responses_surveyor_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.survey_responses ADD CONSTRAINT survey_responses_surveyor_id_foreign FOREIGN KEY (surveyor_id) REFERENCES public.users(id); -- -- Name: survey_templates survey_templates_campaign_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.survey_templates ADD CONSTRAINT survey_templates_campaign_id_foreign FOREIGN KEY (campaign_id) REFERENCES public.campaigns(id) ON DELETE CASCADE; -- -- Name: surveyor_activity_log surveyor_activity_log_street_survey_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.surveyor_activity_log ADD CONSTRAINT surveyor_activity_log_street_survey_id_foreign FOREIGN KEY (street_survey_id) REFERENCES public.street_surveys(id); -- -- Name: surveyor_activity_log surveyor_activity_log_surveyor_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.surveyor_activity_log ADD CONSTRAINT surveyor_activity_log_surveyor_id_foreign FOREIGN KEY (surveyor_id) REFERENCES public.users(id); -- -- Name: tasks tasks_assigned_by_foreign; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.tasks ADD CONSTRAINT tasks_assigned_by_foreign FOREIGN KEY (assigned_by) REFERENCES public.users(id) ON DELETE CASCADE; -- -- Name: tasks tasks_assigned_to_foreign; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.tasks ADD CONSTRAINT tasks_assigned_to_foreign FOREIGN KEY (assigned_to) REFERENCES public.users(id) ON DELETE CASCADE; -- -- Name: tasks tasks_campaign_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.tasks ADD CONSTRAINT tasks_campaign_id_foreign FOREIGN KEY (campaign_id) REFERENCES public.campaigns(id) ON DELETE CASCADE; -- -- Name: territory_demographic_profiles tdp_campaign_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.territory_demographic_profiles ADD CONSTRAINT tdp_campaign_id_foreign FOREIGN KEY (campaign_id) REFERENCES public.campaigns(id) ON DELETE CASCADE; -- -- Name: territory_demographic_profiles tdp_territory_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.territory_demographic_profiles ADD CONSTRAINT tdp_territory_id_foreign FOREIGN KEY (territory_id) REFERENCES public.territories(id) ON DELETE CASCADE; -- -- Name: tenant_configurations tenant_configurations_campaign_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.tenant_configurations ADD CONSTRAINT tenant_configurations_campaign_id_foreign FOREIGN KEY (campaign_id) REFERENCES public.campaigns(id) ON DELETE CASCADE; -- -- Name: tenant_integrations tenant_integrations_campaign_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.tenant_integrations ADD CONSTRAINT tenant_integrations_campaign_id_foreign FOREIGN KEY (campaign_id) REFERENCES public.campaigns(id) ON DELETE CASCADE; -- -- Name: territories territories_campaign_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.territories ADD CONSTRAINT territories_campaign_id_foreign FOREIGN KEY (campaign_id) REFERENCES public.campaigns(id) ON DELETE CASCADE; -- -- Name: territories territories_parent_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.territories ADD CONSTRAINT territories_parent_id_foreign FOREIGN KEY (parent_id) REFERENCES public.territories(id) ON DELETE SET NULL; -- -- Name: territory_visits territory_visits_campaign_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.territory_visits ADD CONSTRAINT territory_visits_campaign_id_foreign FOREIGN KEY (campaign_id) REFERENCES public.campaigns(id) ON DELETE CASCADE; -- -- Name: territory_visits territory_visits_territory_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.territory_visits ADD CONSTRAINT territory_visits_territory_id_foreign FOREIGN KEY (territory_id) REFERENCES public.territories(id) ON DELETE CASCADE; -- -- Name: transactions transactions_campaign_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.transactions ADD CONSTRAINT transactions_campaign_id_foreign FOREIGN KEY (campaign_id) REFERENCES public.campaigns(id) ON DELETE CASCADE; -- -- Name: transactions transactions_category_foreign; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.transactions ADD CONSTRAINT transactions_category_foreign FOREIGN KEY (category_id) REFERENCES public.budget_categories(id) ON DELETE SET NULL; -- -- Name: users users_current_campaign_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.users ADD CONSTRAINT users_current_campaign_id_foreign FOREIGN KEY (current_campaign_id) REFERENCES public.campaigns(id) ON DELETE SET NULL; -- -- Name: victory_predictions victory_predictions_campaign_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.victory_predictions ADD CONSTRAINT victory_predictions_campaign_id_foreign FOREIGN KEY (campaign_id) REFERENCES public.campaigns(id) ON DELETE CASCADE; -- -- Name: volunteer_activities volunteer_activities_campaign_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.volunteer_activities ADD CONSTRAINT volunteer_activities_campaign_id_foreign FOREIGN KEY (campaign_id) REFERENCES public.campaigns(id) ON DELETE CASCADE; -- -- Name: volunteer_activities volunteer_activities_team_foreign; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.volunteer_activities ADD CONSTRAINT volunteer_activities_team_foreign FOREIGN KEY (team_id) REFERENCES public.volunteer_teams(id) ON DELETE SET NULL; -- -- Name: volunteer_hours volunteer_hours_campaign_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.volunteer_hours ADD CONSTRAINT volunteer_hours_campaign_id_foreign FOREIGN KEY (campaign_id) REFERENCES public.campaigns(id) ON DELETE CASCADE; -- -- Name: volunteer_hours volunteer_hours_task_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.volunteer_hours ADD CONSTRAINT volunteer_hours_task_id_foreign FOREIGN KEY (task_id) REFERENCES public.tasks(id) ON DELETE SET NULL; -- -- Name: volunteer_hours volunteer_hours_user_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.volunteer_hours ADD CONSTRAINT volunteer_hours_user_id_foreign FOREIGN KEY (user_id) REFERENCES public.users(id) ON DELETE CASCADE; -- -- Name: volunteer_hours volunteer_hours_verified_by_foreign; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.volunteer_hours ADD CONSTRAINT volunteer_hours_verified_by_foreign FOREIGN KEY (verified_by) REFERENCES public.users(id) ON DELETE SET NULL; -- -- Name: volunteer_tasks volunteer_tasks_assigned_by_foreign; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.volunteer_tasks ADD CONSTRAINT volunteer_tasks_assigned_by_foreign FOREIGN KEY (assigned_by) REFERENCES public.users(id) ON DELETE SET NULL; -- -- Name: volunteer_tasks volunteer_tasks_campaign_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.volunteer_tasks ADD CONSTRAINT volunteer_tasks_campaign_id_foreign FOREIGN KEY (campaign_id) REFERENCES public.campaigns(id) ON DELETE CASCADE; -- -- Name: volunteer_tasks volunteer_tasks_volunteer_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.volunteer_tasks ADD CONSTRAINT volunteer_tasks_volunteer_id_foreign FOREIGN KEY (volunteer_id) REFERENCES public.volunteers(id) ON DELETE CASCADE; -- -- Name: volunteer_teams volunteer_teams_campaign_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.volunteer_teams ADD CONSTRAINT volunteer_teams_campaign_id_foreign FOREIGN KEY (campaign_id) REFERENCES public.campaigns(id) ON DELETE CASCADE; -- -- Name: volunteers volunteers_campaign_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.volunteers ADD CONSTRAINT volunteers_campaign_id_foreign FOREIGN KEY (campaign_id) REFERENCES public.campaigns(id) ON DELETE CASCADE; -- -- Name: volunteers volunteers_user_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.volunteers ADD CONSTRAINT volunteers_user_id_foreign FOREIGN KEY (user_id) REFERENCES public.users(id) ON DELETE SET NULL; -- -- Name: voter_contacts voter_contacts_user_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.voter_contacts ADD CONSTRAINT voter_contacts_user_id_foreign FOREIGN KEY (user_id) REFERENCES public.users(id) ON DELETE SET NULL; -- -- Name: voter_contacts voter_contacts_voter_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.voter_contacts ADD CONSTRAINT voter_contacts_voter_id_foreign FOREIGN KEY (voter_id) REFERENCES public.voters(id) ON DELETE CASCADE; -- -- Name: voters voters_campaign_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.voters ADD CONSTRAINT voters_campaign_id_foreign FOREIGN KEY (campaign_id) REFERENCES public.campaigns(id) ON DELETE CASCADE; -- -- Name: whatsapp_conversation_messages wcm_campaign_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.whatsapp_conversation_messages ADD CONSTRAINT wcm_campaign_id_foreign FOREIGN KEY (campaign_id) REFERENCES public.campaigns(id) ON DELETE CASCADE; -- -- Name: whatsapp_conversation_messages wcm_conversation_foreign; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.whatsapp_conversation_messages ADD CONSTRAINT wcm_conversation_foreign FOREIGN KEY (whatsapp_conversation_id) REFERENCES public.whatsapp_conversations(id) ON DELETE CASCADE; -- -- Name: whatsapp_auto_replies whatsapp_auto_replies_campaign_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.whatsapp_auto_replies ADD CONSTRAINT whatsapp_auto_replies_campaign_id_foreign FOREIGN KEY (campaign_id) REFERENCES public.campaigns(id) ON DELETE CASCADE; -- -- Name: whatsapp_campaigns whatsapp_campaigns_campaign_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.whatsapp_campaigns ADD CONSTRAINT whatsapp_campaigns_campaign_id_foreign FOREIGN KEY (campaign_id) REFERENCES public.campaigns(id) ON DELETE CASCADE; -- -- Name: whatsapp_campaigns whatsapp_campaigns_template_foreign; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.whatsapp_campaigns ADD CONSTRAINT whatsapp_campaigns_template_foreign FOREIGN KEY (whatsapp_template_id) REFERENCES public.whatsapp_templates(id) ON DELETE SET NULL; -- -- Name: whatsapp_conversations whatsapp_conversations_campaign_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.whatsapp_conversations ADD CONSTRAINT whatsapp_conversations_campaign_id_foreign FOREIGN KEY (campaign_id) REFERENCES public.campaigns(id) ON DELETE CASCADE; -- -- Name: whatsapp_messages whatsapp_messages_campaign_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.whatsapp_messages ADD CONSTRAINT whatsapp_messages_campaign_id_foreign FOREIGN KEY (campaign_id) REFERENCES public.campaigns(id) ON DELETE CASCADE; -- -- Name: whatsapp_messages whatsapp_messages_wcampaign_foreign; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.whatsapp_messages ADD CONSTRAINT whatsapp_messages_wcampaign_foreign FOREIGN KEY (whatsapp_campaign_id) REFERENCES public.whatsapp_campaigns(id) ON DELETE CASCADE; -- -- Name: whatsapp_templates whatsapp_templates_campaign_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.whatsapp_templates ADD CONSTRAINT whatsapp_templates_campaign_id_foreign FOREIGN KEY (campaign_id) REFERENCES public.campaigns(id) ON DELETE CASCADE; -- -- \unrestrict 7jUpbJGgFswlKKELvwlcvpIAcF8fcDCqV0isz3asaQQTePEc1Ri6RSj8BZM35gL