--
--

\restrict fIxQDpnQL5BnEmspmKWdGyfeoGX4FKABytzullscbuDanabcwcsPDgxarysYfD6


-- Started on 2026-02-03 10:43:37

SET transaction_timeout = 0;
SELECT pg_catalog.set_config('search_path', '', false);

--
-- TOC entry 19 (class 2615 OID 2200)
-- Name: public; Type: SCHEMA; Schema: -; Owner: pg_database_owner
--

CREATE SCHEMA public;


ALTER SCHEMA public OWNER TO pg_database_owner;

--
-- TOC entry 4365 (class 0 OID 0)
-- Dependencies: 19
-- Name: SCHEMA public; Type: COMMENT; Schema: -; Owner: pg_database_owner
--

COMMENT ON SCHEMA public IS 'standard public schema';


--
-- TOC entry 1159 (class 1247 OID 17495)
-- Name: app_role; Type: TYPE; Schema: public; Owner: postgres
--

CREATE TYPE public.app_role AS ENUM (
    'super_admin',
    'data_manager',
    'content_manager',
    'support_admin'
);


ALTER TYPE public.app_role OWNER TO postgres;

--
-- TOC entry 1174 (class 1247 OID 17544)
-- Name: college_type; Type: TYPE; Schema: public; Owner: postgres
--

CREATE TYPE public.college_type AS ENUM (
    'government',
    'private',
    'deemed'
);


ALTER TYPE public.college_type OWNER TO postgres;

--
-- TOC entry 1162 (class 1247 OID 17504)
-- Name: content_status; Type: TYPE; Schema: public; Owner: postgres
--

CREATE TYPE public.content_status AS ENUM (
    'draft',
    'pending',
    'approved',
    'published',
    'archived'
);


ALTER TYPE public.content_status OWNER TO postgres;

--
-- TOC entry 1168 (class 1247 OID 17526)
-- Name: import_status; Type: TYPE; Schema: public; Owner: postgres
--

CREATE TYPE public.import_status AS ENUM (
    'pending',
    'processing',
    'completed',
    'failed',
    'cancelled'
);


ALTER TYPE public.import_status OWNER TO postgres;

--
-- TOC entry 1171 (class 1247 OID 17538)
-- Name: neet_type; Type: TYPE; Schema: public; Owner: postgres
--

CREATE TYPE public.neet_type AS ENUM (
    'UG',
    'PG'
);


ALTER TYPE public.neet_type OWNER TO postgres;

--
-- TOC entry 1165 (class 1247 OID 17516)
-- Name: subscription_status; Type: TYPE; Schema: public; Owner: postgres
--

CREATE TYPE public.subscription_status AS ENUM (
    'active',
    'expired',
    'cancelled',
    'pending'
);


ALTER TYPE public.subscription_status OWNER TO postgres;

--
-- TOC entry 437 (class 1255 OID 18131)
-- Name: handle_new_user(); Type: FUNCTION; Schema: public; Owner: postgres
--

CREATE FUNCTION public.handle_new_user() RETURNS trigger
    LANGUAGE plpgsql SECURITY DEFINER
    SET search_path TO 'public'
    AS $$
BEGIN
  INSERT INTO public.profiles (user_id, name, email)
  VALUES (
    NEW.id,
    COALESCE(NEW.raw_user_meta_data->>'name', NEW.email),
    NEW.email
  );
  RETURN NEW;
END;
$$;


ALTER FUNCTION public.handle_new_user() OWNER TO postgres;

--
-- TOC entry 432 (class 1255 OID 18109)
-- Name: has_role(uuid, public.app_role); Type: FUNCTION; Schema: public; Owner: postgres
--

CREATE FUNCTION public.has_role(_user_id uuid, _role public.app_role) RETURNS boolean
    LANGUAGE sql STABLE SECURITY DEFINER
    SET search_path TO 'public'
    AS $$
  SELECT EXISTS (
    SELECT 1
    FROM public.user_roles
    WHERE user_id = _user_id
      AND role = _role
  )
$$;


ALTER FUNCTION public.has_role(_user_id uuid, _role public.app_role) OWNER TO postgres;

--
-- TOC entry 433 (class 1255 OID 18110)
-- Name: is_admin(uuid); Type: FUNCTION; Schema: public; Owner: postgres
--

CREATE FUNCTION public.is_admin(_user_id uuid) RETURNS boolean
    LANGUAGE sql STABLE SECURITY DEFINER
    SET search_path TO 'public'
    AS $$
  SELECT EXISTS (
    SELECT 1
    FROM public.user_roles
    WHERE user_id = _user_id
      AND role IN ('super_admin', 'data_manager')
  )
$$;


ALTER FUNCTION public.is_admin(_user_id uuid) OWNER TO postgres;

--
-- TOC entry 434 (class 1255 OID 18111)
-- Name: is_any_admin(uuid); Type: FUNCTION; Schema: public; Owner: postgres
--

CREATE FUNCTION public.is_any_admin(_user_id uuid) RETURNS boolean
    LANGUAGE sql STABLE SECURITY DEFINER
    SET search_path TO 'public'
    AS $$
  SELECT EXISTS (
    SELECT 1
    FROM public.user_roles
    WHERE user_id = _user_id
      AND role IN ('super_admin', 'data_manager', 'content_manager', 'support_admin')
  )
$$;


ALTER FUNCTION public.is_any_admin(_user_id uuid) OWNER TO postgres;

--
-- TOC entry 435 (class 1255 OID 18112)
-- Name: is_super_admin(uuid); Type: FUNCTION; Schema: public; Owner: postgres
--

CREATE FUNCTION public.is_super_admin(_user_id uuid) RETURNS boolean
    LANGUAGE sql STABLE SECURITY DEFINER
    SET search_path TO 'public'
    AS $$
  SELECT EXISTS (
    SELECT 1
    FROM public.user_roles
    WHERE user_id = _user_id
      AND role = 'super_admin'
  )
$$;


ALTER FUNCTION public.is_super_admin(_user_id uuid) OWNER TO postgres;

--
-- TOC entry 436 (class 1255 OID 18113)
-- Name: update_updated_at_column(); Type: FUNCTION; Schema: public; Owner: postgres
--

CREATE FUNCTION public.update_updated_at_column() RETURNS trigger
    LANGUAGE plpgsql
    SET search_path TO 'public'
    AS $$
BEGIN
  NEW.updated_at = now();
  RETURN NEW;
END;
$$;


ALTER FUNCTION public.update_updated_at_column() OWNER TO postgres;



--
-- TOC entry 297 (class 1259 OID 18077)
-- Name: activity_logs; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.activity_logs (
    id uuid DEFAULT gen_random_uuid() NOT NULL,
    user_id uuid,
    action text NOT NULL,
    entity_type text NOT NULL,
    entity_id uuid,
    old_data jsonb,
    new_data jsonb,
    ip_address text,
    user_agent text,
    created_at timestamp with time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.activity_logs OWNER TO postgres;

--
-- TOC entry 298 (class 1259 OID 18195)
-- Name: allotments; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.allotments (
    id uuid DEFAULT gen_random_uuid() NOT NULL,
    year integer NOT NULL,
    round character varying(50) NOT NULL,
    state_rank integer,
    all_india_rank integer,
    state character varying(100) NOT NULL,
    college_id uuid,
    course_id uuid,
    quota character varying(50) NOT NULL,
    category character varying(50) NOT NULL,
    fee numeric,
    stipend_year_1 numeric,
    stipend_year_2 numeric,
    stipend_year_3 numeric,
    bond_years integer,
    bond_penalty numeric,
    beds integer,
    admission_status character varying(50) DEFAULT 'allotted'::character varying,
    reporting_date date,
    neet_type public.neet_type DEFAULT 'UG'::public.neet_type NOT NULL,
    created_at timestamp with time zone DEFAULT now() NOT NULL,
    updated_at timestamp with time zone DEFAULT now() NOT NULL,
    created_by uuid,
    updated_by uuid
);


ALTER TABLE public.allotments OWNER TO postgres;

--
-- TOC entry 290 (class 1259 OID 17935)
-- Name: announcements; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.announcements (
    id uuid DEFAULT gen_random_uuid() NOT NULL,
    title text NOT NULL,
    message text NOT NULL,
    type text DEFAULT 'info'::text NOT NULL,
    neet_type public.neet_type,
    is_important boolean DEFAULT false NOT NULL,
    status public.content_status DEFAULT 'draft'::public.content_status NOT NULL,
    author_id uuid,
    published_at timestamp with time zone,
    expires_at timestamp with time zone,
    created_at timestamp with time zone DEFAULT now() NOT NULL,
    updated_at timestamp with time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.announcements OWNER TO postgres;

--
-- TOC entry 295 (class 1259 OID 18037)
-- Name: choice_list_items; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.choice_list_items (
    id uuid DEFAULT gen_random_uuid() NOT NULL,
    choice_list_id uuid NOT NULL,
    college_id uuid NOT NULL,
    course_id uuid NOT NULL,
    priority integer NOT NULL,
    created_at timestamp with time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.choice_list_items OWNER TO postgres;

--
-- TOC entry 294 (class 1259 OID 18011)
-- Name: choice_lists; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.choice_lists (
    id uuid DEFAULT gen_random_uuid() NOT NULL,
    profile_id uuid NOT NULL,
    name text NOT NULL,
    authority_id uuid,
    round_id uuid,
    is_active boolean DEFAULT true NOT NULL,
    created_at timestamp with time zone DEFAULT now() NOT NULL,
    updated_at timestamp with time zone DEFAULT now() NOT NULL,
    approved_by uuid,
    approval_status text DEFAULT 'pending'::text,
    CONSTRAINT choice_lists_approval_status_check CHECK ((approval_status = ANY (ARRAY['pending'::text, 'approved'::text, 'needs_review'::text])))
);


ALTER TABLE public.choice_lists OWNER TO postgres;

--
-- TOC entry 284 (class 1259 OID 17803)
-- Name: closing_ranks; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.closing_ranks (
    id uuid DEFAULT gen_random_uuid() NOT NULL,
    course_id uuid NOT NULL,
    round_id uuid NOT NULL,
    category text NOT NULL,
    quota text,
    opening_rank integer,
    closing_rank integer NOT NULL,
    created_by uuid,
    updated_by uuid,
    created_at timestamp with time zone DEFAULT now() NOT NULL,
    updated_at timestamp with time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.closing_ranks OWNER TO postgres;

--
-- TOC entry 285 (class 1259 OID 17833)
-- Name: closing_ranks_versions; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.closing_ranks_versions (
    id uuid DEFAULT gen_random_uuid() NOT NULL,
    closing_rank_id uuid,
    course_id uuid NOT NULL,
    round_id uuid NOT NULL,
    category text NOT NULL,
    quota text,
    opening_rank integer,
    closing_rank integer NOT NULL,
    version integer DEFAULT 1 NOT NULL,
    changed_by uuid,
    created_at timestamp with time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.closing_ranks_versions OWNER TO postgres;

--
-- TOC entry 301 (class 1259 OID 18299)
-- Name: coaching_institutes; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.coaching_institutes (
    id uuid DEFAULT gen_random_uuid() NOT NULL,
    profile_id uuid NOT NULL,
    institute_name text NOT NULL,
    institute_code text,
    address text,
    city text,
    state text,
    phone text,
    logo_url text,
    is_verified boolean DEFAULT false,
    created_at timestamp with time zone DEFAULT now() NOT NULL,
    updated_at timestamp with time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.coaching_institutes OWNER TO postgres;

--
-- TOC entry 282 (class 1259 OID 17742)
-- Name: college_bonds; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.college_bonds (
    id uuid DEFAULT gen_random_uuid() NOT NULL,
    course_id uuid NOT NULL,
    academic_year integer NOT NULL,
    bond_amount numeric(12,2),
    bond_duration_years integer,
    service_required boolean DEFAULT false NOT NULL,
    service_duration_years integer,
    description text,
    created_by uuid,
    updated_by uuid,
    created_at timestamp with time zone DEFAULT now() NOT NULL,
    updated_at timestamp with time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.college_bonds OWNER TO postgres;

--
-- TOC entry 281 (class 1259 OID 17714)
-- Name: college_fees; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.college_fees (
    id uuid DEFAULT gen_random_uuid() NOT NULL,
    course_id uuid NOT NULL,
    academic_year integer NOT NULL,
    tuition_fee numeric(12,2),
    hostel_fee numeric(12,2),
    other_fees numeric(12,2),
    total_fee numeric(12,2),
    currency text DEFAULT 'INR'::text NOT NULL,
    created_by uuid,
    updated_by uuid,
    created_at timestamp with time zone DEFAULT now() NOT NULL,
    updated_at timestamp with time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.college_fees OWNER TO postgres;

--
-- TOC entry 279 (class 1259 OID 17663)
-- Name: colleges; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.colleges (
    id uuid DEFAULT gen_random_uuid() NOT NULL,
    name text NOT NULL,
    code text,
    state text NOT NULL,
    city text NOT NULL,
    type public.college_type NOT NULL,
    established_year integer,
    university text,
    website text,
    address text,
    description text,
    image_url text,
    rating numeric(2,1),
    ranking integer,
    is_active boolean DEFAULT true NOT NULL,
    created_by uuid,
    updated_by uuid,
    created_at timestamp with time zone DEFAULT now() NOT NULL,
    updated_at timestamp with time zone DEFAULT now() NOT NULL,
    beds integer
);


ALTER TABLE public.colleges OWNER TO postgres;

--
-- TOC entry 289 (class 1259 OID 17916)
-- Name: content_articles; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.content_articles (
    id uuid DEFAULT gen_random_uuid() NOT NULL,
    title text NOT NULL,
    slug text NOT NULL,
    excerpt text,
    content text,
    category text,
    image_url text,
    status public.content_status DEFAULT 'draft'::public.content_status NOT NULL,
    is_premium boolean DEFAULT false NOT NULL,
    author_id uuid,
    published_at timestamp with time zone,
    created_at timestamp with time zone DEFAULT now() NOT NULL,
    updated_at timestamp with time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.content_articles OWNER TO postgres;

--
-- TOC entry 277 (class 1259 OID 17612)
-- Name: counseling_authorities; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.counseling_authorities (
    id uuid DEFAULT gen_random_uuid() NOT NULL,
    name text NOT NULL,
    code text NOT NULL,
    description text,
    website text,
    neet_type public.neet_type NOT NULL,
    is_active boolean DEFAULT true NOT NULL,
    created_by uuid,
    updated_by uuid,
    created_at timestamp with time zone DEFAULT now() NOT NULL,
    updated_at timestamp with time zone DEFAULT now() NOT NULL,
    counseling_type character varying(50) DEFAULT 'State'::character varying
);


ALTER TABLE public.counseling_authorities OWNER TO postgres;

--
-- TOC entry 278 (class 1259 OID 17635)
-- Name: counseling_rounds; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.counseling_rounds (
    id uuid DEFAULT gen_random_uuid() NOT NULL,
    authority_id uuid NOT NULL,
    year integer NOT NULL,
    round_number integer NOT NULL,
    round_name text,
    start_date date,
    end_date date,
    choice_filling_start date,
    choice_filling_end date,
    result_date date,
    is_active boolean DEFAULT true NOT NULL,
    created_by uuid,
    updated_by uuid,
    created_at timestamp with time zone DEFAULT now() NOT NULL,
    updated_at timestamp with time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.counseling_rounds OWNER TO postgres;

--
-- TOC entry 304 (class 1259 OID 18369)
-- Name: counsellor_notes; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.counsellor_notes (
    id uuid DEFAULT gen_random_uuid() NOT NULL,
    counsellor_id uuid NOT NULL,
    student_profile_id uuid NOT NULL,
    note_type text DEFAULT 'general'::text,
    content text NOT NULL,
    is_private boolean DEFAULT false,
    created_at timestamp with time zone DEFAULT now() NOT NULL,
    updated_at timestamp with time zone DEFAULT now() NOT NULL,
    CONSTRAINT counsellor_notes_note_type_check CHECK ((note_type = ANY (ARRAY['general'::text, 'strategy'::text, 'recommendation'::text, 'warning'::text])))
);


ALTER TABLE public.counsellor_notes OWNER TO postgres;

--
-- TOC entry 302 (class 1259 OID 18317)
-- Name: counsellors; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.counsellors (
    id uuid DEFAULT gen_random_uuid() NOT NULL,
    profile_id uuid NOT NULL,
    institute_id uuid,
    specialization text,
    experience_years integer DEFAULT 0,
    is_verified boolean DEFAULT false,
    created_at timestamp with time zone DEFAULT now() NOT NULL,
    updated_at timestamp with time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.counsellors OWNER TO postgres;

--
-- TOC entry 280 (class 1259 OID 17686)
-- Name: courses; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.courses (
    id uuid DEFAULT gen_random_uuid() NOT NULL,
    college_id uuid NOT NULL,
    name text NOT NULL,
    code text,
    neet_type public.neet_type NOT NULL,
    duration text,
    total_seats integer,
    is_active boolean DEFAULT true NOT NULL,
    created_by uuid,
    updated_by uuid,
    created_at timestamp with time zone DEFAULT now() NOT NULL,
    updated_at timestamp with time zone DEFAULT now() NOT NULL,
    degree_type character varying(50),
    course_type character varying(50)
);


ALTER TABLE public.courses OWNER TO postgres;

--
-- TOC entry 291 (class 1259 OID 17953)
-- Name: data_imports; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.data_imports (
    id uuid DEFAULT gen_random_uuid() NOT NULL,
    file_name text NOT NULL,
    file_url text,
    import_type text NOT NULL,
    status public.import_status DEFAULT 'pending'::public.import_status NOT NULL,
    total_rows integer,
    processed_rows integer DEFAULT 0,
    error_rows integer DEFAULT 0,
    errors jsonb,
    uploaded_by uuid NOT NULL,
    processed_at timestamp with time zone,
    created_at timestamp with time zone DEFAULT now() NOT NULL,
    updated_at timestamp with time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.data_imports OWNER TO postgres;

--
-- TOC entry 303 (class 1259 OID 18341)
-- Name: institute_students; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.institute_students (
    id uuid DEFAULT gen_random_uuid() NOT NULL,
    institute_id uuid NOT NULL,
    student_profile_id uuid NOT NULL,
    counsellor_id uuid,
    enrolled_at timestamp with time zone DEFAULT now() NOT NULL,
    status text DEFAULT 'active'::text,
    CONSTRAINT institute_students_status_check CHECK ((status = ANY (ARRAY['active'::text, 'inactive'::text, 'completed'::text])))
);


ALTER TABLE public.institute_students OWNER TO postgres;

--
-- TOC entry 296 (class 1259 OID 18061)
-- Name: notifications; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.notifications (
    id uuid DEFAULT gen_random_uuid() NOT NULL,
    recipient_id uuid NOT NULL,
    title text NOT NULL,
    message text NOT NULL,
    type text DEFAULT 'info'::text NOT NULL,
    is_read boolean DEFAULT false NOT NULL,
    read_at timestamp with time zone,
    metadata jsonb,
    created_at timestamp with time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.notifications OWNER TO postgres;

--
-- TOC entry 288 (class 1259 OID 17894)
-- Name: payments; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.payments (
    id uuid DEFAULT gen_random_uuid() NOT NULL,
    subscription_id uuid,
    profile_id uuid NOT NULL,
    amount numeric(10,2) NOT NULL,
    currency text DEFAULT 'INR'::text NOT NULL,
    payment_method text,
    transaction_id text,
    status text DEFAULT 'pending'::text NOT NULL,
    payment_date timestamp with time zone,
    metadata jsonb,
    created_at timestamp with time zone DEFAULT now() NOT NULL,
    updated_at timestamp with time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.payments OWNER TO postgres;

--
-- TOC entry 300 (class 1259 OID 18261)
-- Name: pg_closing_ranks; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.pg_closing_ranks (
    id uuid DEFAULT gen_random_uuid() NOT NULL,
    seat_id uuid NOT NULL,
    year integer NOT NULL,
    round integer NOT NULL,
    closing_rank integer NOT NULL,
    opening_rank integer,
    created_at timestamp with time zone DEFAULT now() NOT NULL,
    created_by uuid,
    CONSTRAINT pg_closing_ranks_round_check CHECK (((round >= 1) AND (round <= 5)))
);


ALTER TABLE public.pg_closing_ranks OWNER TO postgres;

--
-- TOC entry 299 (class 1259 OID 18233)
-- Name: pg_course_seats; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.pg_course_seats (
    id uuid DEFAULT gen_random_uuid() NOT NULL,
    college_id uuid,
    course_id uuid,
    state character varying(100) NOT NULL,
    institute_type character varying(50) NOT NULL,
    quota character varying(50) NOT NULL,
    category character varying(50) NOT NULL,
    fee numeric,
    stipend_year_1 numeric,
    stipend_year_2 numeric,
    stipend_year_3 numeric,
    bond_years integer DEFAULT 0,
    bond_penalty numeric DEFAULT 0,
    beds integer,
    degree_type character varying(50),
    course_type character varying(50),
    is_active boolean DEFAULT true,
    created_at timestamp with time zone DEFAULT now() NOT NULL,
    updated_at timestamp with time zone DEFAULT now() NOT NULL,
    created_by uuid,
    updated_by uuid,
    CONSTRAINT pg_course_seats_course_type_check CHECK (((course_type)::text = ANY ((ARRAY['Clinical'::character varying, 'Non-Clinical'::character varying, 'Para-Clinical'::character varying, 'Pre-Clinical'::character varying])::text[]))),
    CONSTRAINT pg_course_seats_degree_type_check CHECK (((degree_type)::text = ANY ((ARRAY['MD'::character varying, 'MS'::character varying, 'MCh'::character varying, 'DM'::character varying, 'Diploma'::character varying, 'DNB'::character varying, 'MPH'::character varying])::text[]))),
    CONSTRAINT pg_course_seats_institute_type_check CHECK (((institute_type)::text = ANY ((ARRAY['Government'::character varying, 'Private'::character varying, 'Deemed'::character varying])::text[])))
);


ALTER TABLE public.pg_course_seats OWNER TO postgres;

--
-- TOC entry 292 (class 1259 OID 17971)
-- Name: predictor_logs; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.predictor_logs (
    id uuid DEFAULT gen_random_uuid() NOT NULL,
    user_id uuid,
    neet_type public.neet_type NOT NULL,
    rank integer NOT NULL,
    category text,
    state text,
    budget integer,
    preferences jsonb,
    results_count integer,
    created_at timestamp with time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.predictor_logs OWNER TO postgres;

--
-- TOC entry 275 (class 1259 OID 17570)
-- Name: profiles; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.profiles (
    id uuid DEFAULT gen_random_uuid() NOT NULL,
    user_id uuid NOT NULL,
    name text NOT NULL,
    email text,
    phone text,
    avatar_url text,
    user_type text DEFAULT 'student'::text NOT NULL,
    created_at timestamp with time zone DEFAULT now() NOT NULL,
    updated_at timestamp with time zone DEFAULT now() NOT NULL,
    CONSTRAINT profiles_user_type_check CHECK ((user_type = ANY (ARRAY['student'::text, 'parent'::text])))
);


ALTER TABLE public.profiles OWNER TO postgres;

--
-- TOC entry 293 (class 1259 OID 17985)
-- Name: saved_colleges; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.saved_colleges (
    id uuid DEFAULT gen_random_uuid() NOT NULL,
    profile_id uuid NOT NULL,
    college_id uuid NOT NULL,
    course_id uuid,
    notes text,
    created_at timestamp with time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.saved_colleges OWNER TO postgres;

--
-- TOC entry 283 (class 1259 OID 17770)
-- Name: seat_matrix; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.seat_matrix (
    id uuid DEFAULT gen_random_uuid() NOT NULL,
    course_id uuid NOT NULL,
    round_id uuid NOT NULL,
    category text NOT NULL,
    quota text,
    total_seats integer DEFAULT 0 NOT NULL,
    filled_seats integer DEFAULT 0 NOT NULL,
    vacant_seats integer DEFAULT 0 NOT NULL,
    created_by uuid,
    updated_by uuid,
    created_at timestamp with time zone DEFAULT now() NOT NULL,
    updated_at timestamp with time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.seat_matrix OWNER TO postgres;

--
-- TOC entry 276 (class 1259 OID 17589)
-- Name: student_profiles; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.student_profiles (
    id uuid DEFAULT gen_random_uuid() NOT NULL,
    profile_id uuid NOT NULL,
    neet_type public.neet_type DEFAULT 'UG'::public.neet_type NOT NULL,
    neet_rank integer,
    neet_score integer,
    category text,
    state text,
    parent_profile_id uuid,
    created_at timestamp with time zone DEFAULT now() NOT NULL,
    updated_at timestamp with time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.student_profiles OWNER TO postgres;

--
-- TOC entry 286 (class 1259 OID 17853)
-- Name: subscription_plans; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.subscription_plans (
    id uuid DEFAULT gen_random_uuid() NOT NULL,
    name text NOT NULL,
    description text,
    price numeric(10,2) NOT NULL,
    duration_months integer NOT NULL,
    neet_type public.neet_type,
    features jsonb,
    is_recommended boolean DEFAULT false NOT NULL,
    is_active boolean DEFAULT true NOT NULL,
    created_by uuid,
    updated_by uuid,
    created_at timestamp with time zone DEFAULT now() NOT NULL,
    updated_at timestamp with time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.subscription_plans OWNER TO postgres;

--
-- TOC entry 305 (class 1259 OID 18392)
-- Name: support_tickets; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.support_tickets (
    id uuid DEFAULT gen_random_uuid() NOT NULL,
    profile_id uuid NOT NULL,
    subject text NOT NULL,
    description text NOT NULL,
    category text DEFAULT 'general'::text,
    priority text DEFAULT 'medium'::text,
    status text DEFAULT 'open'::text,
    assigned_to uuid,
    resolved_at timestamp with time zone,
    created_at timestamp with time zone DEFAULT now() NOT NULL,
    updated_at timestamp with time zone DEFAULT now() NOT NULL,
    CONSTRAINT support_tickets_category_check CHECK ((category = ANY (ARRAY['general'::text, 'technical'::text, 'billing'::text, 'counseling'::text, 'data'::text]))),
    CONSTRAINT support_tickets_priority_check CHECK ((priority = ANY (ARRAY['low'::text, 'medium'::text, 'high'::text, 'urgent'::text]))),
    CONSTRAINT support_tickets_status_check CHECK ((status = ANY (ARRAY['open'::text, 'in_progress'::text, 'resolved'::text, 'closed'::text])))
);


ALTER TABLE public.support_tickets OWNER TO postgres;

--
-- TOC entry 306 (class 1259 OID 18418)
-- Name: ticket_messages; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.ticket_messages (
    id uuid DEFAULT gen_random_uuid() NOT NULL,
    ticket_id uuid NOT NULL,
    sender_id uuid NOT NULL,
    message text NOT NULL,
    is_internal boolean DEFAULT false,
    created_at timestamp with time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.ticket_messages OWNER TO postgres;

--
-- TOC entry 274 (class 1259 OID 17551)
-- Name: user_roles; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.user_roles (
    id uuid DEFAULT gen_random_uuid() NOT NULL,
    user_id uuid NOT NULL,
    role public.app_role NOT NULL,
    assigned_by uuid,
    created_at timestamp with time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.user_roles OWNER TO postgres;

--
-- TOC entry 287 (class 1259 OID 17875)
-- Name: user_subscriptions; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.user_subscriptions (
    id uuid DEFAULT gen_random_uuid() NOT NULL,
    profile_id uuid NOT NULL,
    plan_id uuid NOT NULL,
    status public.subscription_status DEFAULT 'pending'::public.subscription_status NOT NULL,
    start_date timestamp with time zone,
    end_date timestamp with time zone,
    created_at timestamp with time zone DEFAULT now() NOT NULL,
    updated_at timestamp with time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.user_subscriptions OWNER TO postgres;

--
-- TOC entry 4350 (class 0 OID 18077)
-- Dependencies: 297
-- Data for Name: activity_logs; Type: TABLE DATA; Schema: public; Owner: postgres
--

COPY public.activity_logs (id, user_id, action, entity_type, entity_id, old_data, new_data, ip_address, user_agent, created_at) FROM stdin;
\.


--
-- TOC entry 4351 (class 0 OID 18195)
-- Dependencies: 298
-- Data for Name: allotments; Type: TABLE DATA; Schema: public; Owner: postgres
--

COPY public.allotments (id, year, round, state_rank, all_india_rank, state, college_id, course_id, quota, category, fee, stipend_year_1, stipend_year_2, stipend_year_3, bond_years, bond_penalty, beds, admission_status, reporting_date, neet_type, created_at, updated_at, created_by, updated_by) FROM stdin;
\.


--
-- TOC entry 4343 (class 0 OID 17935)
-- Dependencies: 290
-- Data for Name: announcements; Type: TABLE DATA; Schema: public; Owner: postgres
--

COPY public.announcements (id, title, message, type, neet_type, is_important, status, author_id, published_at, expires_at, created_at, updated_at) FROM stdin;
\.


--
-- TOC entry 4348 (class 0 OID 18037)
-- Dependencies: 295
-- Data for Name: choice_list_items; Type: TABLE DATA; Schema: public; Owner: postgres
--

COPY public.choice_list_items (id, choice_list_id, college_id, course_id, priority, created_at) FROM stdin;
\.


--
-- TOC entry 4347 (class 0 OID 18011)
-- Dependencies: 294
-- Data for Name: choice_lists; Type: TABLE DATA; Schema: public; Owner: postgres
--

COPY public.choice_lists (id, profile_id, name, authority_id, round_id, is_active, created_at, updated_at, approved_by, approval_status) FROM stdin;
\.


--
-- TOC entry 4337 (class 0 OID 17803)
-- Dependencies: 284
-- Data for Name: closing_ranks; Type: TABLE DATA; Schema: public; Owner: postgres
--

COPY public.closing_ranks (id, course_id, round_id, category, quota, opening_rank, closing_rank, created_by, updated_by, created_at, updated_at) FROM stdin;
\.


--
-- TOC entry 4338 (class 0 OID 17833)
-- Dependencies: 285
-- Data for Name: closing_ranks_versions; Type: TABLE DATA; Schema: public; Owner: postgres
--

COPY public.closing_ranks_versions (id, closing_rank_id, course_id, round_id, category, quota, opening_rank, closing_rank, version, changed_by, created_at) FROM stdin;
\.


--
-- TOC entry 4354 (class 0 OID 18299)
-- Dependencies: 301
-- Data for Name: coaching_institutes; Type: TABLE DATA; Schema: public; Owner: postgres
--

COPY public.coaching_institutes (id, profile_id, institute_name, institute_code, address, city, state, phone, logo_url, is_verified, created_at, updated_at) FROM stdin;
\.


--
-- TOC entry 4335 (class 0 OID 17742)
-- Dependencies: 282
-- Data for Name: college_bonds; Type: TABLE DATA; Schema: public; Owner: postgres
--

COPY public.college_bonds (id, course_id, academic_year, bond_amount, bond_duration_years, service_required, service_duration_years, description, created_by, updated_by, created_at, updated_at) FROM stdin;
\.


--
-- TOC entry 4334 (class 0 OID 17714)
-- Dependencies: 281
-- Data for Name: college_fees; Type: TABLE DATA; Schema: public; Owner: postgres
--

COPY public.college_fees (id, course_id, academic_year, tuition_fee, hostel_fee, other_fees, total_fee, currency, created_by, updated_by, created_at, updated_at) FROM stdin;
\.


--
-- TOC entry 4332 (class 0 OID 17663)
-- Dependencies: 279
-- Data for Name: colleges; Type: TABLE DATA; Schema: public; Owner: postgres
--

COPY public.colleges (id, name, code, state, city, type, established_year, university, website, address, description, image_url, rating, ranking, is_active, created_by, updated_by, created_at, updated_at, beds) FROM stdin;
\.


--
-- TOC entry 4342 (class 0 OID 17916)
-- Dependencies: 289
-- Data for Name: content_articles; Type: TABLE DATA; Schema: public; Owner: postgres
--

COPY public.content_articles (id, title, slug, excerpt, content, category, image_url, status, is_premium, author_id, published_at, created_at, updated_at) FROM stdin;
\.


--
-- TOC entry 4330 (class 0 OID 17612)
-- Dependencies: 277
-- Data for Name: counseling_authorities; Type: TABLE DATA; Schema: public; Owner: postgres
--

COPY public.counseling_authorities (id, name, code, description, website, neet_type, is_active, created_by, updated_by, created_at, updated_at, counseling_type) FROM stdin;
\.


--
-- TOC entry 4331 (class 0 OID 17635)
-- Dependencies: 278
-- Data for Name: counseling_rounds; Type: TABLE DATA; Schema: public; Owner: postgres
--

COPY public.counseling_rounds (id, authority_id, year, round_number, round_name, start_date, end_date, choice_filling_start, choice_filling_end, result_date, is_active, created_by, updated_by, created_at, updated_at) FROM stdin;
\.


--
-- TOC entry 4357 (class 0 OID 18369)
-- Dependencies: 304
-- Data for Name: counsellor_notes; Type: TABLE DATA; Schema: public; Owner: postgres
--

COPY public.counsellor_notes (id, counsellor_id, student_profile_id, note_type, content, is_private, created_at, updated_at) FROM stdin;
\.


--
-- TOC entry 4355 (class 0 OID 18317)
-- Dependencies: 302
-- Data for Name: counsellors; Type: TABLE DATA; Schema: public; Owner: postgres
--

COPY public.counsellors (id, profile_id, institute_id, specialization, experience_years, is_verified, created_at, updated_at) FROM stdin;
\.


--
-- TOC entry 4333 (class 0 OID 17686)
-- Dependencies: 280
-- Data for Name: courses; Type: TABLE DATA; Schema: public; Owner: postgres
--

COPY public.courses (id, college_id, name, code, neet_type, duration, total_seats, is_active, created_by, updated_by, created_at, updated_at, degree_type, course_type) FROM stdin;
\.


--
-- TOC entry 4344 (class 0 OID 17953)
-- Dependencies: 291
-- Data for Name: data_imports; Type: TABLE DATA; Schema: public; Owner: postgres
--

COPY public.data_imports (id, file_name, file_url, import_type, status, total_rows, processed_rows, error_rows, errors, uploaded_by, processed_at, created_at, updated_at) FROM stdin;
\.


--
-- TOC entry 4356 (class 0 OID 18341)
-- Dependencies: 303
-- Data for Name: institute_students; Type: TABLE DATA; Schema: public; Owner: postgres
--

COPY public.institute_students (id, institute_id, student_profile_id, counsellor_id, enrolled_at, status) FROM stdin;
\.


--
-- TOC entry 4349 (class 0 OID 18061)
-- Dependencies: 296
-- Data for Name: notifications; Type: TABLE DATA; Schema: public; Owner: postgres
--

COPY public.notifications (id, recipient_id, title, message, type, is_read, read_at, metadata, created_at) FROM stdin;
\.


--
-- TOC entry 4341 (class 0 OID 17894)
-- Dependencies: 288
-- Data for Name: payments; Type: TABLE DATA; Schema: public; Owner: postgres
--

COPY public.payments (id, subscription_id, profile_id, amount, currency, payment_method, transaction_id, status, payment_date, metadata, created_at, updated_at) FROM stdin;
\.


--
-- TOC entry 4353 (class 0 OID 18261)
-- Dependencies: 300
-- Data for Name: pg_closing_ranks; Type: TABLE DATA; Schema: public; Owner: postgres
--

COPY public.pg_closing_ranks (id, seat_id, year, round, closing_rank, opening_rank, created_at, created_by) FROM stdin;
\.


--
-- TOC entry 4352 (class 0 OID 18233)
-- Dependencies: 299
-- Data for Name: pg_course_seats; Type: TABLE DATA; Schema: public; Owner: postgres
--

COPY public.pg_course_seats (id, college_id, course_id, state, institute_type, quota, category, fee, stipend_year_1, stipend_year_2, stipend_year_3, bond_years, bond_penalty, beds, degree_type, course_type, is_active, created_at, updated_at, created_by, updated_by) FROM stdin;
\.


--
-- TOC entry 4345 (class 0 OID 17971)
-- Dependencies: 292
-- Data for Name: predictor_logs; Type: TABLE DATA; Schema: public; Owner: postgres
--

COPY public.predictor_logs (id, user_id, neet_type, rank, category, state, budget, preferences, results_count, created_at) FROM stdin;
\.


--
-- TOC entry 4328 (class 0 OID 17570)
-- Dependencies: 275
-- Data for Name: profiles; Type: TABLE DATA; Schema: public; Owner: postgres
--

COPY public.profiles (id, user_id, name, email, phone, avatar_url, user_type, created_at, updated_at) FROM stdin;
\.


--
-- TOC entry 4346 (class 0 OID 17985)
-- Dependencies: 293
-- Data for Name: saved_colleges; Type: TABLE DATA; Schema: public; Owner: postgres
--

COPY public.saved_colleges (id, profile_id, college_id, course_id, notes, created_at) FROM stdin;
\.


--
-- TOC entry 4336 (class 0 OID 17770)
-- Dependencies: 283
-- Data for Name: seat_matrix; Type: TABLE DATA; Schema: public; Owner: postgres
--

COPY public.seat_matrix (id, course_id, round_id, category, quota, total_seats, filled_seats, vacant_seats, created_by, updated_by, created_at, updated_at) FROM stdin;
\.


--
-- TOC entry 4329 (class 0 OID 17589)
-- Dependencies: 276
-- Data for Name: student_profiles; Type: TABLE DATA; Schema: public; Owner: postgres
--

COPY public.student_profiles (id, profile_id, neet_type, neet_rank, neet_score, category, state, parent_profile_id, created_at, updated_at) FROM stdin;
\.


--
-- TOC entry 4339 (class 0 OID 17853)
-- Dependencies: 286
-- Data for Name: subscription_plans; Type: TABLE DATA; Schema: public; Owner: postgres
--

COPY public.subscription_plans (id, name, description, price, duration_months, neet_type, features, is_recommended, is_active, created_by, updated_by, created_at, updated_at) FROM stdin;
\.


--
-- TOC entry 4358 (class 0 OID 18392)
-- Dependencies: 305
-- Data for Name: support_tickets; Type: TABLE DATA; Schema: public; Owner: postgres
--

COPY public.support_tickets (id, profile_id, subject, description, category, priority, status, assigned_to, resolved_at, created_at, updated_at) FROM stdin;
\.


--
-- TOC entry 4359 (class 0 OID 18418)
-- Dependencies: 306
-- Data for Name: ticket_messages; Type: TABLE DATA; Schema: public; Owner: postgres
--

COPY public.ticket_messages (id, ticket_id, sender_id, message, is_internal, created_at) FROM stdin;
\.


--
-- TOC entry 4327 (class 0 OID 17551)
-- Dependencies: 274
-- Data for Name: user_roles; Type: TABLE DATA; Schema: public; Owner: postgres
--

COPY public.user_roles (id, user_id, role, assigned_by, created_at) FROM stdin;
\.


--
-- TOC entry 4340 (class 0 OID 17875)
-- Dependencies: 287
-- Data for Name: user_subscriptions; Type: TABLE DATA; Schema: public; Owner: postgres
--

COPY public.user_subscriptions (id, profile_id, plan_id, status, start_date, end_date, created_at, updated_at) FROM stdin;
\.


--
-- TOC entry 3905 (class 2606 OID 18085)
-- Name: activity_logs activity_logs_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.activity_logs
    ADD CONSTRAINT activity_logs_pkey PRIMARY KEY (id);


--
-- TOC entry 3907 (class 2606 OID 18206)
-- Name: allotments allotments_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.allotments
    ADD CONSTRAINT allotments_pkey PRIMARY KEY (id);


--
-- TOC entry 3882 (class 2606 OID 17947)
-- Name: announcements announcements_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.announcements
    ADD CONSTRAINT announcements_pkey PRIMARY KEY (id);


--
-- TOC entry 3897 (class 2606 OID 18045)
-- Name: choice_list_items choice_list_items_choice_list_id_priority_key; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.choice_list_items
    ADD CONSTRAINT choice_list_items_choice_list_id_priority_key UNIQUE (choice_list_id, priority);


--
-- TOC entry 3899 (class 2606 OID 18043)
-- Name: choice_list_items choice_list_items_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.choice_list_items
    ADD CONSTRAINT choice_list_items_pkey PRIMARY KEY (id);


--
-- TOC entry 3895 (class 2606 OID 18021)
-- Name: choice_lists choice_lists_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.choice_lists
    ADD CONSTRAINT choice_lists_pkey PRIMARY KEY (id);


--
-- TOC entry 3861 (class 2606 OID 17812)
-- Name: closing_ranks closing_ranks_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.closing_ranks
    ADD CONSTRAINT closing_ranks_pkey PRIMARY KEY (id);


--
-- TOC entry 3868 (class 2606 OID 17842)
-- Name: closing_ranks_versions closing_ranks_versions_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.closing_ranks_versions
    ADD CONSTRAINT closing_ranks_versions_pkey PRIMARY KEY (id);


--
-- TOC entry 3944 (class 2606 OID 18309)
-- Name: coaching_institutes coaching_institutes_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.coaching_institutes
    ADD CONSTRAINT coaching_institutes_pkey PRIMARY KEY (id);


--
-- TOC entry 3946 (class 2606 OID 18311)
-- Name: coaching_institutes coaching_institutes_profile_id_key; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.coaching_institutes
    ADD CONSTRAINT coaching_institutes_profile_id_key UNIQUE (profile_id);


--
-- TOC entry 3853 (class 2606 OID 17754)
-- Name: college_bonds college_bonds_course_id_academic_year_key; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.college_bonds
    ADD CONSTRAINT college_bonds_course_id_academic_year_key UNIQUE (course_id, academic_year);


--
-- TOC entry 3855 (class 2606 OID 17752)
-- Name: college_bonds college_bonds_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.college_bonds
    ADD CONSTRAINT college_bonds_pkey PRIMARY KEY (id);


--
-- TOC entry 3849 (class 2606 OID 17726)
-- Name: college_fees college_fees_course_id_academic_year_key; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.college_fees
    ADD CONSTRAINT college_fees_course_id_academic_year_key UNIQUE (course_id, academic_year);


--
-- TOC entry 3851 (class 2606 OID 17724)
-- Name: college_fees college_fees_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.college_fees
    ADD CONSTRAINT college_fees_pkey PRIMARY KEY (id);


--
-- TOC entry 3837 (class 2606 OID 17675)
-- Name: colleges colleges_code_key; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.colleges
    ADD CONSTRAINT colleges_code_key UNIQUE (code);


--
-- TOC entry 3839 (class 2606 OID 17673)
-- Name: colleges colleges_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.colleges
    ADD CONSTRAINT colleges_pkey PRIMARY KEY (id);


--
-- TOC entry 3876 (class 2606 OID 17927)
-- Name: content_articles content_articles_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.content_articles
    ADD CONSTRAINT content_articles_pkey PRIMARY KEY (id);


--
-- TOC entry 3878 (class 2606 OID 17929)
-- Name: content_articles content_articles_slug_key; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.content_articles
    ADD CONSTRAINT content_articles_slug_key UNIQUE (slug);


--
-- TOC entry 3829 (class 2606 OID 17624)
-- Name: counseling_authorities counseling_authorities_code_key; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.counseling_authorities
    ADD CONSTRAINT counseling_authorities_code_key UNIQUE (code);


--
-- TOC entry 3831 (class 2606 OID 17622)
-- Name: counseling_authorities counseling_authorities_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.counseling_authorities
    ADD CONSTRAINT counseling_authorities_pkey PRIMARY KEY (id);


--
-- TOC entry 3833 (class 2606 OID 17647)
-- Name: counseling_rounds counseling_rounds_authority_id_year_round_number_key; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.counseling_rounds
    ADD CONSTRAINT counseling_rounds_authority_id_year_round_number_key UNIQUE (authority_id, year, round_number);


--
-- TOC entry 3835 (class 2606 OID 17645)
-- Name: counseling_rounds counseling_rounds_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.counseling_rounds
    ADD CONSTRAINT counseling_rounds_pkey PRIMARY KEY (id);


--
-- TOC entry 3959 (class 2606 OID 18381)
-- Name: counsellor_notes counsellor_notes_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.counsellor_notes
    ADD CONSTRAINT counsellor_notes_pkey PRIMARY KEY (id);


--
-- TOC entry 3948 (class 2606 OID 18328)
-- Name: counsellors counsellors_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.counsellors
    ADD CONSTRAINT counsellors_pkey PRIMARY KEY (id);


--
-- TOC entry 3950 (class 2606 OID 18330)
-- Name: counsellors counsellors_profile_id_key; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.counsellors
    ADD CONSTRAINT counsellors_profile_id_key UNIQUE (profile_id);


--
-- TOC entry 3843 (class 2606 OID 17698)
-- Name: courses courses_college_id_name_neet_type_key; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.courses
    ADD CONSTRAINT courses_college_id_name_neet_type_key UNIQUE (college_id, name, neet_type);


--
-- TOC entry 3845 (class 2606 OID 17696)
-- Name: courses courses_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.courses
    ADD CONSTRAINT courses_pkey PRIMARY KEY (id);


--
-- TOC entry 3885 (class 2606 OID 17965)
-- Name: data_imports data_imports_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.data_imports
    ADD CONSTRAINT data_imports_pkey PRIMARY KEY (id);


--
-- TOC entry 3955 (class 2606 OID 18353)
-- Name: institute_students institute_students_institute_id_student_profile_id_key; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.institute_students
    ADD CONSTRAINT institute_students_institute_id_student_profile_id_key UNIQUE (institute_id, student_profile_id);


--
-- TOC entry 3957 (class 2606 OID 18351)
-- Name: institute_students institute_students_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.institute_students
    ADD CONSTRAINT institute_students_pkey PRIMARY KEY (id);


--
-- TOC entry 3903 (class 2606 OID 18071)
-- Name: notifications notifications_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.notifications
    ADD CONSTRAINT notifications_pkey PRIMARY KEY (id);


--
-- TOC entry 3874 (class 2606 OID 17905)
-- Name: payments payments_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.payments
    ADD CONSTRAINT payments_pkey PRIMARY KEY (id);


--
-- TOC entry 3940 (class 2606 OID 18268)
-- Name: pg_closing_ranks pg_closing_ranks_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.pg_closing_ranks
    ADD CONSTRAINT pg_closing_ranks_pkey PRIMARY KEY (id);


--
-- TOC entry 3942 (class 2606 OID 18270)
-- Name: pg_closing_ranks pg_closing_ranks_seat_id_year_round_key; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.pg_closing_ranks
    ADD CONSTRAINT pg_closing_ranks_seat_id_year_round_key UNIQUE (seat_id, year, round);


--
-- TOC entry 3931 (class 2606 OID 18250)
-- Name: pg_course_seats pg_course_seats_college_id_course_id_quota_category_key; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.pg_course_seats
    ADD CONSTRAINT pg_course_seats_college_id_course_id_quota_category_key UNIQUE (college_id, course_id, quota, category);


--
-- TOC entry 3933 (class 2606 OID 18248)
-- Name: pg_course_seats pg_course_seats_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.pg_course_seats
    ADD CONSTRAINT pg_course_seats_pkey PRIMARY KEY (id);


--
-- TOC entry 3889 (class 2606 OID 17979)
-- Name: predictor_logs predictor_logs_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.predictor_logs
    ADD CONSTRAINT predictor_logs_pkey PRIMARY KEY (id);


--
-- TOC entry 3820 (class 2606 OID 17581)
-- Name: profiles profiles_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.profiles
    ADD CONSTRAINT profiles_pkey PRIMARY KEY (id);


--
-- TOC entry 3822 (class 2606 OID 17583)
-- Name: profiles profiles_user_id_key; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.profiles
    ADD CONSTRAINT profiles_user_id_key UNIQUE (user_id);


--
-- TOC entry 3891 (class 2606 OID 17993)
-- Name: saved_colleges saved_colleges_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.saved_colleges
    ADD CONSTRAINT saved_colleges_pkey PRIMARY KEY (id);


--
-- TOC entry 3893 (class 2606 OID 17995)
-- Name: saved_colleges saved_colleges_profile_id_college_id_course_id_key; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.saved_colleges
    ADD CONSTRAINT saved_colleges_profile_id_college_id_course_id_key UNIQUE (profile_id, college_id, course_id);


--
-- TOC entry 3859 (class 2606 OID 17782)
-- Name: seat_matrix seat_matrix_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.seat_matrix
    ADD CONSTRAINT seat_matrix_pkey PRIMARY KEY (id);


--
-- TOC entry 3825 (class 2606 OID 17599)
-- Name: student_profiles student_profiles_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.student_profiles
    ADD CONSTRAINT student_profiles_pkey PRIMARY KEY (id);


--
-- TOC entry 3827 (class 2606 OID 17601)
-- Name: student_profiles student_profiles_profile_id_key; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.student_profiles
    ADD CONSTRAINT student_profiles_profile_id_key UNIQUE (profile_id);


--
-- TOC entry 3870 (class 2606 OID 17864)
-- Name: subscription_plans subscription_plans_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.subscription_plans
    ADD CONSTRAINT subscription_plans_pkey PRIMARY KEY (id);


--
-- TOC entry 3965 (class 2606 OID 18407)
-- Name: support_tickets support_tickets_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.support_tickets
    ADD CONSTRAINT support_tickets_pkey PRIMARY KEY (id);


--
-- TOC entry 3968 (class 2606 OID 18427)
-- Name: ticket_messages ticket_messages_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.ticket_messages
    ADD CONSTRAINT ticket_messages_pkey PRIMARY KEY (id);


--
-- TOC entry 3815 (class 2606 OID 17557)
-- Name: user_roles user_roles_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.user_roles
    ADD CONSTRAINT user_roles_pkey PRIMARY KEY (id);


--
-- TOC entry 3817 (class 2606 OID 17559)
-- Name: user_roles user_roles_user_id_role_key; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.user_roles
    ADD CONSTRAINT user_roles_user_id_role_key UNIQUE (user_id, role);


--
-- TOC entry 3872 (class 2606 OID 17883)
-- Name: user_subscriptions user_subscriptions_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.user_subscriptions
    ADD CONSTRAINT user_subscriptions_pkey PRIMARY KEY (id);


--
-- TOC entry 3908 (class 1259 OID 18226)
-- Name: idx_allotments_air; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX idx_allotments_air ON public.allotments USING btree (all_india_rank);


--
-- TOC entry 3909 (class 1259 OID 18221)
-- Name: idx_allotments_category; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX idx_allotments_category ON public.allotments USING btree (category);


--
-- TOC entry 3910 (class 1259 OID 18223)
-- Name: idx_allotments_college; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX idx_allotments_college ON public.allotments USING btree (college_id);


--
-- TOC entry 3911 (class 1259 OID 18224)
-- Name: idx_allotments_course; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX idx_allotments_course ON public.allotments USING btree (course_id);


--
-- TOC entry 3912 (class 1259 OID 18222)
-- Name: idx_allotments_neet_type; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX idx_allotments_neet_type ON public.allotments USING btree (neet_type);


--
-- TOC entry 3913 (class 1259 OID 18220)
-- Name: idx_allotments_quota; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX idx_allotments_quota ON public.allotments USING btree (quota);


--
-- TOC entry 3914 (class 1259 OID 18218)
-- Name: idx_allotments_round; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX idx_allotments_round ON public.allotments USING btree (round);


--
-- TOC entry 3915 (class 1259 OID 18219)
-- Name: idx_allotments_state; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX idx_allotments_state ON public.allotments USING btree (state);


--
-- TOC entry 3916 (class 1259 OID 18225)
-- Name: idx_allotments_state_rank; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX idx_allotments_state_rank ON public.allotments USING btree (state_rank);


--
-- TOC entry 3917 (class 1259 OID 18217)
-- Name: idx_allotments_year; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX idx_allotments_year ON public.allotments USING btree (year);


--
-- TOC entry 3883 (class 1259 OID 18104)
-- Name: idx_announcements_status; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX idx_announcements_status ON public.announcements USING btree (status);


--
-- TOC entry 3862 (class 1259 OID 18230)
-- Name: idx_closing_ranks_category; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX idx_closing_ranks_category ON public.closing_ranks USING btree (category);


--
-- TOC entry 3863 (class 1259 OID 18232)
-- Name: idx_closing_ranks_closing_rank; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX idx_closing_ranks_closing_rank ON public.closing_ranks USING btree (closing_rank);


--
-- TOC entry 3864 (class 1259 OID 18098)
-- Name: idx_closing_ranks_course_id; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX idx_closing_ranks_course_id ON public.closing_ranks USING btree (course_id);


--
-- TOC entry 3865 (class 1259 OID 18231)
-- Name: idx_closing_ranks_quota; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX idx_closing_ranks_quota ON public.closing_ranks USING btree (quota);


--
-- TOC entry 3866 (class 1259 OID 18099)
-- Name: idx_closing_ranks_round_id; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX idx_closing_ranks_round_id ON public.closing_ranks USING btree (round_id);


--
-- TOC entry 3840 (class 1259 OID 18094)
-- Name: idx_colleges_state; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX idx_colleges_state ON public.colleges USING btree (state);


--
-- TOC entry 3841 (class 1259 OID 18095)
-- Name: idx_colleges_type; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX idx_colleges_type ON public.colleges USING btree (type);


--
-- TOC entry 3879 (class 1259 OID 18103)
-- Name: idx_content_articles_slug; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX idx_content_articles_slug ON public.content_articles USING btree (slug);


--
-- TOC entry 3880 (class 1259 OID 18102)
-- Name: idx_content_articles_status; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX idx_content_articles_status ON public.content_articles USING btree (status);


--
-- TOC entry 3960 (class 1259 OID 18469)
-- Name: idx_counsellor_notes_counsellor; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX idx_counsellor_notes_counsellor ON public.counsellor_notes USING btree (counsellor_id);


--
-- TOC entry 3961 (class 1259 OID 18470)
-- Name: idx_counsellor_notes_student; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX idx_counsellor_notes_student ON public.counsellor_notes USING btree (student_profile_id);


--
-- TOC entry 3846 (class 1259 OID 18096)
-- Name: idx_courses_college_id; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX idx_courses_college_id ON public.courses USING btree (college_id);


--
-- TOC entry 3847 (class 1259 OID 18097)
-- Name: idx_courses_neet_type; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX idx_courses_neet_type ON public.courses USING btree (neet_type);


--
-- TOC entry 3951 (class 1259 OID 18468)
-- Name: idx_institute_students_counsellor; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX idx_institute_students_counsellor ON public.institute_students USING btree (counsellor_id);


--
-- TOC entry 3952 (class 1259 OID 18466)
-- Name: idx_institute_students_institute; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX idx_institute_students_institute ON public.institute_students USING btree (institute_id);


--
-- TOC entry 3953 (class 1259 OID 18467)
-- Name: idx_institute_students_student; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX idx_institute_students_student ON public.institute_students USING btree (student_profile_id);


--
-- TOC entry 3900 (class 1259 OID 18108)
-- Name: idx_notifications_is_read; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX idx_notifications_is_read ON public.notifications USING btree (is_read);


--
-- TOC entry 3901 (class 1259 OID 18107)
-- Name: idx_notifications_recipient_id; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX idx_notifications_recipient_id ON public.notifications USING btree (recipient_id);


--
-- TOC entry 3934 (class 1259 OID 18291)
-- Name: idx_pg_ranks_closing; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX idx_pg_ranks_closing ON public.pg_closing_ranks USING btree (closing_rank);


--
-- TOC entry 3935 (class 1259 OID 18290)
-- Name: idx_pg_ranks_round; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX idx_pg_ranks_round ON public.pg_closing_ranks USING btree (round);


--
-- TOC entry 3936 (class 1259 OID 18288)
-- Name: idx_pg_ranks_seat; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX idx_pg_ranks_seat ON public.pg_closing_ranks USING btree (seat_id);


--
-- TOC entry 3937 (class 1259 OID 18289)
-- Name: idx_pg_ranks_year; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX idx_pg_ranks_year ON public.pg_closing_ranks USING btree (year);


--
-- TOC entry 3938 (class 1259 OID 18292)
-- Name: idx_pg_ranks_year_round; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX idx_pg_ranks_year_round ON public.pg_closing_ranks USING btree (year, round);


--
-- TOC entry 3918 (class 1259 OID 18283)
-- Name: idx_pg_seats_beds; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX idx_pg_seats_beds ON public.pg_course_seats USING btree (beds);


--
-- TOC entry 3919 (class 1259 OID 18282)
-- Name: idx_pg_seats_bond_penalty; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX idx_pg_seats_bond_penalty ON public.pg_course_seats USING btree (bond_penalty);


--
-- TOC entry 3920 (class 1259 OID 18281)
-- Name: idx_pg_seats_bond_years; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX idx_pg_seats_bond_years ON public.pg_course_seats USING btree (bond_years);


--
-- TOC entry 3921 (class 1259 OID 18279)
-- Name: idx_pg_seats_category; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX idx_pg_seats_category ON public.pg_course_seats USING btree (category);


--
-- TOC entry 3922 (class 1259 OID 18286)
-- Name: idx_pg_seats_college; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX idx_pg_seats_college ON public.pg_course_seats USING btree (college_id);


--
-- TOC entry 3923 (class 1259 OID 18287)
-- Name: idx_pg_seats_course; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX idx_pg_seats_course ON public.pg_course_seats USING btree (course_id);


--
-- TOC entry 3924 (class 1259 OID 18285)
-- Name: idx_pg_seats_course_type; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX idx_pg_seats_course_type ON public.pg_course_seats USING btree (course_type);


--
-- TOC entry 3925 (class 1259 OID 18284)
-- Name: idx_pg_seats_degree_type; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX idx_pg_seats_degree_type ON public.pg_course_seats USING btree (degree_type);


--
-- TOC entry 3926 (class 1259 OID 18280)
-- Name: idx_pg_seats_fee; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX idx_pg_seats_fee ON public.pg_course_seats USING btree (fee);


--
-- TOC entry 3927 (class 1259 OID 18277)
-- Name: idx_pg_seats_institute_type; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX idx_pg_seats_institute_type ON public.pg_course_seats USING btree (institute_type);


--
-- TOC entry 3928 (class 1259 OID 18278)
-- Name: idx_pg_seats_quota; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX idx_pg_seats_quota ON public.pg_course_seats USING btree (quota);


--
-- TOC entry 3929 (class 1259 OID 18276)
-- Name: idx_pg_seats_state; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX idx_pg_seats_state ON public.pg_course_seats USING btree (state);


--
-- TOC entry 3886 (class 1259 OID 18106)
-- Name: idx_predictor_logs_created_at; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX idx_predictor_logs_created_at ON public.predictor_logs USING btree (created_at);


--
-- TOC entry 3887 (class 1259 OID 18105)
-- Name: idx_predictor_logs_user_id; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX idx_predictor_logs_user_id ON public.predictor_logs USING btree (user_id);


--
-- TOC entry 3818 (class 1259 OID 18092)
-- Name: idx_profiles_user_id; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX idx_profiles_user_id ON public.profiles USING btree (user_id);


--
-- TOC entry 3856 (class 1259 OID 18100)
-- Name: idx_seat_matrix_course_id; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX idx_seat_matrix_course_id ON public.seat_matrix USING btree (course_id);


--
-- TOC entry 3857 (class 1259 OID 18101)
-- Name: idx_seat_matrix_round_id; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX idx_seat_matrix_round_id ON public.seat_matrix USING btree (round_id);


--
-- TOC entry 3823 (class 1259 OID 18093)
-- Name: idx_student_profiles_profile_id; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX idx_student_profiles_profile_id ON public.student_profiles USING btree (profile_id);


--
-- TOC entry 3962 (class 1259 OID 18471)
-- Name: idx_support_tickets_profile; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX idx_support_tickets_profile ON public.support_tickets USING btree (profile_id);


--
-- TOC entry 3963 (class 1259 OID 18472)
-- Name: idx_support_tickets_status; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX idx_support_tickets_status ON public.support_tickets USING btree (status);


--
-- TOC entry 3966 (class 1259 OID 18473)
-- Name: idx_ticket_messages_ticket; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX idx_ticket_messages_ticket ON public.ticket_messages USING btree (ticket_id);


--
-- TOC entry 3813 (class 1259 OID 18091)
-- Name: idx_user_roles_user_id; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX idx_user_roles_user_id ON public.user_roles USING btree (user_id);


--
-- TOC entry 4056 (class 2620 OID 18229)
-- Name: allotments update_allotments_updated_at; Type: TRIGGER; Schema: public; Owner: postgres
--

CREATE TRIGGER update_allotments_updated_at BEFORE UPDATE ON public.allotments FOR EACH ROW EXECUTE FUNCTION public.update_updated_at_column();


--
-- TOC entry 4053 (class 2620 OID 18128)
-- Name: announcements update_announcements_updated_at; Type: TRIGGER; Schema: public; Owner: postgres
--

CREATE TRIGGER update_announcements_updated_at BEFORE UPDATE ON public.announcements FOR EACH ROW EXECUTE FUNCTION public.update_updated_at_column();


--
-- TOC entry 4055 (class 2620 OID 18130)
-- Name: choice_lists update_choice_lists_updated_at; Type: TRIGGER; Schema: public; Owner: postgres
--

CREATE TRIGGER update_choice_lists_updated_at BEFORE UPDATE ON public.choice_lists FOR EACH ROW EXECUTE FUNCTION public.update_updated_at_column();


--
-- TOC entry 4048 (class 2620 OID 18123)
-- Name: closing_ranks update_closing_ranks_updated_at; Type: TRIGGER; Schema: public; Owner: postgres
--

CREATE TRIGGER update_closing_ranks_updated_at BEFORE UPDATE ON public.closing_ranks FOR EACH ROW EXECUTE FUNCTION public.update_updated_at_column();


--
-- TOC entry 4058 (class 2620 OID 18474)
-- Name: coaching_institutes update_coaching_institutes_updated_at; Type: TRIGGER; Schema: public; Owner: postgres
--

CREATE TRIGGER update_coaching_institutes_updated_at BEFORE UPDATE ON public.coaching_institutes FOR EACH ROW EXECUTE FUNCTION public.update_updated_at_column();


--
-- TOC entry 4046 (class 2620 OID 18119)
-- Name: college_bonds update_college_bonds_updated_at; Type: TRIGGER; Schema: public; Owner: postgres
--

CREATE TRIGGER update_college_bonds_updated_at BEFORE UPDATE ON public.college_bonds FOR EACH ROW EXECUTE FUNCTION public.update_updated_at_column();


--
-- TOC entry 4045 (class 2620 OID 18118)
-- Name: college_fees update_college_fees_updated_at; Type: TRIGGER; Schema: public; Owner: postgres
--

CREATE TRIGGER update_college_fees_updated_at BEFORE UPDATE ON public.college_fees FOR EACH ROW EXECUTE FUNCTION public.update_updated_at_column();


--
-- TOC entry 4043 (class 2620 OID 18116)
-- Name: colleges update_colleges_updated_at; Type: TRIGGER; Schema: public; Owner: postgres
--

CREATE TRIGGER update_colleges_updated_at BEFORE UPDATE ON public.colleges FOR EACH ROW EXECUTE FUNCTION public.update_updated_at_column();


--
-- TOC entry 4052 (class 2620 OID 18127)
-- Name: content_articles update_content_articles_updated_at; Type: TRIGGER; Schema: public; Owner: postgres
--

CREATE TRIGGER update_content_articles_updated_at BEFORE UPDATE ON public.content_articles FOR EACH ROW EXECUTE FUNCTION public.update_updated_at_column();


--
-- TOC entry 4041 (class 2620 OID 18120)
-- Name: counseling_authorities update_counseling_authorities_updated_at; Type: TRIGGER; Schema: public; Owner: postgres
--

CREATE TRIGGER update_counseling_authorities_updated_at BEFORE UPDATE ON public.counseling_authorities FOR EACH ROW EXECUTE FUNCTION public.update_updated_at_column();


--
-- TOC entry 4042 (class 2620 OID 18121)
-- Name: counseling_rounds update_counseling_rounds_updated_at; Type: TRIGGER; Schema: public; Owner: postgres
--

CREATE TRIGGER update_counseling_rounds_updated_at BEFORE UPDATE ON public.counseling_rounds FOR EACH ROW EXECUTE FUNCTION public.update_updated_at_column();


--
-- TOC entry 4060 (class 2620 OID 18476)
-- Name: counsellor_notes update_counsellor_notes_updated_at; Type: TRIGGER; Schema: public; Owner: postgres
--

CREATE TRIGGER update_counsellor_notes_updated_at BEFORE UPDATE ON public.counsellor_notes FOR EACH ROW EXECUTE FUNCTION public.update_updated_at_column();


--
-- TOC entry 4059 (class 2620 OID 18475)
-- Name: counsellors update_counsellors_updated_at; Type: TRIGGER; Schema: public; Owner: postgres
--

CREATE TRIGGER update_counsellors_updated_at BEFORE UPDATE ON public.counsellors FOR EACH ROW EXECUTE FUNCTION public.update_updated_at_column();


--
-- TOC entry 4044 (class 2620 OID 18117)
-- Name: courses update_courses_updated_at; Type: TRIGGER; Schema: public; Owner: postgres
--

CREATE TRIGGER update_courses_updated_at BEFORE UPDATE ON public.courses FOR EACH ROW EXECUTE FUNCTION public.update_updated_at_column();


--
-- TOC entry 4054 (class 2620 OID 18129)
-- Name: data_imports update_data_imports_updated_at; Type: TRIGGER; Schema: public; Owner: postgres
--

CREATE TRIGGER update_data_imports_updated_at BEFORE UPDATE ON public.data_imports FOR EACH ROW EXECUTE FUNCTION public.update_updated_at_column();


--
-- TOC entry 4051 (class 2620 OID 18126)
-- Name: payments update_payments_updated_at; Type: TRIGGER; Schema: public; Owner: postgres
--

CREATE TRIGGER update_payments_updated_at BEFORE UPDATE ON public.payments FOR EACH ROW EXECUTE FUNCTION public.update_updated_at_column();


--
-- TOC entry 4057 (class 2620 OID 18297)
-- Name: pg_course_seats update_pg_course_seats_updated_at; Type: TRIGGER; Schema: public; Owner: postgres
--

CREATE TRIGGER update_pg_course_seats_updated_at BEFORE UPDATE ON public.pg_course_seats FOR EACH ROW EXECUTE FUNCTION public.update_updated_at_column();


--
-- TOC entry 4039 (class 2620 OID 18114)
-- Name: profiles update_profiles_updated_at; Type: TRIGGER; Schema: public; Owner: postgres
--

CREATE TRIGGER update_profiles_updated_at BEFORE UPDATE ON public.profiles FOR EACH ROW EXECUTE FUNCTION public.update_updated_at_column();


--
-- TOC entry 4047 (class 2620 OID 18122)
-- Name: seat_matrix update_seat_matrix_updated_at; Type: TRIGGER; Schema: public; Owner: postgres
--

CREATE TRIGGER update_seat_matrix_updated_at BEFORE UPDATE ON public.seat_matrix FOR EACH ROW EXECUTE FUNCTION public.update_updated_at_column();


--
-- TOC entry 4040 (class 2620 OID 18115)
-- Name: student_profiles update_student_profiles_updated_at; Type: TRIGGER; Schema: public; Owner: postgres
--

CREATE TRIGGER update_student_profiles_updated_at BEFORE UPDATE ON public.student_profiles FOR EACH ROW EXECUTE FUNCTION public.update_updated_at_column();


--
-- TOC entry 4049 (class 2620 OID 18124)
-- Name: subscription_plans update_subscription_plans_updated_at; Type: TRIGGER; Schema: public; Owner: postgres
--

CREATE TRIGGER update_subscription_plans_updated_at BEFORE UPDATE ON public.subscription_plans FOR EACH ROW EXECUTE FUNCTION public.update_updated_at_column();


--
-- TOC entry 4061 (class 2620 OID 18477)
-- Name: support_tickets update_support_tickets_updated_at; Type: TRIGGER; Schema: public; Owner: postgres
--

CREATE TRIGGER update_support_tickets_updated_at BEFORE UPDATE ON public.support_tickets FOR EACH ROW EXECUTE FUNCTION public.update_updated_at_column();


--
-- TOC entry 4050 (class 2620 OID 18125)
-- Name: user_subscriptions update_user_subscriptions_updated_at; Type: TRIGGER; Schema: public; Owner: postgres
--

CREATE TRIGGER update_user_subscriptions_updated_at BEFORE UPDATE ON public.user_subscriptions FOR EACH ROW EXECUTE FUNCTION public.update_updated_at_column();


--
-- TOC entry 4021 (class 2606 OID 18086)
-- Name: activity_logs activity_logs_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.activity_logs
    ADD CONSTRAINT activity_logs_user_id_fkey FOREIGN KEY (user_id) REFERENCES auth.users(id);


--
-- TOC entry 4022 (class 2606 OID 18207)
-- Name: allotments allotments_college_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.allotments
    ADD CONSTRAINT allotments_college_id_fkey FOREIGN KEY (college_id) REFERENCES public.colleges(id);


--
-- TOC entry 4023 (class 2606 OID 18212)
-- Name: allotments allotments_course_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.allotments
    ADD CONSTRAINT allotments_course_id_fkey FOREIGN KEY (course_id) REFERENCES public.courses(id);


--
-- TOC entry 4007 (class 2606 OID 17948)
-- Name: announcements announcements_author_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.announcements
    ADD CONSTRAINT announcements_author_id_fkey FOREIGN KEY (author_id) REFERENCES auth.users(id);


--
-- TOC entry 4017 (class 2606 OID 18046)
-- Name: choice_list_items choice_list_items_choice_list_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.choice_list_items
    ADD CONSTRAINT choice_list_items_choice_list_id_fkey FOREIGN KEY (choice_list_id) REFERENCES public.choice_lists(id) ON DELETE CASCADE;


--
-- TOC entry 4018 (class 2606 OID 18051)
-- Name: choice_list_items choice_list_items_college_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.choice_list_items
    ADD CONSTRAINT choice_list_items_college_id_fkey FOREIGN KEY (college_id) REFERENCES public.colleges(id) ON DELETE CASCADE;


--
-- TOC entry 4019 (class 2606 OID 18056)
-- Name: choice_list_items choice_list_items_course_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.choice_list_items
    ADD CONSTRAINT choice_list_items_course_id_fkey FOREIGN KEY (course_id) REFERENCES public.courses(id) ON DELETE CASCADE;


--
-- TOC entry 4013 (class 2606 OID 18439)
-- Name: choice_lists choice_lists_approved_by_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.choice_lists
    ADD CONSTRAINT choice_lists_approved_by_fkey FOREIGN KEY (approved_by) REFERENCES public.counsellors(id);


--
-- TOC entry 4014 (class 2606 OID 18027)
-- Name: choice_lists choice_lists_authority_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.choice_lists
    ADD CONSTRAINT choice_lists_authority_id_fkey FOREIGN KEY (authority_id) REFERENCES public.counseling_authorities(id);


--
-- TOC entry 4015 (class 2606 OID 18022)
-- Name: choice_lists choice_lists_profile_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.choice_lists
    ADD CONSTRAINT choice_lists_profile_id_fkey FOREIGN KEY (profile_id) REFERENCES public.profiles(id) ON DELETE CASCADE;


--
-- TOC entry 4016 (class 2606 OID 18032)
-- Name: choice_lists choice_lists_round_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.choice_lists
    ADD CONSTRAINT choice_lists_round_id_fkey FOREIGN KEY (round_id) REFERENCES public.counseling_rounds(id);


--
-- TOC entry 3994 (class 2606 OID 17813)
-- Name: closing_ranks closing_ranks_course_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.closing_ranks
    ADD CONSTRAINT closing_ranks_course_id_fkey FOREIGN KEY (course_id) REFERENCES public.courses(id) ON DELETE CASCADE;


--
-- TOC entry 3995 (class 2606 OID 17823)
-- Name: closing_ranks closing_ranks_created_by_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.closing_ranks
    ADD CONSTRAINT closing_ranks_created_by_fkey FOREIGN KEY (created_by) REFERENCES auth.users(id);


--
-- TOC entry 3996 (class 2606 OID 17818)
-- Name: closing_ranks closing_ranks_round_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.closing_ranks
    ADD CONSTRAINT closing_ranks_round_id_fkey FOREIGN KEY (round_id) REFERENCES public.counseling_rounds(id) ON DELETE CASCADE;


--
-- TOC entry 3997 (class 2606 OID 17828)
-- Name: closing_ranks closing_ranks_updated_by_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.closing_ranks
    ADD CONSTRAINT closing_ranks_updated_by_fkey FOREIGN KEY (updated_by) REFERENCES auth.users(id);


--
-- TOC entry 3998 (class 2606 OID 17848)
-- Name: closing_ranks_versions closing_ranks_versions_changed_by_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.closing_ranks_versions
    ADD CONSTRAINT closing_ranks_versions_changed_by_fkey FOREIGN KEY (changed_by) REFERENCES auth.users(id);


--
-- TOC entry 3999 (class 2606 OID 17843)
-- Name: closing_ranks_versions closing_ranks_versions_closing_rank_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.closing_ranks_versions
    ADD CONSTRAINT closing_ranks_versions_closing_rank_id_fkey FOREIGN KEY (closing_rank_id) REFERENCES public.closing_ranks(id) ON DELETE SET NULL;


--
-- TOC entry 4027 (class 2606 OID 18312)
-- Name: coaching_institutes coaching_institutes_profile_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.coaching_institutes
    ADD CONSTRAINT coaching_institutes_profile_id_fkey FOREIGN KEY (profile_id) REFERENCES public.profiles(id) ON DELETE CASCADE;


--
-- TOC entry 3987 (class 2606 OID 17755)
-- Name: college_bonds college_bonds_course_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.college_bonds
    ADD CONSTRAINT college_bonds_course_id_fkey FOREIGN KEY (course_id) REFERENCES public.courses(id) ON DELETE CASCADE;


--
-- TOC entry 3988 (class 2606 OID 17760)
-- Name: college_bonds college_bonds_created_by_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.college_bonds
    ADD CONSTRAINT college_bonds_created_by_fkey FOREIGN KEY (created_by) REFERENCES auth.users(id);


--
-- TOC entry 3989 (class 2606 OID 17765)
-- Name: college_bonds college_bonds_updated_by_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.college_bonds
    ADD CONSTRAINT college_bonds_updated_by_fkey FOREIGN KEY (updated_by) REFERENCES auth.users(id);


--
-- TOC entry 3984 (class 2606 OID 17727)
-- Name: college_fees college_fees_course_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.college_fees
    ADD CONSTRAINT college_fees_course_id_fkey FOREIGN KEY (course_id) REFERENCES public.courses(id) ON DELETE CASCADE;


--
-- TOC entry 3985 (class 2606 OID 17732)
-- Name: college_fees college_fees_created_by_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.college_fees
    ADD CONSTRAINT college_fees_created_by_fkey FOREIGN KEY (created_by) REFERENCES auth.users(id);


--
-- TOC entry 3986 (class 2606 OID 17737)
-- Name: college_fees college_fees_updated_by_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.college_fees
    ADD CONSTRAINT college_fees_updated_by_fkey FOREIGN KEY (updated_by) REFERENCES auth.users(id);


--
-- TOC entry 3979 (class 2606 OID 17676)
-- Name: colleges colleges_created_by_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.colleges
    ADD CONSTRAINT colleges_created_by_fkey FOREIGN KEY (created_by) REFERENCES auth.users(id);


--
-- TOC entry 3980 (class 2606 OID 17681)
-- Name: colleges colleges_updated_by_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.colleges
    ADD CONSTRAINT colleges_updated_by_fkey FOREIGN KEY (updated_by) REFERENCES auth.users(id);


--
-- TOC entry 4006 (class 2606 OID 17930)
-- Name: content_articles content_articles_author_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.content_articles
    ADD CONSTRAINT content_articles_author_id_fkey FOREIGN KEY (author_id) REFERENCES auth.users(id);


--
-- TOC entry 3974 (class 2606 OID 17625)
-- Name: counseling_authorities counseling_authorities_created_by_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.counseling_authorities
    ADD CONSTRAINT counseling_authorities_created_by_fkey FOREIGN KEY (created_by) REFERENCES auth.users(id);


--
-- TOC entry 3975 (class 2606 OID 17630)
-- Name: counseling_authorities counseling_authorities_updated_by_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.counseling_authorities
    ADD CONSTRAINT counseling_authorities_updated_by_fkey FOREIGN KEY (updated_by) REFERENCES auth.users(id);


--
-- TOC entry 3976 (class 2606 OID 17648)
-- Name: counseling_rounds counseling_rounds_authority_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.counseling_rounds
    ADD CONSTRAINT counseling_rounds_authority_id_fkey FOREIGN KEY (authority_id) REFERENCES public.counseling_authorities(id) ON DELETE CASCADE;


--
-- TOC entry 3977 (class 2606 OID 17653)
-- Name: counseling_rounds counseling_rounds_created_by_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.counseling_rounds
    ADD CONSTRAINT counseling_rounds_created_by_fkey FOREIGN KEY (created_by) REFERENCES auth.users(id);


--
-- TOC entry 3978 (class 2606 OID 17658)
-- Name: counseling_rounds counseling_rounds_updated_by_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.counseling_rounds
    ADD CONSTRAINT counseling_rounds_updated_by_fkey FOREIGN KEY (updated_by) REFERENCES auth.users(id);


--
-- TOC entry 4033 (class 2606 OID 18382)
-- Name: counsellor_notes counsellor_notes_counsellor_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.counsellor_notes
    ADD CONSTRAINT counsellor_notes_counsellor_id_fkey FOREIGN KEY (counsellor_id) REFERENCES public.counsellors(id) ON DELETE CASCADE;


--
-- TOC entry 4034 (class 2606 OID 18387)
-- Name: counsellor_notes counsellor_notes_student_profile_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.counsellor_notes
    ADD CONSTRAINT counsellor_notes_student_profile_id_fkey FOREIGN KEY (student_profile_id) REFERENCES public.profiles(id) ON DELETE CASCADE;


--
-- TOC entry 4028 (class 2606 OID 18336)
-- Name: counsellors counsellors_institute_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.counsellors
    ADD CONSTRAINT counsellors_institute_id_fkey FOREIGN KEY (institute_id) REFERENCES public.coaching_institutes(id) ON DELETE SET NULL;


--
-- TOC entry 4029 (class 2606 OID 18331)
-- Name: counsellors counsellors_profile_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.counsellors
    ADD CONSTRAINT counsellors_profile_id_fkey FOREIGN KEY (profile_id) REFERENCES public.profiles(id) ON DELETE CASCADE;


--
-- TOC entry 3981 (class 2606 OID 17699)
-- Name: courses courses_college_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.courses
    ADD CONSTRAINT courses_college_id_fkey FOREIGN KEY (college_id) REFERENCES public.colleges(id) ON DELETE CASCADE;


--
-- TOC entry 3982 (class 2606 OID 17704)
-- Name: courses courses_created_by_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.courses
    ADD CONSTRAINT courses_created_by_fkey FOREIGN KEY (created_by) REFERENCES auth.users(id);


--
-- TOC entry 3983 (class 2606 OID 17709)
-- Name: courses courses_updated_by_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.courses
    ADD CONSTRAINT courses_updated_by_fkey FOREIGN KEY (updated_by) REFERENCES auth.users(id);


--
-- TOC entry 4008 (class 2606 OID 17966)
-- Name: data_imports data_imports_uploaded_by_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.data_imports
    ADD CONSTRAINT data_imports_uploaded_by_fkey FOREIGN KEY (uploaded_by) REFERENCES auth.users(id);


--
-- TOC entry 4030 (class 2606 OID 18364)
-- Name: institute_students institute_students_counsellor_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.institute_students
    ADD CONSTRAINT institute_students_counsellor_id_fkey FOREIGN KEY (counsellor_id) REFERENCES public.counsellors(id) ON DELETE SET NULL;


--
-- TOC entry 4031 (class 2606 OID 18354)
-- Name: institute_students institute_students_institute_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.institute_students
    ADD CONSTRAINT institute_students_institute_id_fkey FOREIGN KEY (institute_id) REFERENCES public.coaching_institutes(id) ON DELETE CASCADE;


--
-- TOC entry 4032 (class 2606 OID 18359)
-- Name: institute_students institute_students_student_profile_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.institute_students
    ADD CONSTRAINT institute_students_student_profile_id_fkey FOREIGN KEY (student_profile_id) REFERENCES public.profiles(id) ON DELETE CASCADE;


--
-- TOC entry 4020 (class 2606 OID 18072)
-- Name: notifications notifications_recipient_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.notifications
    ADD CONSTRAINT notifications_recipient_id_fkey FOREIGN KEY (recipient_id) REFERENCES auth.users(id) ON DELETE CASCADE;


--
-- TOC entry 4004 (class 2606 OID 17911)
-- Name: payments payments_profile_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.payments
    ADD CONSTRAINT payments_profile_id_fkey FOREIGN KEY (profile_id) REFERENCES public.profiles(id) ON DELETE CASCADE;


--
-- TOC entry 4005 (class 2606 OID 17906)
-- Name: payments payments_subscription_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.payments
    ADD CONSTRAINT payments_subscription_id_fkey FOREIGN KEY (subscription_id) REFERENCES public.user_subscriptions(id) ON DELETE SET NULL;


--
-- TOC entry 4026 (class 2606 OID 18271)
-- Name: pg_closing_ranks pg_closing_ranks_seat_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.pg_closing_ranks
    ADD CONSTRAINT pg_closing_ranks_seat_id_fkey FOREIGN KEY (seat_id) REFERENCES public.pg_course_seats(id) ON DELETE CASCADE;


--
-- TOC entry 4024 (class 2606 OID 18251)
-- Name: pg_course_seats pg_course_seats_college_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.pg_course_seats
    ADD CONSTRAINT pg_course_seats_college_id_fkey FOREIGN KEY (college_id) REFERENCES public.colleges(id) ON DELETE CASCADE;


--
-- TOC entry 4025 (class 2606 OID 18256)
-- Name: pg_course_seats pg_course_seats_course_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.pg_course_seats
    ADD CONSTRAINT pg_course_seats_course_id_fkey FOREIGN KEY (course_id) REFERENCES public.courses(id) ON DELETE CASCADE;


--
-- TOC entry 4009 (class 2606 OID 17980)
-- Name: predictor_logs predictor_logs_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.predictor_logs
    ADD CONSTRAINT predictor_logs_user_id_fkey FOREIGN KEY (user_id) REFERENCES auth.users(id);


--
-- TOC entry 3971 (class 2606 OID 17584)
-- Name: profiles profiles_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.profiles
    ADD CONSTRAINT profiles_user_id_fkey FOREIGN KEY (user_id) REFERENCES auth.users(id) ON DELETE CASCADE;


--
-- TOC entry 4010 (class 2606 OID 18001)
-- Name: saved_colleges saved_colleges_college_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.saved_colleges
    ADD CONSTRAINT saved_colleges_college_id_fkey FOREIGN KEY (college_id) REFERENCES public.colleges(id) ON DELETE CASCADE;


--
-- TOC entry 4011 (class 2606 OID 18006)
-- Name: saved_colleges saved_colleges_course_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.saved_colleges
    ADD CONSTRAINT saved_colleges_course_id_fkey FOREIGN KEY (course_id) REFERENCES public.courses(id);


--
-- TOC entry 4012 (class 2606 OID 17996)
-- Name: saved_colleges saved_colleges_profile_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.saved_colleges
    ADD CONSTRAINT saved_colleges_profile_id_fkey FOREIGN KEY (profile_id) REFERENCES public.profiles(id) ON DELETE CASCADE;


--
-- TOC entry 3990 (class 2606 OID 17783)
-- Name: seat_matrix seat_matrix_course_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.seat_matrix
    ADD CONSTRAINT seat_matrix_course_id_fkey FOREIGN KEY (course_id) REFERENCES public.courses(id) ON DELETE CASCADE;


--
-- TOC entry 3991 (class 2606 OID 17793)
-- Name: seat_matrix seat_matrix_created_by_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.seat_matrix
    ADD CONSTRAINT seat_matrix_created_by_fkey FOREIGN KEY (created_by) REFERENCES auth.users(id);


--
-- TOC entry 3992 (class 2606 OID 17788)
-- Name: seat_matrix seat_matrix_round_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.seat_matrix
    ADD CONSTRAINT seat_matrix_round_id_fkey FOREIGN KEY (round_id) REFERENCES public.counseling_rounds(id) ON DELETE CASCADE;


--
-- TOC entry 3993 (class 2606 OID 17798)
-- Name: seat_matrix seat_matrix_updated_by_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.seat_matrix
    ADD CONSTRAINT seat_matrix_updated_by_fkey FOREIGN KEY (updated_by) REFERENCES auth.users(id);


--
-- TOC entry 3972 (class 2606 OID 17607)
-- Name: student_profiles student_profiles_parent_profile_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.student_profiles
    ADD CONSTRAINT student_profiles_parent_profile_id_fkey FOREIGN KEY (parent_profile_id) REFERENCES public.profiles(id);


--
-- TOC entry 3973 (class 2606 OID 17602)
-- Name: student_profiles student_profiles_profile_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.student_profiles
    ADD CONSTRAINT student_profiles_profile_id_fkey FOREIGN KEY (profile_id) REFERENCES public.profiles(id) ON DELETE CASCADE;


--
-- TOC entry 4000 (class 2606 OID 17865)
-- Name: subscription_plans subscription_plans_created_by_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.subscription_plans
    ADD CONSTRAINT subscription_plans_created_by_fkey FOREIGN KEY (created_by) REFERENCES auth.users(id);


--
-- TOC entry 4001 (class 2606 OID 17870)
-- Name: subscription_plans subscription_plans_updated_by_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.subscription_plans
    ADD CONSTRAINT subscription_plans_updated_by_fkey FOREIGN KEY (updated_by) REFERENCES auth.users(id);


--
-- TOC entry 4035 (class 2606 OID 18413)
-- Name: support_tickets support_tickets_assigned_to_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.support_tickets
    ADD CONSTRAINT support_tickets_assigned_to_fkey FOREIGN KEY (assigned_to) REFERENCES public.profiles(id) ON DELETE SET NULL;


--
-- TOC entry 4036 (class 2606 OID 18408)
-- Name: support_tickets support_tickets_profile_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.support_tickets
    ADD CONSTRAINT support_tickets_profile_id_fkey FOREIGN KEY (profile_id) REFERENCES public.profiles(id) ON DELETE CASCADE;


--
-- TOC entry 4037 (class 2606 OID 18433)
-- Name: ticket_messages ticket_messages_sender_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.ticket_messages
    ADD CONSTRAINT ticket_messages_sender_id_fkey FOREIGN KEY (sender_id) REFERENCES public.profiles(id) ON DELETE CASCADE;


--
-- TOC entry 4038 (class 2606 OID 18428)
-- Name: ticket_messages ticket_messages_ticket_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.ticket_messages
    ADD CONSTRAINT ticket_messages_ticket_id_fkey FOREIGN KEY (ticket_id) REFERENCES public.support_tickets(id) ON DELETE CASCADE;


--
-- TOC entry 3969 (class 2606 OID 17565)
-- Name: user_roles user_roles_assigned_by_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.user_roles
    ADD CONSTRAINT user_roles_assigned_by_fkey FOREIGN KEY (assigned_by) REFERENCES auth.users(id);


--
-- TOC entry 3970 (class 2606 OID 17560)
-- Name: user_roles user_roles_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.user_roles
    ADD CONSTRAINT user_roles_user_id_fkey FOREIGN KEY (user_id) REFERENCES auth.users(id) ON DELETE CASCADE;


--
-- TOC entry 4002 (class 2606 OID 17889)
-- Name: user_subscriptions user_subscriptions_plan_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.user_subscriptions
    ADD CONSTRAINT user_subscriptions_plan_id_fkey FOREIGN KEY (plan_id) REFERENCES public.subscription_plans(id);


--
-- TOC entry 4003 (class 2606 OID 17884)
-- Name: user_subscriptions user_subscriptions_profile_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.user_subscriptions
    ADD CONSTRAINT user_subscriptions_profile_id_fkey FOREIGN KEY (profile_id) REFERENCES public.profiles(id) ON DELETE CASCADE;


--
-- TOC entry 4301 (class 3256 OID 18296)
-- Name: pg_closing_ranks Admins can manage PG closing ranks; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY "Admins can manage PG closing ranks" ON public.pg_closing_ranks USING (public.is_admin(auth.uid()));


--
-- TOC entry 4299 (class 3256 OID 18294)
-- Name: pg_course_seats Admins can manage PG course seats; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY "Admins can manage PG course seats" ON public.pg_course_seats USING (public.is_admin(auth.uid()));


--
-- TOC entry 4279 (class 3256 OID 18173)
-- Name: announcements Admins can manage all announcements; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY "Admins can manage all announcements" ON public.announcements USING (public.is_admin(auth.uid()));


--
-- TOC entry 4276 (class 3256 OID 18170)
-- Name: content_articles Admins can manage all articles; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY "Admins can manage all articles" ON public.content_articles USING (public.is_super_admin(auth.uid()));


--
-- TOC entry 4309 (class 3256 OID 18451)
-- Name: counsellors Admins can manage all counsellors; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY "Admins can manage all counsellors" ON public.counsellors USING (public.is_admin(auth.uid()));


--
-- TOC entry 4280 (class 3256 OID 18455)
-- Name: institute_students Admins can manage all institute students; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY "Admins can manage all institute students" ON public.institute_students USING (public.is_admin(auth.uid()));


--
-- TOC entry 4304 (class 3256 OID 18447)
-- Name: coaching_institutes Admins can manage all institutes; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY "Admins can manage all institutes" ON public.coaching_institutes USING (public.is_admin(auth.uid()));


--
-- TOC entry 4321 (class 3256 OID 18465)
-- Name: ticket_messages Admins can manage all messages; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY "Admins can manage all messages" ON public.ticket_messages USING (public.is_any_admin(auth.uid()));


--
-- TOC entry 4314 (class 3256 OID 18458)
-- Name: counsellor_notes Admins can manage all notes; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY "Admins can manage all notes" ON public.counsellor_notes USING (public.is_admin(auth.uid()));


--
-- TOC entry 4292 (class 3256 OID 18185)
-- Name: notifications Admins can manage all notifications; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY "Admins can manage all notifications" ON public.notifications USING (public.is_admin(auth.uid()));


--
-- TOC entry 4273 (class 3256 OID 18165)
-- Name: payments Admins can manage all payments; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY "Admins can manage all payments" ON public.payments USING (public.is_admin(auth.uid()));


--
-- TOC entry 4248 (class 3256 OID 18138)
-- Name: profiles Admins can manage all profiles; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY "Admins can manage all profiles" ON public.profiles USING (public.is_admin(auth.uid()));


--
-- TOC entry 4251 (class 3256 OID 18141)
-- Name: student_profiles Admins can manage all student profiles; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY "Admins can manage all student profiles" ON public.student_profiles USING (public.is_admin(auth.uid()));


--
-- TOC entry 4271 (class 3256 OID 18163)
-- Name: user_subscriptions Admins can manage all subscriptions; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY "Admins can manage all subscriptions" ON public.user_subscriptions USING (public.is_admin(auth.uid()));


--
-- TOC entry 4318 (class 3256 OID 18462)
-- Name: support_tickets Admins can manage all tickets; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY "Admins can manage all tickets" ON public.support_tickets USING (public.is_any_admin(auth.uid()));


--
-- TOC entry 4297 (class 3256 OID 18228)
-- Name: allotments Admins can manage allotments; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY "Admins can manage allotments" ON public.allotments USING (public.is_admin(auth.uid()));


--
-- TOC entry 4267 (class 3256 OID 18159)
-- Name: closing_ranks_versions Admins can manage closing rank versions; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY "Admins can manage closing rank versions" ON public.closing_ranks_versions USING (public.is_admin(auth.uid()));


--
-- TOC entry 4265 (class 3256 OID 18157)
-- Name: closing_ranks Admins can manage closing ranks; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY "Admins can manage closing ranks" ON public.closing_ranks USING (public.is_admin(auth.uid()));


--
-- TOC entry 4257 (class 3256 OID 18149)
-- Name: college_bonds Admins can manage college bonds; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY "Admins can manage college bonds" ON public.college_bonds USING (public.is_admin(auth.uid()));


--
-- TOC entry 4255 (class 3256 OID 18147)
-- Name: college_fees Admins can manage college fees; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY "Admins can manage college fees" ON public.college_fees USING (public.is_admin(auth.uid()));


--
-- TOC entry 4252 (class 3256 OID 18143)
-- Name: colleges Admins can manage colleges; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY "Admins can manage colleges" ON public.colleges USING (public.is_admin(auth.uid()));


--
-- TOC entry 4259 (class 3256 OID 18151)
-- Name: counseling_authorities Admins can manage counseling authorities; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY "Admins can manage counseling authorities" ON public.counseling_authorities USING (public.is_admin(auth.uid()));


--
-- TOC entry 4261 (class 3256 OID 18153)
-- Name: counseling_rounds Admins can manage counseling rounds; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY "Admins can manage counseling rounds" ON public.counseling_rounds USING (public.is_admin(auth.uid()));


--
-- TOC entry 4254 (class 3256 OID 18145)
-- Name: courses Admins can manage courses; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY "Admins can manage courses" ON public.courses USING (public.is_admin(auth.uid()));


--
-- TOC entry 4283 (class 3256 OID 18176)
-- Name: data_imports Admins can manage data imports; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY "Admins can manage data imports" ON public.data_imports USING (public.is_admin(auth.uid()));


--
-- TOC entry 4263 (class 3256 OID 18155)
-- Name: seat_matrix Admins can manage seat matrix; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY "Admins can manage seat matrix" ON public.seat_matrix USING (public.is_admin(auth.uid()));


--
-- TOC entry 4269 (class 3256 OID 18161)
-- Name: subscription_plans Admins can manage subscription plans; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY "Admins can manage subscription plans" ON public.subscription_plans USING (public.is_super_admin(auth.uid()));


--
-- TOC entry 4243 (class 3256 OID 18133)
-- Name: user_roles Admins can manage user roles; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY "Admins can manage user roles" ON public.user_roles USING (public.is_super_admin(auth.uid()));


--
-- TOC entry 4293 (class 3256 OID 18187)
-- Name: activity_logs Admins can view activity logs; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY "Admins can view activity logs" ON public.activity_logs FOR SELECT USING (public.is_super_admin(auth.uid()));


--
-- TOC entry 4282 (class 3256 OID 18175)
-- Name: data_imports Admins can view all imports; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY "Admins can view all imports" ON public.data_imports FOR SELECT USING (public.is_admin(auth.uid()));


--
-- TOC entry 4286 (class 3256 OID 18179)
-- Name: predictor_logs Admins can view all predictor logs; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY "Admins can view all predictor logs" ON public.predictor_logs FOR SELECT USING (public.is_admin(auth.uid()));


--
-- TOC entry 4247 (class 3256 OID 18137)
-- Name: profiles Admins can view all profiles; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY "Admins can view all profiles" ON public.profiles FOR SELECT USING (public.is_any_admin(auth.uid()));


--
-- TOC entry 4266 (class 3256 OID 18158)
-- Name: closing_ranks_versions Admins can view closing rank versions; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY "Admins can view closing rank versions" ON public.closing_ranks_versions FOR SELECT USING (public.is_admin(auth.uid()));


--
-- TOC entry 4300 (class 3256 OID 18295)
-- Name: pg_closing_ranks Anyone can view PG closing ranks; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY "Anyone can view PG closing ranks" ON public.pg_closing_ranks FOR SELECT USING (true);


--
-- TOC entry 4298 (class 3256 OID 18293)
-- Name: pg_course_seats Anyone can view active PG course seats; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY "Anyone can view active PG course seats" ON public.pg_course_seats FOR SELECT USING ((is_active = true));


--
-- TOC entry 4258 (class 3256 OID 18150)
-- Name: counseling_authorities Anyone can view active counseling authorities; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY "Anyone can view active counseling authorities" ON public.counseling_authorities FOR SELECT USING ((is_active = true));


--
-- TOC entry 4260 (class 3256 OID 18152)
-- Name: counseling_rounds Anyone can view active counseling rounds; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY "Anyone can view active counseling rounds" ON public.counseling_rounds FOR SELECT USING ((is_active = true));


--
-- TOC entry 4253 (class 3256 OID 18144)
-- Name: courses Anyone can view active courses; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY "Anyone can view active courses" ON public.courses FOR SELECT USING ((is_active = true));


--
-- TOC entry 4268 (class 3256 OID 18160)
-- Name: subscription_plans Anyone can view active subscription plans; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY "Anyone can view active subscription plans" ON public.subscription_plans FOR SELECT USING ((is_active = true));


--
-- TOC entry 4296 (class 3256 OID 18227)
-- Name: allotments Anyone can view allotments; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY "Anyone can view allotments" ON public.allotments FOR SELECT USING (true);


--
-- TOC entry 4264 (class 3256 OID 18156)
-- Name: closing_ranks Anyone can view closing ranks; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY "Anyone can view closing ranks" ON public.closing_ranks FOR SELECT USING (true);


--
-- TOC entry 4256 (class 3256 OID 18148)
-- Name: college_bonds Anyone can view college bonds; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY "Anyone can view college bonds" ON public.college_bonds FOR SELECT USING (true);


--
-- TOC entry 4277 (class 3256 OID 18171)
-- Name: announcements Anyone can view published announcements; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY "Anyone can view published announcements" ON public.announcements FOR SELECT USING ((status = 'published'::public.content_status));


--
-- TOC entry 4262 (class 3256 OID 18154)
-- Name: seat_matrix Anyone can view seat matrix; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY "Anyone can view seat matrix" ON public.seat_matrix FOR SELECT USING (true);


--
-- TOC entry 4294 (class 3256 OID 18193)
-- Name: notifications Authenticated users and admins can create notifications; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY "Authenticated users and admins can create notifications" ON public.notifications FOR INSERT WITH CHECK ((auth.uid() IS NOT NULL));


--
-- TOC entry 4295 (class 3256 OID 18194)
-- Name: activity_logs Authenticated users can create activity logs; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY "Authenticated users can create activity logs" ON public.activity_logs FOR INSERT WITH CHECK ((auth.uid() IS NOT NULL));


--
-- TOC entry 4284 (class 3256 OID 18177)
-- Name: predictor_logs Authenticated users can create predictor logs; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY "Authenticated users can create predictor logs" ON public.predictor_logs FOR INSERT WITH CHECK ((auth.uid() IS NOT NULL));


--
-- TOC entry 4278 (class 3256 OID 18172)
-- Name: announcements Content managers can create announcements; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY "Content managers can create announcements" ON public.announcements FOR INSERT WITH CHECK ((public.has_role(auth.uid(), 'content_manager'::public.app_role) OR public.is_admin(auth.uid())));


--
-- TOC entry 4274 (class 3256 OID 18168)
-- Name: content_articles Content managers can create articles; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY "Content managers can create articles" ON public.content_articles FOR INSERT WITH CHECK ((public.has_role(auth.uid(), 'content_manager'::public.app_role) OR public.has_role(auth.uid(), 'super_admin'::public.app_role)));


--
-- TOC entry 4275 (class 3256 OID 18169)
-- Name: content_articles Content managers can update their own articles; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY "Content managers can update their own articles" ON public.content_articles FOR UPDATE USING (((author_id = auth.uid()) OR public.is_super_admin(auth.uid())));


--
-- TOC entry 4307 (class 3256 OID 18456)
-- Name: counsellor_notes Counsellors can manage their own notes; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY "Counsellors can manage their own notes" ON public.counsellor_notes USING ((EXISTS ( SELECT 1
   FROM (public.counsellors c
     JOIN public.profiles p ON ((p.id = c.profile_id)))
  WHERE ((c.id = counsellor_notes.counsellor_id) AND (p.user_id = auth.uid())))));


--
-- TOC entry 4312 (class 3256 OID 18454)
-- Name: institute_students Counsellors can view their assigned students; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY "Counsellors can view their assigned students" ON public.institute_students FOR SELECT USING ((EXISTS ( SELECT 1
   FROM (public.counsellors c
     JOIN public.profiles p ON ((p.id = c.profile_id)))
  WHERE ((c.id = institute_students.counsellor_id) AND (p.user_id = auth.uid())))));


--
-- TOC entry 4281 (class 3256 OID 18174)
-- Name: data_imports Data managers can view their own imports; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY "Data managers can view their own imports" ON public.data_imports FOR SELECT USING ((uploaded_by = auth.uid()));


--
-- TOC entry 4311 (class 3256 OID 18453)
-- Name: institute_students Institute owners can manage their students; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY "Institute owners can manage their students" ON public.institute_students USING ((EXISTS ( SELECT 1
   FROM (public.coaching_institutes ci
     JOIN public.profiles p ON ((p.id = ci.profile_id)))
  WHERE ((ci.id = institute_students.institute_id) AND (p.user_id = auth.uid())))));


--
-- TOC entry 4308 (class 3256 OID 18450)
-- Name: counsellors Institute owners can view their counsellors; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY "Institute owners can view their counsellors" ON public.counsellors FOR SELECT USING ((EXISTS ( SELECT 1
   FROM (public.coaching_institutes ci
     JOIN public.profiles p ON ((p.id = ci.profile_id)))
  WHERE ((ci.id = counsellors.institute_id) AND (p.user_id = auth.uid())))));


--
-- TOC entry 4323 (class 3256 OID 18480)
-- Name: colleges Public can view active colleges; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY "Public can view active colleges" ON public.colleges FOR SELECT USING ((is_active = true));


--
-- TOC entry 4324 (class 3256 OID 18481)
-- Name: courses Public can view active courses; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY "Public can view active courses" ON public.courses FOR SELECT USING ((is_active = true));


--
-- TOC entry 4325 (class 3256 OID 18482)
-- Name: college_fees Public can view college fees; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY "Public can view college fees" ON public.college_fees FOR SELECT USING (true);


--
-- TOC entry 4322 (class 3256 OID 18479)
-- Name: content_articles Public can view published articles; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY "Public can view published articles" ON public.content_articles FOR SELECT USING ((status = 'published'::public.content_status));


--
-- TOC entry 4313 (class 3256 OID 18457)
-- Name: counsellor_notes Students can view non-private notes about them; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY "Students can view non-private notes about them" ON public.counsellor_notes FOR SELECT USING (((NOT is_private) AND (EXISTS ( SELECT 1
   FROM public.profiles
  WHERE ((profiles.id = counsellor_notes.student_profile_id) AND (profiles.user_id = auth.uid()))))));


--
-- TOC entry 4310 (class 3256 OID 18452)
-- Name: institute_students Students can view their own enrollment; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY "Students can view their own enrollment" ON public.institute_students FOR SELECT USING ((EXISTS ( SELECT 1
   FROM public.profiles
  WHERE ((profiles.id = institute_students.student_profile_id) AND (profiles.user_id = auth.uid())))));


--
-- TOC entry 4320 (class 3256 OID 18464)
-- Name: ticket_messages Users can add messages to their tickets; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY "Users can add messages to their tickets" ON public.ticket_messages FOR INSERT WITH CHECK ((EXISTS ( SELECT 1
   FROM (public.support_tickets st
     JOIN public.profiles p ON ((p.id = st.profile_id)))
  WHERE ((st.id = ticket_messages.ticket_id) AND (p.user_id = auth.uid())))));


--
-- TOC entry 4316 (class 3256 OID 18460)
-- Name: support_tickets Users can create tickets; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY "Users can create tickets" ON public.support_tickets FOR INSERT WITH CHECK ((EXISTS ( SELECT 1
   FROM public.profiles
  WHERE ((profiles.id = support_tickets.profile_id) AND (profiles.user_id = auth.uid())))));


--
-- TOC entry 4289 (class 3256 OID 18182)
-- Name: choice_list_items Users can manage their own choice list items; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY "Users can manage their own choice list items" ON public.choice_list_items USING ((EXISTS ( SELECT 1
   FROM (public.choice_lists
     JOIN public.profiles ON ((profiles.id = choice_lists.profile_id)))
  WHERE ((choice_lists.id = choice_list_items.choice_list_id) AND (profiles.user_id = auth.uid())))));


--
-- TOC entry 4288 (class 3256 OID 18181)
-- Name: choice_lists Users can manage their own choice lists; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY "Users can manage their own choice lists" ON public.choice_lists USING ((EXISTS ( SELECT 1
   FROM public.profiles
  WHERE ((profiles.id = choice_lists.profile_id) AND (profiles.user_id = auth.uid())))));


--
-- TOC entry 4306 (class 3256 OID 18449)
-- Name: counsellors Users can manage their own counsellor profile; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY "Users can manage their own counsellor profile" ON public.counsellors USING ((EXISTS ( SELECT 1
   FROM public.profiles
  WHERE ((profiles.id = counsellors.profile_id) AND (profiles.user_id = auth.uid())))));


--
-- TOC entry 4303 (class 3256 OID 18446)
-- Name: coaching_institutes Users can manage their own institute; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY "Users can manage their own institute" ON public.coaching_institutes USING ((EXISTS ( SELECT 1
   FROM public.profiles
  WHERE ((profiles.id = coaching_institutes.profile_id) AND (profiles.user_id = auth.uid())))));


--
-- TOC entry 4287 (class 3256 OID 18180)
-- Name: saved_colleges Users can manage their own saved colleges; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY "Users can manage their own saved colleges" ON public.saved_colleges USING ((EXISTS ( SELECT 1
   FROM public.profiles
  WHERE ((profiles.id = saved_colleges.profile_id) AND (profiles.user_id = auth.uid())))));


--
-- TOC entry 4250 (class 3256 OID 18140)
-- Name: student_profiles Users can manage their own student profile; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY "Users can manage their own student profile" ON public.student_profiles USING ((EXISTS ( SELECT 1
   FROM public.profiles
  WHERE ((profiles.id = student_profiles.profile_id) AND (profiles.user_id = auth.uid())))));


--
-- TOC entry 4291 (class 3256 OID 18184)
-- Name: notifications Users can update their own notifications; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY "Users can update their own notifications" ON public.notifications FOR UPDATE USING ((recipient_id = auth.uid()));


--
-- TOC entry 4246 (class 3256 OID 18136)
-- Name: profiles Users can update their own profile; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY "Users can update their own profile" ON public.profiles FOR UPDATE USING ((auth.uid() = user_id));


--
-- TOC entry 4317 (class 3256 OID 18461)
-- Name: support_tickets Users can update their own tickets; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY "Users can update their own tickets" ON public.support_tickets FOR UPDATE USING ((EXISTS ( SELECT 1
   FROM public.profiles
  WHERE ((profiles.id = support_tickets.profile_id) AND (profiles.user_id = auth.uid())))));


--
-- TOC entry 4319 (class 3256 OID 18463)
-- Name: ticket_messages Users can view messages on their tickets; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY "Users can view messages on their tickets" ON public.ticket_messages FOR SELECT USING ((EXISTS ( SELECT 1
   FROM (public.support_tickets st
     JOIN public.profiles p ON ((p.id = st.profile_id)))
  WHERE ((st.id = ticket_messages.ticket_id) AND (p.user_id = auth.uid())))));


--
-- TOC entry 4305 (class 3256 OID 18448)
-- Name: counsellors Users can view their own counsellor profile; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY "Users can view their own counsellor profile" ON public.counsellors FOR SELECT USING ((EXISTS ( SELECT 1
   FROM public.profiles
  WHERE ((profiles.id = counsellors.profile_id) AND (profiles.user_id = auth.uid())))));


--
-- TOC entry 4302 (class 3256 OID 18445)
-- Name: coaching_institutes Users can view their own institute; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY "Users can view their own institute" ON public.coaching_institutes FOR SELECT USING ((EXISTS ( SELECT 1
   FROM public.profiles
  WHERE ((profiles.id = coaching_institutes.profile_id) AND (profiles.user_id = auth.uid())))));


--
-- TOC entry 4290 (class 3256 OID 18183)
-- Name: notifications Users can view their own notifications; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY "Users can view their own notifications" ON public.notifications FOR SELECT USING ((recipient_id = auth.uid()));


--
-- TOC entry 4272 (class 3256 OID 18164)
-- Name: payments Users can view their own payments; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY "Users can view their own payments" ON public.payments FOR SELECT USING ((EXISTS ( SELECT 1
   FROM public.profiles
  WHERE ((profiles.id = payments.profile_id) AND (profiles.user_id = auth.uid())))));


--
-- TOC entry 4285 (class 3256 OID 18178)
-- Name: predictor_logs Users can view their own predictor logs; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY "Users can view their own predictor logs" ON public.predictor_logs FOR SELECT USING ((user_id = auth.uid()));


--
-- TOC entry 4245 (class 3256 OID 18135)
-- Name: profiles Users can view their own profile; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY "Users can view their own profile" ON public.profiles FOR SELECT USING ((auth.uid() = user_id));


--
-- TOC entry 4244 (class 3256 OID 18134)
-- Name: user_roles Users can view their own roles; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY "Users can view their own roles" ON public.user_roles FOR SELECT USING ((auth.uid() = user_id));


--
-- TOC entry 4249 (class 3256 OID 18139)
-- Name: student_profiles Users can view their own student profile; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY "Users can view their own student profile" ON public.student_profiles FOR SELECT USING ((EXISTS ( SELECT 1
   FROM public.profiles
  WHERE ((profiles.id = student_profiles.profile_id) AND (profiles.user_id = auth.uid())))));


--
-- TOC entry 4270 (class 3256 OID 18162)
-- Name: user_subscriptions Users can view their own subscriptions; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY "Users can view their own subscriptions" ON public.user_subscriptions FOR SELECT USING ((EXISTS ( SELECT 1
   FROM public.profiles
  WHERE ((profiles.id = user_subscriptions.profile_id) AND (profiles.user_id = auth.uid())))));


--
-- TOC entry 4315 (class 3256 OID 18459)
-- Name: support_tickets Users can view their own tickets; Type: POLICY; Schema: public; Owner: postgres
--

CREATE POLICY "Users can view their own tickets" ON public.support_tickets FOR SELECT USING ((EXISTS ( SELECT 1
   FROM public.profiles
  WHERE ((profiles.id = support_tickets.profile_id) AND (profiles.user_id = auth.uid())))));


--
-- TOC entry 4233 (class 0 OID 18077)
-- Dependencies: 297
-- Name: activity_logs; Type: ROW SECURITY; Schema: public; Owner: postgres
--

ALTER TABLE public.activity_logs ENABLE ROW LEVEL SECURITY;

--
-- TOC entry 4234 (class 0 OID 18195)
-- Dependencies: 298
-- Name: allotments; Type: ROW SECURITY; Schema: public; Owner: postgres
--

ALTER TABLE public.allotments ENABLE ROW LEVEL SECURITY;

--
-- TOC entry 4226 (class 0 OID 17935)
-- Dependencies: 290
-- Name: announcements; Type: ROW SECURITY; Schema: public; Owner: postgres
--

ALTER TABLE public.announcements ENABLE ROW LEVEL SECURITY;

--
-- TOC entry 4231 (class 0 OID 18037)
-- Dependencies: 295
-- Name: choice_list_items; Type: ROW SECURITY; Schema: public; Owner: postgres
--

ALTER TABLE public.choice_list_items ENABLE ROW LEVEL SECURITY;

--
-- TOC entry 4230 (class 0 OID 18011)
-- Dependencies: 294
-- Name: choice_lists; Type: ROW SECURITY; Schema: public; Owner: postgres
--

ALTER TABLE public.choice_lists ENABLE ROW LEVEL SECURITY;

--
-- TOC entry 4220 (class 0 OID 17803)
-- Dependencies: 284
-- Name: closing_ranks; Type: ROW SECURITY; Schema: public; Owner: postgres
--

ALTER TABLE public.closing_ranks ENABLE ROW LEVEL SECURITY;

--
-- TOC entry 4221 (class 0 OID 17833)
-- Dependencies: 285
-- Name: closing_ranks_versions; Type: ROW SECURITY; Schema: public; Owner: postgres
--

ALTER TABLE public.closing_ranks_versions ENABLE ROW LEVEL SECURITY;

--
-- TOC entry 4237 (class 0 OID 18299)
-- Dependencies: 301
-- Name: coaching_institutes; Type: ROW SECURITY; Schema: public; Owner: postgres
--

ALTER TABLE public.coaching_institutes ENABLE ROW LEVEL SECURITY;

--
-- TOC entry 4218 (class 0 OID 17742)
-- Dependencies: 282
-- Name: college_bonds; Type: ROW SECURITY; Schema: public; Owner: postgres
--

ALTER TABLE public.college_bonds ENABLE ROW LEVEL SECURITY;

--
-- TOC entry 4217 (class 0 OID 17714)
-- Dependencies: 281
-- Name: college_fees; Type: ROW SECURITY; Schema: public; Owner: postgres
--

ALTER TABLE public.college_fees ENABLE ROW LEVEL SECURITY;

--
-- TOC entry 4215 (class 0 OID 17663)
-- Dependencies: 279
-- Name: colleges; Type: ROW SECURITY; Schema: public; Owner: postgres
--

ALTER TABLE public.colleges ENABLE ROW LEVEL SECURITY;

--
-- TOC entry 4225 (class 0 OID 17916)
-- Dependencies: 289
-- Name: content_articles; Type: ROW SECURITY; Schema: public; Owner: postgres
--

ALTER TABLE public.content_articles ENABLE ROW LEVEL SECURITY;

--
-- TOC entry 4213 (class 0 OID 17612)
-- Dependencies: 277
-- Name: counseling_authorities; Type: ROW SECURITY; Schema: public; Owner: postgres
--

ALTER TABLE public.counseling_authorities ENABLE ROW LEVEL SECURITY;

--
-- TOC entry 4214 (class 0 OID 17635)
-- Dependencies: 278
-- Name: counseling_rounds; Type: ROW SECURITY; Schema: public; Owner: postgres
--

ALTER TABLE public.counseling_rounds ENABLE ROW LEVEL SECURITY;

--
-- TOC entry 4240 (class 0 OID 18369)
-- Dependencies: 304
-- Name: counsellor_notes; Type: ROW SECURITY; Schema: public; Owner: postgres
--

ALTER TABLE public.counsellor_notes ENABLE ROW LEVEL SECURITY;

--
-- TOC entry 4238 (class 0 OID 18317)
-- Dependencies: 302
-- Name: counsellors; Type: ROW SECURITY; Schema: public; Owner: postgres
--

ALTER TABLE public.counsellors ENABLE ROW LEVEL SECURITY;

--
-- TOC entry 4216 (class 0 OID 17686)
-- Dependencies: 280
-- Name: courses; Type: ROW SECURITY; Schema: public; Owner: postgres
--

ALTER TABLE public.courses ENABLE ROW LEVEL SECURITY;

--
-- TOC entry 4227 (class 0 OID 17953)
-- Dependencies: 291
-- Name: data_imports; Type: ROW SECURITY; Schema: public; Owner: postgres
--

ALTER TABLE public.data_imports ENABLE ROW LEVEL SECURITY;

--
-- TOC entry 4239 (class 0 OID 18341)
-- Dependencies: 303
-- Name: institute_students; Type: ROW SECURITY; Schema: public; Owner: postgres
--

ALTER TABLE public.institute_students ENABLE ROW LEVEL SECURITY;

--
-- TOC entry 4232 (class 0 OID 18061)
-- Dependencies: 296
-- Name: notifications; Type: ROW SECURITY; Schema: public; Owner: postgres
--

ALTER TABLE public.notifications ENABLE ROW LEVEL SECURITY;

--
-- TOC entry 4224 (class 0 OID 17894)
-- Dependencies: 288
-- Name: payments; Type: ROW SECURITY; Schema: public; Owner: postgres
--

ALTER TABLE public.payments ENABLE ROW LEVEL SECURITY;

--
-- TOC entry 4236 (class 0 OID 18261)
-- Dependencies: 300
-- Name: pg_closing_ranks; Type: ROW SECURITY; Schema: public; Owner: postgres
--

ALTER TABLE public.pg_closing_ranks ENABLE ROW LEVEL SECURITY;

--
-- TOC entry 4235 (class 0 OID 18233)
-- Dependencies: 299
-- Name: pg_course_seats; Type: ROW SECURITY; Schema: public; Owner: postgres
--

ALTER TABLE public.pg_course_seats ENABLE ROW LEVEL SECURITY;

--
-- TOC entry 4228 (class 0 OID 17971)
-- Dependencies: 292
-- Name: predictor_logs; Type: ROW SECURITY; Schema: public; Owner: postgres
--

ALTER TABLE public.predictor_logs ENABLE ROW LEVEL SECURITY;

--
-- TOC entry 4211 (class 0 OID 17570)
-- Dependencies: 275
-- Name: profiles; Type: ROW SECURITY; Schema: public; Owner: postgres
--

ALTER TABLE public.profiles ENABLE ROW LEVEL SECURITY;

--
-- TOC entry 4229 (class 0 OID 17985)
-- Dependencies: 293
-- Name: saved_colleges; Type: ROW SECURITY; Schema: public; Owner: postgres
--

ALTER TABLE public.saved_colleges ENABLE ROW LEVEL SECURITY;

--
-- TOC entry 4219 (class 0 OID 17770)
-- Dependencies: 283
-- Name: seat_matrix; Type: ROW SECURITY; Schema: public; Owner: postgres
--

ALTER TABLE public.seat_matrix ENABLE ROW LEVEL SECURITY;

--
-- TOC entry 4212 (class 0 OID 17589)
-- Dependencies: 276
-- Name: student_profiles; Type: ROW SECURITY; Schema: public; Owner: postgres
--

ALTER TABLE public.student_profiles ENABLE ROW LEVEL SECURITY;

--
-- TOC entry 4222 (class 0 OID 17853)
-- Dependencies: 286
-- Name: subscription_plans; Type: ROW SECURITY; Schema: public; Owner: postgres
--

ALTER TABLE public.subscription_plans ENABLE ROW LEVEL SECURITY;

--
-- TOC entry 4241 (class 0 OID 18392)
-- Dependencies: 305
-- Name: support_tickets; Type: ROW SECURITY; Schema: public; Owner: postgres
--

ALTER TABLE public.support_tickets ENABLE ROW LEVEL SECURITY;

--
-- TOC entry 4242 (class 0 OID 18418)
-- Dependencies: 306
-- Name: ticket_messages; Type: ROW SECURITY; Schema: public; Owner: postgres
--

ALTER TABLE public.ticket_messages ENABLE ROW LEVEL SECURITY;

--
-- TOC entry 4210 (class 0 OID 17551)
-- Dependencies: 274
-- Name: user_roles; Type: ROW SECURITY; Schema: public; Owner: postgres
--

ALTER TABLE public.user_roles ENABLE ROW LEVEL SECURITY;

--
-- TOC entry 4223 (class 0 OID 17875)
-- Dependencies: 287
-- Name: user_subscriptions; Type: ROW SECURITY; Schema: public; Owner: postgres
--

ALTER TABLE public.user_subscriptions ENABLE ROW LEVEL SECURITY;

--
-- TOC entry 4366 (class 0 OID 0)
-- Dependencies: 19
-- Name: SCHEMA public; Type: ACL; Schema: -; Owner: pg_database_owner
--

GRANT USAGE ON SCHEMA public TO postgres;
GRANT USAGE ON SCHEMA public TO anon;
GRANT USAGE ON SCHEMA public TO authenticated;
GRANT USAGE ON SCHEMA public TO service_role;


--
-- TOC entry 4367 (class 0 OID 0)
-- Dependencies: 437
-- Name: FUNCTION handle_new_user(); Type: ACL; Schema: public; Owner: postgres
--

GRANT ALL ON FUNCTION public.handle_new_user() TO anon;
GRANT ALL ON FUNCTION public.handle_new_user() TO authenticated;
GRANT ALL ON FUNCTION public.handle_new_user() TO service_role;


--
-- TOC entry 4368 (class 0 OID 0)
-- Dependencies: 432
-- Name: FUNCTION has_role(_user_id uuid, _role public.app_role); Type: ACL; Schema: public; Owner: postgres
--

GRANT ALL ON FUNCTION public.has_role(_user_id uuid, _role public.app_role) TO anon;
GRANT ALL ON FUNCTION public.has_role(_user_id uuid, _role public.app_role) TO authenticated;
GRANT ALL ON FUNCTION public.has_role(_user_id uuid, _role public.app_role) TO service_role;


--
-- TOC entry 4369 (class 0 OID 0)
-- Dependencies: 433
-- Name: FUNCTION is_admin(_user_id uuid); Type: ACL; Schema: public; Owner: postgres
--

GRANT ALL ON FUNCTION public.is_admin(_user_id uuid) TO anon;
GRANT ALL ON FUNCTION public.is_admin(_user_id uuid) TO authenticated;
GRANT ALL ON FUNCTION public.is_admin(_user_id uuid) TO service_role;


--
-- TOC entry 4370 (class 0 OID 0)
-- Dependencies: 434
-- Name: FUNCTION is_any_admin(_user_id uuid); Type: ACL; Schema: public; Owner: postgres
--

GRANT ALL ON FUNCTION public.is_any_admin(_user_id uuid) TO anon;
GRANT ALL ON FUNCTION public.is_any_admin(_user_id uuid) TO authenticated;
GRANT ALL ON FUNCTION public.is_any_admin(_user_id uuid) TO service_role;


--
-- TOC entry 4371 (class 0 OID 0)
-- Dependencies: 435
-- Name: FUNCTION is_super_admin(_user_id uuid); Type: ACL; Schema: public; Owner: postgres
--

GRANT ALL ON FUNCTION public.is_super_admin(_user_id uuid) TO anon;
GRANT ALL ON FUNCTION public.is_super_admin(_user_id uuid) TO authenticated;
GRANT ALL ON FUNCTION public.is_super_admin(_user_id uuid) TO service_role;


--
-- TOC entry 4372 (class 0 OID 0)
-- Dependencies: 436
-- Name: FUNCTION update_updated_at_column(); Type: ACL; Schema: public; Owner: postgres
--

GRANT ALL ON FUNCTION public.update_updated_at_column() TO anon;
GRANT ALL ON FUNCTION public.update_updated_at_column() TO authenticated;
GRANT ALL ON FUNCTION public.update_updated_at_column() TO service_role;


--
-- TOC entry 4373 (class 0 OID 0)
-- Dependencies: 297
-- Name: TABLE activity_logs; Type: ACL; Schema: public; Owner: postgres
--

GRANT ALL ON TABLE public.activity_logs TO anon;
GRANT ALL ON TABLE public.activity_logs TO authenticated;
GRANT ALL ON TABLE public.activity_logs TO service_role;


--
-- TOC entry 4374 (class 0 OID 0)
-- Dependencies: 298
-- Name: TABLE allotments; Type: ACL; Schema: public; Owner: postgres
--

GRANT ALL ON TABLE public.allotments TO anon;
GRANT ALL ON TABLE public.allotments TO authenticated;
GRANT ALL ON TABLE public.allotments TO service_role;


--
-- TOC entry 4375 (class 0 OID 0)
-- Dependencies: 290
-- Name: TABLE announcements; Type: ACL; Schema: public; Owner: postgres
--

GRANT ALL ON TABLE public.announcements TO anon;
GRANT ALL ON TABLE public.announcements TO authenticated;
GRANT ALL ON TABLE public.announcements TO service_role;


--
-- TOC entry 4376 (class 0 OID 0)
-- Dependencies: 295
-- Name: TABLE choice_list_items; Type: ACL; Schema: public; Owner: postgres
--

GRANT ALL ON TABLE public.choice_list_items TO anon;
GRANT ALL ON TABLE public.choice_list_items TO authenticated;
GRANT ALL ON TABLE public.choice_list_items TO service_role;


--
-- TOC entry 4377 (class 0 OID 0)
-- Dependencies: 294
-- Name: TABLE choice_lists; Type: ACL; Schema: public; Owner: postgres
--

GRANT ALL ON TABLE public.choice_lists TO anon;
GRANT ALL ON TABLE public.choice_lists TO authenticated;
GRANT ALL ON TABLE public.choice_lists TO service_role;


--
-- TOC entry 4378 (class 0 OID 0)
-- Dependencies: 284
-- Name: TABLE closing_ranks; Type: ACL; Schema: public; Owner: postgres
--

GRANT ALL ON TABLE public.closing_ranks TO anon;
GRANT ALL ON TABLE public.closing_ranks TO authenticated;
GRANT ALL ON TABLE public.closing_ranks TO service_role;


--
-- TOC entry 4379 (class 0 OID 0)
-- Dependencies: 285
-- Name: TABLE closing_ranks_versions; Type: ACL; Schema: public; Owner: postgres
--

GRANT ALL ON TABLE public.closing_ranks_versions TO anon;
GRANT ALL ON TABLE public.closing_ranks_versions TO authenticated;
GRANT ALL ON TABLE public.closing_ranks_versions TO service_role;


--
-- TOC entry 4380 (class 0 OID 0)
-- Dependencies: 301
-- Name: TABLE coaching_institutes; Type: ACL; Schema: public; Owner: postgres
--

GRANT ALL ON TABLE public.coaching_institutes TO anon;
GRANT ALL ON TABLE public.coaching_institutes TO authenticated;
GRANT ALL ON TABLE public.coaching_institutes TO service_role;


--
-- TOC entry 4381 (class 0 OID 0)
-- Dependencies: 282
-- Name: TABLE college_bonds; Type: ACL; Schema: public; Owner: postgres
--

GRANT ALL ON TABLE public.college_bonds TO anon;
GRANT ALL ON TABLE public.college_bonds TO authenticated;
GRANT ALL ON TABLE public.college_bonds TO service_role;


--
-- TOC entry 4382 (class 0 OID 0)
-- Dependencies: 281
-- Name: TABLE college_fees; Type: ACL; Schema: public; Owner: postgres
--

GRANT ALL ON TABLE public.college_fees TO anon;
GRANT ALL ON TABLE public.college_fees TO authenticated;
GRANT ALL ON TABLE public.college_fees TO service_role;


--
-- TOC entry 4383 (class 0 OID 0)
-- Dependencies: 279
-- Name: TABLE colleges; Type: ACL; Schema: public; Owner: postgres
--

GRANT ALL ON TABLE public.colleges TO anon;
GRANT ALL ON TABLE public.colleges TO authenticated;
GRANT ALL ON TABLE public.colleges TO service_role;


--
-- TOC entry 4384 (class 0 OID 0)
-- Dependencies: 289
-- Name: TABLE content_articles; Type: ACL; Schema: public; Owner: postgres
--

GRANT ALL ON TABLE public.content_articles TO anon;
GRANT ALL ON TABLE public.content_articles TO authenticated;
GRANT ALL ON TABLE public.content_articles TO service_role;


--
-- TOC entry 4385 (class 0 OID 0)
-- Dependencies: 277
-- Name: TABLE counseling_authorities; Type: ACL; Schema: public; Owner: postgres
--

GRANT ALL ON TABLE public.counseling_authorities TO anon;
GRANT ALL ON TABLE public.counseling_authorities TO authenticated;
GRANT ALL ON TABLE public.counseling_authorities TO service_role;


--
-- TOC entry 4386 (class 0 OID 0)
-- Dependencies: 278
-- Name: TABLE counseling_rounds; Type: ACL; Schema: public; Owner: postgres
--

GRANT ALL ON TABLE public.counseling_rounds TO anon;
GRANT ALL ON TABLE public.counseling_rounds TO authenticated;
GRANT ALL ON TABLE public.counseling_rounds TO service_role;


--
-- TOC entry 4387 (class 0 OID 0)
-- Dependencies: 304
-- Name: TABLE counsellor_notes; Type: ACL; Schema: public; Owner: postgres
--

GRANT ALL ON TABLE public.counsellor_notes TO anon;
GRANT ALL ON TABLE public.counsellor_notes TO authenticated;
GRANT ALL ON TABLE public.counsellor_notes TO service_role;


--
-- TOC entry 4388 (class 0 OID 0)
-- Dependencies: 302
-- Name: TABLE counsellors; Type: ACL; Schema: public; Owner: postgres
--

GRANT ALL ON TABLE public.counsellors TO anon;
GRANT ALL ON TABLE public.counsellors TO authenticated;
GRANT ALL ON TABLE public.counsellors TO service_role;


--
-- TOC entry 4389 (class 0 OID 0)
-- Dependencies: 280
-- Name: TABLE courses; Type: ACL; Schema: public; Owner: postgres
--

GRANT ALL ON TABLE public.courses TO anon;
GRANT ALL ON TABLE public.courses TO authenticated;
GRANT ALL ON TABLE public.courses TO service_role;


--
-- TOC entry 4390 (class 0 OID 0)
-- Dependencies: 291
-- Name: TABLE data_imports; Type: ACL; Schema: public; Owner: postgres
--

GRANT ALL ON TABLE public.data_imports TO anon;
GRANT ALL ON TABLE public.data_imports TO authenticated;
GRANT ALL ON TABLE public.data_imports TO service_role;


--
-- TOC entry 4391 (class 0 OID 0)
-- Dependencies: 303
-- Name: TABLE institute_students; Type: ACL; Schema: public; Owner: postgres
--

GRANT ALL ON TABLE public.institute_students TO anon;
GRANT ALL ON TABLE public.institute_students TO authenticated;
GRANT ALL ON TABLE public.institute_students TO service_role;


--
-- TOC entry 4392 (class 0 OID 0)
-- Dependencies: 296
-- Name: TABLE notifications; Type: ACL; Schema: public; Owner: postgres
--

GRANT ALL ON TABLE public.notifications TO anon;
GRANT ALL ON TABLE public.notifications TO authenticated;
GRANT ALL ON TABLE public.notifications TO service_role;


--
-- TOC entry 4393 (class 0 OID 0)
-- Dependencies: 288
-- Name: TABLE payments; Type: ACL; Schema: public; Owner: postgres
--

GRANT ALL ON TABLE public.payments TO anon;
GRANT ALL ON TABLE public.payments TO authenticated;
GRANT ALL ON TABLE public.payments TO service_role;


--
-- TOC entry 4394 (class 0 OID 0)
-- Dependencies: 300
-- Name: TABLE pg_closing_ranks; Type: ACL; Schema: public; Owner: postgres
--

GRANT ALL ON TABLE public.pg_closing_ranks TO anon;
GRANT ALL ON TABLE public.pg_closing_ranks TO authenticated;
GRANT ALL ON TABLE public.pg_closing_ranks TO service_role;


--
-- TOC entry 4395 (class 0 OID 0)
-- Dependencies: 299
-- Name: TABLE pg_course_seats; Type: ACL; Schema: public; Owner: postgres
--

GRANT ALL ON TABLE public.pg_course_seats TO anon;
GRANT ALL ON TABLE public.pg_course_seats TO authenticated;
GRANT ALL ON TABLE public.pg_course_seats TO service_role;


--
-- TOC entry 4396 (class 0 OID 0)
-- Dependencies: 292
-- Name: TABLE predictor_logs; Type: ACL; Schema: public; Owner: postgres
--

GRANT ALL ON TABLE public.predictor_logs TO anon;
GRANT ALL ON TABLE public.predictor_logs TO authenticated;
GRANT ALL ON TABLE public.predictor_logs TO service_role;


--
-- TOC entry 4397 (class 0 OID 0)
-- Dependencies: 275
-- Name: TABLE profiles; Type: ACL; Schema: public; Owner: postgres
--

GRANT ALL ON TABLE public.profiles TO anon;
GRANT ALL ON TABLE public.profiles TO authenticated;
GRANT ALL ON TABLE public.profiles TO service_role;


--
-- TOC entry 4398 (class 0 OID 0)
-- Dependencies: 293
-- Name: TABLE saved_colleges; Type: ACL; Schema: public; Owner: postgres
--

GRANT ALL ON TABLE public.saved_colleges TO anon;
GRANT ALL ON TABLE public.saved_colleges TO authenticated;
GRANT ALL ON TABLE public.saved_colleges TO service_role;


--
-- TOC entry 4399 (class 0 OID 0)
-- Dependencies: 283
-- Name: TABLE seat_matrix; Type: ACL; Schema: public; Owner: postgres
--

GRANT ALL ON TABLE public.seat_matrix TO anon;
GRANT ALL ON TABLE public.seat_matrix TO authenticated;
GRANT ALL ON TABLE public.seat_matrix TO service_role;


--
-- TOC entry 4400 (class 0 OID 0)
-- Dependencies: 276
-- Name: TABLE student_profiles; Type: ACL; Schema: public; Owner: postgres
--

GRANT ALL ON TABLE public.student_profiles TO anon;
GRANT ALL ON TABLE public.student_profiles TO authenticated;
GRANT ALL ON TABLE public.student_profiles TO service_role;


--
-- TOC entry 4401 (class 0 OID 0)
-- Dependencies: 286
-- Name: TABLE subscription_plans; Type: ACL; Schema: public; Owner: postgres
--

GRANT ALL ON TABLE public.subscription_plans TO anon;
GRANT ALL ON TABLE public.subscription_plans TO authenticated;
GRANT ALL ON TABLE public.subscription_plans TO service_role;


--
-- TOC entry 4402 (class 0 OID 0)
-- Dependencies: 305
-- Name: TABLE support_tickets; Type: ACL; Schema: public; Owner: postgres
--

GRANT ALL ON TABLE public.support_tickets TO anon;
GRANT ALL ON TABLE public.support_tickets TO authenticated;
GRANT ALL ON TABLE public.support_tickets TO service_role;


--
-- TOC entry 4403 (class 0 OID 0)
-- Dependencies: 306
-- Name: TABLE ticket_messages; Type: ACL; Schema: public; Owner: postgres
--

GRANT ALL ON TABLE public.ticket_messages TO anon;
GRANT ALL ON TABLE public.ticket_messages TO authenticated;
GRANT ALL ON TABLE public.ticket_messages TO service_role;


--
-- TOC entry 4404 (class 0 OID 0)
-- Dependencies: 274
-- Name: TABLE user_roles; Type: ACL; Schema: public; Owner: postgres
--

GRANT ALL ON TABLE public.user_roles TO anon;
GRANT ALL ON TABLE public.user_roles TO authenticated;
GRANT ALL ON TABLE public.user_roles TO service_role;


--
-- TOC entry 4405 (class 0 OID 0)
-- Dependencies: 287
-- Name: TABLE user_subscriptions; Type: ACL; Schema: public; Owner: postgres
--

GRANT ALL ON TABLE public.user_subscriptions TO anon;
GRANT ALL ON TABLE public.user_subscriptions TO authenticated;
GRANT ALL ON TABLE public.user_subscriptions TO service_role;


--
-- TOC entry 2472 (class 826 OID 16490)
-- Name: DEFAULT PRIVILEGES FOR SEQUENCES; Type: DEFAULT ACL; Schema: public; Owner: postgres
--

ALTER DEFAULT PRIVILEGES FOR ROLE postgres IN SCHEMA public GRANT ALL ON SEQUENCES TO postgres;
ALTER DEFAULT PRIVILEGES FOR ROLE postgres IN SCHEMA public GRANT ALL ON SEQUENCES TO anon;
ALTER DEFAULT PRIVILEGES FOR ROLE postgres IN SCHEMA public GRANT ALL ON SEQUENCES TO authenticated;
ALTER DEFAULT PRIVILEGES FOR ROLE postgres IN SCHEMA public GRANT ALL ON SEQUENCES TO service_role;


--
-- TOC entry 2473 (class 826 OID 16491)
-- Name: DEFAULT PRIVILEGES FOR SEQUENCES; Type: DEFAULT ACL; Schema: public; Owner: supabase_admin
--

ALTER DEFAULT PRIVILEGES FOR ROLE supabase_admin IN SCHEMA public GRANT ALL ON SEQUENCES TO postgres;
ALTER DEFAULT PRIVILEGES FOR ROLE supabase_admin IN SCHEMA public GRANT ALL ON SEQUENCES TO anon;
ALTER DEFAULT PRIVILEGES FOR ROLE supabase_admin IN SCHEMA public GRANT ALL ON SEQUENCES TO authenticated;
ALTER DEFAULT PRIVILEGES FOR ROLE supabase_admin IN SCHEMA public GRANT ALL ON SEQUENCES TO service_role;


--
-- TOC entry 2471 (class 826 OID 16489)
-- Name: DEFAULT PRIVILEGES FOR FUNCTIONS; Type: DEFAULT ACL; Schema: public; Owner: postgres
--

ALTER DEFAULT PRIVILEGES FOR ROLE postgres IN SCHEMA public GRANT ALL ON FUNCTIONS TO postgres;
ALTER DEFAULT PRIVILEGES FOR ROLE postgres IN SCHEMA public GRANT ALL ON FUNCTIONS TO anon;
ALTER DEFAULT PRIVILEGES FOR ROLE postgres IN SCHEMA public GRANT ALL ON FUNCTIONS TO authenticated;
ALTER DEFAULT PRIVILEGES FOR ROLE postgres IN SCHEMA public GRANT ALL ON FUNCTIONS TO service_role;


--
-- TOC entry 2475 (class 826 OID 16493)
-- Name: DEFAULT PRIVILEGES FOR FUNCTIONS; Type: DEFAULT ACL; Schema: public; Owner: supabase_admin
--

ALTER DEFAULT PRIVILEGES FOR ROLE supabase_admin IN SCHEMA public GRANT ALL ON FUNCTIONS TO postgres;
ALTER DEFAULT PRIVILEGES FOR ROLE supabase_admin IN SCHEMA public GRANT ALL ON FUNCTIONS TO anon;
ALTER DEFAULT PRIVILEGES FOR ROLE supabase_admin IN SCHEMA public GRANT ALL ON FUNCTIONS TO authenticated;
ALTER DEFAULT PRIVILEGES FOR ROLE supabase_admin IN SCHEMA public GRANT ALL ON FUNCTIONS TO service_role;


--
-- TOC entry 2470 (class 826 OID 16488)
-- Name: DEFAULT PRIVILEGES FOR TABLES; Type: DEFAULT ACL; Schema: public; Owner: postgres
--

ALTER DEFAULT PRIVILEGES FOR ROLE postgres IN SCHEMA public GRANT ALL ON TABLES TO postgres;
ALTER DEFAULT PRIVILEGES FOR ROLE postgres IN SCHEMA public GRANT ALL ON TABLES TO anon;
ALTER DEFAULT PRIVILEGES FOR ROLE postgres IN SCHEMA public GRANT ALL ON TABLES TO authenticated;
ALTER DEFAULT PRIVILEGES FOR ROLE postgres IN SCHEMA public GRANT ALL ON TABLES TO service_role;


--
-- TOC entry 2474 (class 826 OID 16492)
-- Name: DEFAULT PRIVILEGES FOR TABLES; Type: DEFAULT ACL; Schema: public; Owner: supabase_admin
--

ALTER DEFAULT PRIVILEGES FOR ROLE supabase_admin IN SCHEMA public GRANT ALL ON TABLES TO postgres;
ALTER DEFAULT PRIVILEGES FOR ROLE supabase_admin IN SCHEMA public GRANT ALL ON TABLES TO anon;
ALTER DEFAULT PRIVILEGES FOR ROLE supabase_admin IN SCHEMA public GRANT ALL ON TABLES TO authenticated;
ALTER DEFAULT PRIVILEGES FOR ROLE supabase_admin IN SCHEMA public GRANT ALL ON TABLES TO service_role;


-- Completed on 2026-02-03 10:43:55

--
--

\unrestrict fIxQDpnQL5BnEmspmKWdGyfeoGX4FKABytzullscbuDanabcwcsPDgxarysYfD6

