--
-- PostgreSQL database dump
--

\restrict rJe1Gy5GMPzawpaJZiQmUDxD6gCxnwjfhMGsGM8QvA0b3acVAPjT7ftg1eemfem

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

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

ALTER TABLE IF EXISTS ONLY public.vendor_settlements DROP CONSTRAINT IF EXISTS fkt7l1kk79o5lc6uod8jv910mnf;
ALTER TABLE IF EXISTS ONLY public.bookings DROP CONSTRAINT IF EXISTS fkstpgklh4a1lexve7b5qn8ebwp;
ALTER TABLE IF EXISTS ONLY public.users DROP CONSTRAINT IF EXISTS fkrq6el5qawr0fnqofn8yjmqr0i;
ALTER TABLE IF EXISTS ONLY public.users DROP CONSTRAINT IF EXISTS fkp3aufrqlptl7jn77avemkbpxr;
ALTER TABLE IF EXISTS ONLY public.drivers DROP CONSTRAINT IF EXISTS fko2ld66drmgv084wws15u6hqor;
ALTER TABLE IF EXISTS ONLY public.users DROP CONSTRAINT IF EXISTS fkl4l7wq0lyhhq2pje8wro9gfh9;
ALTER TABLE IF EXISTS ONLY public.user_permissions DROP CONSTRAINT IF EXISTS fkkowxl8b2bngrxd1gafh13005u;
ALTER TABLE IF EXISTS ONLY public.vehicle_locations DROP CONSTRAINT IF EXISTS fkkgfol016f9hl7pt1nphs5yrsn;
ALTER TABLE IF EXISTS ONLY public.car_documents DROP CONSTRAINT IF EXISTS fkjr1xvrrs96ey2efq4jww071bh;
ALTER TABLE IF EXISTS ONLY public.bookings DROP CONSTRAINT IF EXISTS fkj1y19nc7wf0rdp24pyhomn7ck;
ALTER TABLE IF EXISTS ONLY public.bookings DROP CONSTRAINT IF EXISTS fkj0bxwbe92tfc6xwp7pdffo3pq;
ALTER TABLE IF EXISTS ONLY public.reviews DROP CONSTRAINT IF EXISTS fkieeb3p5v84i1xja7nbj1vkkeg;
ALTER TABLE IF EXISTS ONLY public.inspection_records DROP CONSTRAINT IF EXISTS fkhla1wpktqjsujkg3ihm79iaxh;
ALTER TABLE IF EXISTS ONLY public.bookings DROP CONSTRAINT IF EXISTS fkeyog2oic85xg7hsu2je2lx3s6;
ALTER TABLE IF EXISTS ONLY public.drivers DROP CONSTRAINT IF EXISTS fkdgi05p3479yd57btyrgmp4mle;
ALTER TABLE IF EXISTS ONLY public.reviews DROP CONSTRAINT IF EXISTS fkcgy7qjc1r99dp117y9en6lxye;
ALTER TABLE IF EXISTS ONLY public.payments DROP CONSTRAINT IF EXISTS fkc52o2b1jkxttngufqp3t7jr3h;
ALTER TABLE IF EXISTS ONLY public.invoices DROP CONSTRAINT IF EXISTS fkb9bhb7xre5v64qvjeholh3qj0;
ALTER TABLE IF EXISTS ONLY public.maintenance_records DROP CONSTRAINT IF EXISTS fka4dsfs77eje856jth3peepq16;
ALTER TABLE IF EXISTS ONLY public.car_photos DROP CONSTRAINT IF EXISTS fk75ncp53p4jb47tewrlvtwmh41;
ALTER TABLE IF EXISTS ONLY public.inspection_records DROP CONSTRAINT IF EXISTS fk753d5fiil3olhyi5t0sbpn8eh;
ALTER TABLE IF EXISTS ONLY public.cars DROP CONSTRAINT IF EXISTS fk6lq0lg9o4o6c4weriter6574f;
ALTER TABLE IF EXISTS ONLY public.car_feature_tags DROP CONSTRAINT IF EXISTS fk6js0s623ar2p4tjoa6ank1lm2;
ALTER TABLE IF EXISTS ONLY public.driver_documents DROP CONSTRAINT IF EXISTS fk4cqh5sfs29eeky0q37t2x78vq;
ALTER TABLE IF EXISTS ONLY public.reviews DROP CONSTRAINT IF EXISTS fk28an517hrxtt2bsg93uefugrm;
DROP INDEX IF EXISTS public.idx_audit_username;
DROP INDEX IF EXISTS public.idx_audit_created;
ALTER TABLE IF EXISTS ONLY public.vendors DROP CONSTRAINT IF EXISTS vendors_pkey;
ALTER TABLE IF EXISTS ONLY public.vendor_settlements DROP CONSTRAINT IF EXISTS vendor_settlements_pkey;
ALTER TABLE IF EXISTS ONLY public.vehicle_locations DROP CONSTRAINT IF EXISTS vehicle_locations_pkey;
ALTER TABLE IF EXISTS ONLY public.users DROP CONSTRAINT IF EXISTS users_pkey;
ALTER TABLE IF EXISTS ONLY public.users DROP CONSTRAINT IF EXISTS ukr43af9ap4edm43mmtq01oddj6;
ALTER TABLE IF EXISTS ONLY public.invoices DROP CONSTRAINT IF EXISTS ukqn380ix1ge287r0rd8th12bwi;
ALTER TABLE IF EXISTS ONLY public.invoices DROP CONSTRAINT IF EXISTS ukl1x55mfsay7co0r3m9ynvipd5;
ALTER TABLE IF EXISTS ONLY public.vehicle_locations DROP CONSTRAINT IF EXISTS ukke1m6iutu0pt6jorg1jr4ejx2;
ALTER TABLE IF EXISTS ONLY public.cars DROP CONSTRAINT IF EXISTS uki3ldfyekqw49cw6omv99rrfkx;
ALTER TABLE IF EXISTS ONLY public.users DROP CONSTRAINT IF EXISTS uk6dotkott2kjsp8vw4d0m25fb7;
ALTER TABLE IF EXISTS ONLY public.drivers DROP CONSTRAINT IF EXISTS uk5v2gvq951rwadgpkg6wcr8ue9;
ALTER TABLE IF EXISTS ONLY public.categories DROP CONSTRAINT IF EXISTS uk17k21odm3kbnriiikewhatvlm;
ALTER TABLE IF EXISTS ONLY public.system_config DROP CONSTRAINT IF EXISTS system_config_pkey;
ALTER TABLE IF EXISTS ONLY public.reviews DROP CONSTRAINT IF EXISTS reviews_pkey;
ALTER TABLE IF EXISTS ONLY public.payments DROP CONSTRAINT IF EXISTS payments_pkey;
ALTER TABLE IF EXISTS ONLY public.organization DROP CONSTRAINT IF EXISTS organization_pkey;
ALTER TABLE IF EXISTS ONLY public.maintenance_records DROP CONSTRAINT IF EXISTS maintenance_records_pkey;
ALTER TABLE IF EXISTS ONLY public.invoices DROP CONSTRAINT IF EXISTS invoices_pkey;
ALTER TABLE IF EXISTS ONLY public.inspection_records DROP CONSTRAINT IF EXISTS inspection_records_pkey;
ALTER TABLE IF EXISTS ONLY public.drivers DROP CONSTRAINT IF EXISTS drivers_pkey;
ALTER TABLE IF EXISTS ONLY public.driver_documents DROP CONSTRAINT IF EXISTS driver_documents_pkey;
ALTER TABLE IF EXISTS ONLY public.categories DROP CONSTRAINT IF EXISTS categories_pkey;
ALTER TABLE IF EXISTS ONLY public.cars DROP CONSTRAINT IF EXISTS cars_pkey;
ALTER TABLE IF EXISTS ONLY public.car_photos DROP CONSTRAINT IF EXISTS car_photos_pkey;
ALTER TABLE IF EXISTS ONLY public.car_documents DROP CONSTRAINT IF EXISTS car_documents_pkey;
ALTER TABLE IF EXISTS ONLY public.bookings DROP CONSTRAINT IF EXISTS bookings_pkey;
ALTER TABLE IF EXISTS ONLY public.audit_logs DROP CONSTRAINT IF EXISTS audit_logs_pkey;
DROP TABLE IF EXISTS public.vendors;
DROP TABLE IF EXISTS public.vendor_settlements;
DROP TABLE IF EXISTS public.vehicle_locations;
DROP TABLE IF EXISTS public.users;
DROP TABLE IF EXISTS public.user_permissions;
DROP TABLE IF EXISTS public.system_config;
DROP TABLE IF EXISTS public.reviews;
DROP TABLE IF EXISTS public.payments;
DROP TABLE IF EXISTS public.organization;
DROP TABLE IF EXISTS public.maintenance_records;
DROP TABLE IF EXISTS public.invoices;
DROP TABLE IF EXISTS public.inspection_records;
DROP TABLE IF EXISTS public.drivers;
DROP TABLE IF EXISTS public.driver_documents;
DROP TABLE IF EXISTS public.categories;
DROP TABLE IF EXISTS public.cars;
DROP TABLE IF EXISTS public.car_photos;
DROP TABLE IF EXISTS public.car_feature_tags;
DROP TABLE IF EXISTS public.car_documents;
DROP TABLE IF EXISTS public.bookings;
DROP TABLE IF EXISTS public.audit_logs;
SET default_tablespace = '';

SET default_table_access_method = heap;

--
-- Name: audit_logs; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.audit_logs (
    id bigint NOT NULL,
    action character varying(255),
    created_at timestamp(6) without time zone,
    detail character varying(500),
    entity_id character varying(255),
    entity_type character varying(255),
    ip character varying(255),
    role character varying(255),
    username character varying(255)
);


--
-- Name: audit_logs_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

ALTER TABLE public.audit_logs ALTER COLUMN id ADD GENERATED BY DEFAULT AS IDENTITY (
    SEQUENCE NAME public.audit_logs_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1
);


--
-- Name: bookings; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.bookings (
    id bigint NOT NULL,
    created_at timestamp(6) without time zone NOT NULL,
    drop_location character varying(255) NOT NULL,
    pickup_date date NOT NULL,
    pickup_location character varying(255) NOT NULL,
    return_date date NOT NULL,
    status character varying(255) NOT NULL,
    total_amount numeric(38,2) NOT NULL,
    car_id bigint NOT NULL,
    user_id bigint NOT NULL,
    driver_id bigint,
    commission_amount numeric(38,2),
    commission_percent numeric(38,2),
    driver_charge numeric(38,2),
    rental_unit character varying(255),
    revenue_owner character varying(255),
    tax_amount numeric(38,2),
    tax_percent numeric(38,2),
    vehicle_charge numeric(38,2),
    vendor_id bigint,
    with_driver boolean DEFAULT false NOT NULL,
    quantity integer DEFAULT 1 NOT NULL,
    CONSTRAINT bookings_rental_unit_check CHECK (((rental_unit)::text = ANY ((ARRAY['HOUR'::character varying, 'DAY'::character varying, 'MONTH'::character varying])::text[]))),
    CONSTRAINT bookings_revenue_owner_check CHECK (((revenue_owner)::text = ANY ((ARRAY['OWNED'::character varying, 'VENDOR'::character varying])::text[]))),
    CONSTRAINT bookings_status_check CHECK (((status)::text = ANY ((ARRAY['PENDING'::character varying, 'CONFIRMED'::character varying, 'CANCELLED'::character varying, 'COMPLETED'::character varying])::text[])))
);


--
-- Name: bookings_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

ALTER TABLE public.bookings ALTER COLUMN id ADD GENERATED BY DEFAULT AS IDENTITY (
    SEQUENCE NAME public.bookings_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1
);


--
-- Name: car_documents; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.car_documents (
    id bigint NOT NULL,
    doc_type character varying(255) NOT NULL,
    expiry_date date,
    file_url character varying(255),
    issued_date date,
    car_id bigint NOT NULL,
    CONSTRAINT car_documents_doc_type_check CHECK (((doc_type)::text = ANY ((ARRAY['RC'::character varying, 'INSURANCE'::character varying, 'PERMIT'::character varying, 'POLLUTION'::character varying, 'FITNESS'::character varying, 'OTHER'::character varying])::text[])))
);


--
-- Name: car_documents_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

ALTER TABLE public.car_documents ALTER COLUMN id ADD GENERATED BY DEFAULT AS IDENTITY (
    SEQUENCE NAME public.car_documents_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1
);


--
-- Name: car_feature_tags; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.car_feature_tags (
    car_id bigint NOT NULL,
    tag character varying(255)
);


--
-- Name: car_photos; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.car_photos (
    id bigint NOT NULL,
    sort_order integer NOT NULL,
    url character varying(255) NOT NULL,
    car_id bigint NOT NULL
);


--
-- Name: car_photos_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

ALTER TABLE public.car_photos ALTER COLUMN id ADD GENERATED BY DEFAULT AS IDENTITY (
    SEQUENCE NAME public.car_photos_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1
);


--
-- Name: cars; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.cars (
    id bigint NOT NULL,
    available boolean NOT NULL,
    fuel_type character varying(255),
    image_url character varying(255),
    make character varying(255) NOT NULL,
    model character varying(255) NOT NULL,
    price_per_day numeric(38,2) NOT NULL,
    registration_number character varying(255) NOT NULL,
    seats integer NOT NULL,
    transmission character varying(255),
    type character varying(255) NOT NULL,
    colour character varying(255),
    hourly_rate numeric(38,2),
    monthly_rate numeric(38,2),
    ownership character varying(255) DEFAULT 'OWNED'::character varying,
    status character varying(255) DEFAULT 'ACTIVE'::character varying,
    units_total integer DEFAULT 1 NOT NULL,
    year_of_registration integer,
    commission_percent_override numeric(38,2),
    vendor_id bigint,
    CONSTRAINT cars_fuel_type_check CHECK (((fuel_type)::text = ANY ((ARRAY['PETROL'::character varying, 'DIESEL'::character varying, 'ELECTRIC'::character varying, 'HYBRID'::character varying, 'CNG'::character varying])::text[]))),
    CONSTRAINT cars_ownership_check CHECK (((ownership)::text = ANY ((ARRAY['OWNED'::character varying, 'VENDOR'::character varying])::text[]))),
    CONSTRAINT cars_seats_check CHECK (((seats <= 15) AND (seats >= 2))),
    CONSTRAINT cars_status_check CHECK (((status)::text = ANY ((ARRAY['ACTIVE'::character varying, 'MAINTENANCE'::character varying, 'RETIRED'::character varying])::text[]))),
    CONSTRAINT cars_transmission_check CHECK (((transmission)::text = ANY ((ARRAY['MANUAL'::character varying, 'AUTOMATIC'::character varying])::text[]))),
    CONSTRAINT cars_type_check CHECK (((type)::text = ANY ((ARRAY['HATCHBACK'::character varying, 'SEDAN'::character varying, 'SUV'::character varying, 'MUV'::character varying, 'LUXURY'::character varying, 'BIKE'::character varying])::text[])))
);


--
-- Name: cars_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

ALTER TABLE public.cars ALTER COLUMN id ADD GENERATED BY DEFAULT AS IDENTITY (
    SEQUENCE NAME public.cars_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1
);


--
-- Name: categories; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.categories (
    id bigint NOT NULL,
    active boolean NOT NULL,
    description character varying(255),
    name character varying(255) NOT NULL,
    type character varying(255) NOT NULL,
    CONSTRAINT categories_type_check CHECK (((type)::text = ANY ((ARRAY['VEHICLE'::character varying, 'DRIVER'::character varying, 'CUSTOMER'::character varying])::text[])))
);


--
-- Name: categories_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

ALTER TABLE public.categories ALTER COLUMN id ADD GENERATED BY DEFAULT AS IDENTITY (
    SEQUENCE NAME public.categories_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1
);


--
-- Name: driver_documents; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.driver_documents (
    id bigint NOT NULL,
    doc_type character varying(255) NOT NULL,
    expiry_date date,
    file_url character varying(255),
    issued_date date,
    driver_id bigint NOT NULL,
    CONSTRAINT driver_documents_doc_type_check CHECK (((doc_type)::text = ANY ((ARRAY['LICENCE'::character varying, 'ID_PROOF'::character varying, 'POLICE_VERIFICATION'::character varying, 'MEDICAL'::character varying, 'OTHER'::character varying])::text[])))
);


--
-- Name: driver_documents_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

ALTER TABLE public.driver_documents ALTER COLUMN id ADD GENERATED BY DEFAULT AS IDENTITY (
    SEQUENCE NAME public.driver_documents_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1
);


--
-- Name: drivers; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.drivers (
    id bigint NOT NULL,
    daily_charge numeric(38,2),
    employment_type character varying(255) DEFAULT 'EMPLOYED'::character varying,
    hourly_charge numeric(38,2),
    licence_expiry date,
    licence_number character varying(255) NOT NULL,
    monthly_charge numeric(38,2),
    name character varying(255) NOT NULL,
    phone character varying(255),
    photo_url character varying(255),
    status character varying(255) DEFAULT 'AVAILABLE'::character varying,
    years_experience integer DEFAULT 0 NOT NULL,
    category_id bigint,
    vendor_id bigint,
    CONSTRAINT drivers_employment_type_check CHECK (((employment_type)::text = ANY ((ARRAY['EMPLOYED'::character varying, 'VENDOR'::character varying])::text[]))),
    CONSTRAINT drivers_status_check CHECK (((status)::text = ANY ((ARRAY['AVAILABLE'::character varying, 'ON_TRIP'::character varying, 'OFF'::character varying])::text[]))),
    CONSTRAINT drivers_years_experience_check CHECK ((years_experience >= 0))
);


--
-- Name: drivers_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

ALTER TABLE public.drivers ALTER COLUMN id ADD GENERATED BY DEFAULT AS IDENTITY (
    SEQUENCE NAME public.drivers_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1
);


--
-- Name: inspection_records; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.inspection_records (
    id bigint NOT NULL,
    condition character varying(255) NOT NULL,
    created_at timestamp(6) without time zone,
    damage_notes character varying(1000),
    fuel_level integer,
    inspection_date date,
    inspector character varying(255),
    odometer integer,
    photo_url character varying(255),
    type character varying(255) NOT NULL,
    booking_id bigint,
    car_id bigint NOT NULL,
    CONSTRAINT inspection_records_condition_check CHECK (((condition)::text = ANY ((ARRAY['GOOD'::character varying, 'MINOR_DAMAGE'::character varying, 'MAJOR_DAMAGE'::character varying])::text[]))),
    CONSTRAINT inspection_records_type_check CHECK (((type)::text = ANY ((ARRAY['PRE_TRIP'::character varying, 'POST_TRIP'::character varying, 'PERIODIC'::character varying, 'INCIDENT'::character varying])::text[])))
);


--
-- Name: inspection_records_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

ALTER TABLE public.inspection_records ALTER COLUMN id ADD GENERATED BY DEFAULT AS IDENTITY (
    SEQUENCE NAME public.inspection_records_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1
);


--
-- Name: invoices; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.invoices (
    id bigint NOT NULL,
    invoice_number character varying(255) NOT NULL,
    issued_at timestamp(6) without time zone NOT NULL,
    subtotal numeric(38,2),
    tax_amount numeric(38,2),
    total numeric(38,2),
    booking_id bigint NOT NULL
);


--
-- Name: invoices_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

ALTER TABLE public.invoices ALTER COLUMN id ADD GENERATED BY DEFAULT AS IDENTITY (
    SEQUENCE NAME public.invoices_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1
);


--
-- Name: maintenance_records; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.maintenance_records (
    id bigint NOT NULL,
    cost numeric(38,2),
    created_at timestamp(6) without time zone,
    garage character varying(255),
    next_service_date date,
    next_service_odometer integer,
    notes character varying(1000),
    odometer integer,
    service_date date,
    status character varying(255) NOT NULL,
    type character varying(255) NOT NULL,
    car_id bigint NOT NULL,
    CONSTRAINT maintenance_records_status_check CHECK (((status)::text = ANY ((ARRAY['SCHEDULED'::character varying, 'IN_PROGRESS'::character varying, 'COMPLETED'::character varying])::text[]))),
    CONSTRAINT maintenance_records_type_check CHECK (((type)::text = ANY ((ARRAY['SERVICE'::character varying, 'REPAIR'::character varying, 'TYRE'::character varying, 'BATTERY'::character varying, 'BODY_WORK'::character varying, 'CLEANING'::character varying, 'INSURANCE_RENEWAL'::character varying, 'OTHER'::character varying])::text[])))
);


--
-- Name: maintenance_records_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

ALTER TABLE public.maintenance_records ALTER COLUMN id ADD GENERATED BY DEFAULT AS IDENTITY (
    SEQUENCE NAME public.maintenance_records_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1
);


--
-- Name: organization; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.organization (
    id bigint NOT NULL,
    address character varying(255),
    contact_email character varying(255),
    currency_code character varying(255) NOT NULL,
    gst_number character varying(255),
    legal_name character varying(255),
    logo_url character varying(255),
    name character varying(255) NOT NULL,
    phone character varying(255)
);


--
-- Name: organization_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

ALTER TABLE public.organization ALTER COLUMN id ADD GENERATED BY DEFAULT AS IDENTITY (
    SEQUENCE NAME public.organization_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1
);


--
-- Name: payments; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.payments (
    id bigint NOT NULL,
    amount numeric(38,2) NOT NULL,
    created_at timestamp(6) without time zone,
    method character varying(255) NOT NULL,
    notes character varying(255),
    paid_at date,
    recorded_by character varying(255),
    reference character varying(255),
    booking_id bigint NOT NULL,
    CONSTRAINT payments_method_check CHECK (((method)::text = ANY ((ARRAY['CASH'::character varying, 'UPI'::character varying, 'CARD'::character varying, 'BANK_TRANSFER'::character varying, 'ONLINE'::character varying, 'OTHER'::character varying])::text[])))
);


--
-- Name: payments_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

ALTER TABLE public.payments ALTER COLUMN id ADD GENERATED BY DEFAULT AS IDENTITY (
    SEQUENCE NAME public.payments_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1
);


--
-- Name: reviews; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.reviews (
    id bigint NOT NULL,
    approved boolean NOT NULL,
    comment character varying(1000),
    created_at timestamp(6) without time zone,
    rating integer NOT NULL,
    booking_id bigint,
    car_id bigint NOT NULL,
    user_id bigint NOT NULL,
    CONSTRAINT reviews_rating_check CHECK (((rating <= 5) AND (rating >= 1)))
);


--
-- Name: reviews_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

ALTER TABLE public.reviews ALTER COLUMN id ADD GENERATED BY DEFAULT AS IDENTITY (
    SEQUENCE NAME public.reviews_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1
);


--
-- Name: system_config; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.system_config (
    id bigint NOT NULL,
    currency_code character varying(255),
    default_commission_percent numeric(38,2),
    default_driver_daily_charge numeric(38,2),
    default_tax_percent numeric(38,2),
    invoice_prefix character varying(255),
    settlement_cycle character varying(255),
    CONSTRAINT system_config_settlement_cycle_check CHECK (((settlement_cycle)::text = ANY ((ARRAY['WEEKLY'::character varying, 'MONTHLY'::character varying])::text[])))
);


--
-- Name: system_config_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

ALTER TABLE public.system_config ALTER COLUMN id ADD GENERATED BY DEFAULT AS IDENTITY (
    SEQUENCE NAME public.system_config_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1
);


--
-- Name: user_permissions; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.user_permissions (
    user_id bigint NOT NULL,
    permission character varying(255),
    CONSTRAINT user_permissions_permission_check CHECK (((permission)::text = ANY ((ARRAY['MANAGE_FLEET'::character varying, 'MANAGE_DRIVERS'::character varying, 'MANAGE_VENDORS'::character varying, 'MANAGE_BOOKINGS'::character varying, 'MANAGE_BILLING'::character varying, 'VIEW_REPORTS'::character varying, 'MANAGE_CONFIG'::character varying, 'MANAGE_USERS'::character varying])::text[])))
);


--
-- Name: users; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.users (
    id bigint NOT NULL,
    email character varying(255) NOT NULL,
    enabled boolean NOT NULL,
    full_name character varying(255) NOT NULL,
    license_number character varying(255),
    password character varying(255) NOT NULL,
    phone character varying(255),
    role character varying(255) NOT NULL,
    username character varying(50) NOT NULL,
    vendor_id bigint,
    customer_category_id bigint,
    driver_id bigint
);


--
-- Name: users_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

ALTER TABLE public.users ALTER COLUMN id ADD GENERATED BY DEFAULT AS IDENTITY (
    SEQUENCE NAME public.users_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1
);


--
-- Name: vehicle_locations; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.vehicle_locations (
    id bigint NOT NULL,
    heading double precision,
    ignition_on boolean,
    latitude double precision NOT NULL,
    longitude double precision NOT NULL,
    odometer integer,
    speed_kph double precision,
    updated_at timestamp(6) without time zone,
    car_id bigint NOT NULL
);


--
-- Name: vehicle_locations_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

ALTER TABLE public.vehicle_locations ALTER COLUMN id ADD GENERATED BY DEFAULT AS IDENTITY (
    SEQUENCE NAME public.vehicle_locations_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1
);


--
-- Name: vendor_settlements; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.vendor_settlements (
    id bigint NOT NULL,
    commission_amount numeric(38,2),
    driver_charges numeric(38,2),
    generated_at timestamp(6) without time zone NOT NULL,
    gross_revenue numeric(38,2),
    net_payable numeric(38,2),
    period_end date,
    period_start date,
    status character varying(255) NOT NULL,
    trip_count integer NOT NULL,
    vendor_id bigint NOT NULL,
    CONSTRAINT vendor_settlements_status_check CHECK (((status)::text = ANY ((ARRAY['DRAFT'::character varying, 'FINALISED'::character varying, 'PAID'::character varying])::text[])))
);


--
-- Name: vendor_settlements_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

ALTER TABLE public.vendor_settlements ALTER COLUMN id ADD GENERATED BY DEFAULT AS IDENTITY (
    SEQUENCE NAME public.vendor_settlements_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1
);


--
-- Name: vendors; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.vendors (
    id bigint NOT NULL,
    active boolean DEFAULT true NOT NULL,
    address character varying(255),
    commission_percent numeric(38,2),
    contact_person character varying(255),
    email character varying(255),
    gst_number character varying(255),
    name character varying(255) NOT NULL,
    phone character varying(255),
    settlement_details character varying(255)
);


--
-- Name: vendors_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

ALTER TABLE public.vendors ALTER COLUMN id ADD GENERATED BY DEFAULT AS IDENTITY (
    SEQUENCE NAME public.vendors_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1
);


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

COPY public.audit_logs (id, action, created_at, detail, entity_id, entity_type, ip, role, username) FROM stdin;
1	LOGIN_SUCCESS	2026-06-27 15:36:16.178347	\N	\N	Auth	0:0:0:0:0:0:0:1	\N	admin
2	UPDATE	2026-06-27 15:40:15.007566	save	2	Car	0:0:0:0:0:0:0:1	ADMIN	admin
3	UPDATE	2026-06-27 15:40:15.011246	save	2	Maintenance	0:0:0:0:0:0:0:1	ADMIN	admin
4	UPDATE	2026-06-27 15:46:48.419016	save	2	Car	0:0:0:0:0:0:0:1	ADMIN	admin
5	UPDATE	2026-06-27 15:46:48.420726	save	2	Maintenance	0:0:0:0:0:0:0:1	ADMIN	admin
6	LOGIN_SUCCESS	2026-06-27 15:46:50.000951	\N	\N	Auth	0:0:0:0:0:0:0:1	\N	demo
7	CREATE	2026-06-27 15:46:50.06117	addReview	3	Review	0:0:0:0:0:0:0:1	CUSTOMER	demo
8	LOGIN_SUCCESS	2026-06-27 16:08:20.61989	\N	\N	Auth	0:0:0:0:0:0:0:1	\N	admin
9	CREATE	2026-06-27 16:08:45.827638	createStaff	9	User	0:0:0:0:0:0:0:1	ADMIN	admin
10	LOGIN_SUCCESS	2026-06-27 16:09:16.090374	\N	\N	Auth	0:0:0:0:0:0:0:1	\N	staff1
11	CREATE	2026-06-27 16:09:16.212725	createBooking	7	Booking	0:0:0:0:0:0:0:1	ADMIN	admin
12	LOGIN_SUCCESS	2026-06-27 16:12:06.959293	\N	\N	Auth	0:0:0:0:0:0:0:1	\N	admin
13	CREATE	2026-06-27 16:12:07.154034	createBooking	8	Booking	0:0:0:0:0:0:0:1	ADMIN	admin
14	LOGIN_SUCCESS	2026-06-27 16:13:44.912973	\N	\N	Auth	0:0:0:0:0:0:0:1	\N	admin
15	LOGIN_SUCCESS	2026-06-27 16:22:03.724071	\N	\N	Auth	0:0:0:0:0:0:0:1	\N	admin
16	LOGIN_SUCCESS	2026-06-27 16:23:07.054389	\N	\N	Auth	0:0:0:0:0:0:0:1	\N	staff1
17	LOGIN_SUCCESS	2026-06-27 16:23:26.98585	\N	\N	Auth	0:0:0:0:0:0:0:1	\N	vendor1
18	LOGIN_SUCCESS	2026-06-27 16:36:56.585807	\N	\N	Auth	0:0:0:0:0:0:0:1	\N	admin
19	LOGIN_SUCCESS	2026-06-27 16:42:55.037816	\N	\N	Auth	0:0:0:0:0:0:0:1	\N	admin
20	LOGIN_SUCCESS	2026-07-02 17:03:37.847477	\N	\N	Auth	0:0:0:0:0:0:0:1	\N	admin
21	LOGIN_SUCCESS	2026-07-03 09:07:11.350728	\N	\N	Auth	0:0:0:0:0:0:0:1	\N	admin
22	LOGIN_SUCCESS	2026-07-03 09:14:36.728845	\N	\N	Auth	0:0:0:0:0:0:0:1	\N	admin
23	LOGIN_SUCCESS	2026-07-03 09:19:17.254401	\N	\N	Auth	0:0:0:0:0:0:0:1	\N	admin
24	UPDATE	2026-07-03 09:19:17.396479	updateStatus	3	Driver	0:0:0:0:0:0:0:1	ADMIN	admin
25	UPDATE	2026-07-03 09:19:17.424299	updateStatus	3	Driver	0:0:0:0:0:0:0:1	ADMIN	admin
26	LOGIN_SUCCESS	2026-07-03 09:35:49.328363	\N	\N	Auth	0:0:0:0:0:0:0:1	\N	admin
27	CREATE	2026-07-03 09:35:51.243882	createPortalUser	10	Driver	0:0:0:0:0:0:0:1	ADMIN	admin
28	LOGIN_SUCCESS	2026-07-03 09:35:51.350599	\N	\N	Auth	0:0:0:0:0:0:0:1	\N	driver1
29	UPDATE	2026-07-03 09:36:35.12477	updateStatus	3	Driver	0:0:0:0:0:0:0:1	DRIVER	driver1
30	UPDATE	2026-07-03 09:36:35.337063	updateStatus	3	Driver	0:0:0:0:0:0:0:1	DRIVER	driver1
31	LOGIN_SUCCESS	2026-07-03 10:32:31.915052	\N	\N	Auth	0:0:0:0:0:0:0:1	\N	admin
32	LOGIN_SUCCESS	2026-07-03 10:35:37.499045	\N	\N	Auth	0:0:0:0:0:0:0:1	\N	admin
33	LOGIN_FAILURE	2026-07-03 10:38:26.242989	\N	\N	Auth	0:0:0:0:0:0:0:1	\N	driver1
34	LOGIN_SUCCESS	2026-07-03 10:38:50.795708	\N	\N	Auth	0:0:0:0:0:0:0:1	\N	driver1
35	LOGIN_SUCCESS	2026-07-03 10:39:26.956775	\N	\N	Auth	0:0:0:0:0:0:0:1	\N	driver1
\.


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

COPY public.bookings (id, created_at, drop_location, pickup_date, pickup_location, return_date, status, total_amount, car_id, user_id, driver_id, commission_amount, commission_percent, driver_charge, rental_unit, revenue_owner, tax_amount, tax_percent, vehicle_charge, vendor_id, with_driver, quantity) FROM stdin;
1	2026-06-26 16:07:35.833255	Kochi	2026-08-01	Kochi	2026-08-03	PENDING	4400.00	1	2	\N	\N	\N	\N	DAY	\N	\N	\N	\N	\N	f	1
2	2026-06-26 16:15:49.397764	Kochi	2026-09-01	Kochi	2026-09-04	PENDING	12600.00	2	2	\N	0.00	0.00	0.00	DAY	OWNED	2100.00	20.00	10500.00	\N	f	3
3	2026-06-26 16:15:49.579068	Kochi	2026-10-01	Kochi	2026-10-03	PENDING	10320.00	2	2	1	0.00	0.00	1600.00	DAY	OWNED	1720.00	20.00	7000.00	\N	t	2
4	2026-06-26 16:29:10.689776	Kochi	2026-11-05	Kochi	2026-11-08	COMPLETED	7920.00	1	2	\N	792.00	12.00	0.00	DAY	VENDOR	1320.00	20.00	6600.00	1	f	3
5	2026-06-27 15:00:13.490606	Kochi	2026-07-10	Kochi	2026-07-13	PENDING	12600.00	2	7	\N	0.00	0.00	0.00	DAY	OWNED	2100.00	20.00	10500.00	\N	f	3
6	2026-06-27 15:00:13.663696	Wayanad	2026-08-01	Calicut	2026-08-04	PENDING	15480.00	2	8	1	0.00	0.00	2400.00	DAY	OWNED	2580.00	20.00	10500.00	\N	t	3
7	2026-06-27 16:09:16.200651	Kochi	2026-09-10	Kochi	2026-09-12	PENDING	7680.00	3	7	\N	0.00	0.00	0.00	DAY	OWNED	1280.00	20.00	6400.00	\N	f	2
8	2026-06-27 16:12:07.140903	Kochi	2026-10-10	Kochi	2026-10-12	PENDING	7680.00	3	7	\N	0.00	0.00	0.00	DAY	OWNED	1280.00	20.00	6400.00	\N	f	2
\.


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

COPY public.car_documents (id, doc_type, expiry_date, file_url, issued_date, car_id) FROM stdin;
1	INSURANCE	2026-07-06	/docs/ins.pdf	\N	7
3	RC	2027-06-30	/uploads/7850af44-955e-4505-b0ab-9f85402bed1f.pdf	\N	2
\.


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

COPY public.car_feature_tags (car_id, tag) FROM stdin;
2	AC
2	Bluetooth
2	GPS
3	AC
3	Spacious
4	AC
4	Bluetooth
4	GPS
5	AC
6	AC
6	Bluetooth
6	GPS
7	AC
1	AC
1	Bluetooth
1	GPS
\.


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

COPY public.car_photos (id, sort_order, url, car_id) FROM stdin;
1	1	/images/bmwx3.png	7
3	0	/images/bmwx3.png	2
\.


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

COPY public.cars (id, available, fuel_type, image_url, make, model, price_per_day, registration_number, seats, transmission, type, colour, hourly_rate, monthly_rate, ownership, status, units_total, year_of_registration, commission_percent_override, vendor_id) FROM stdin;
3	t	PETROL	/images/hector.png	MG	Hector	3200.00	KL07AA1003	7	AUTOMATIC	SUV	\N	\N	\N	OWNED	ACTIVE	1	\N	\N	\N
4	t	PETROL	/images/bmwx3.png	BMW	X3	8500.00	KL07AA1004	5	AUTOMATIC	LUXURY	\N	\N	\N	OWNED	ACTIVE	1	\N	\N	\N
5	t	PETROL	/images/bike.png	Royal Enfield	Classic 350	800.00	KL07AA1005	2	MANUAL	BIKE	\N	\N	\N	OWNED	ACTIVE	1	\N	\N	\N
6	t	PETROL	/images/car.png	Maruti	Swift	1500.00	KL07AA1006	5	MANUAL	HATCHBACK	\N	\N	\N	OWNED	ACTIVE	1	\N	\N	\N
7	t	\N	\N	Tesla	Model 3	4500.00	KL-99-EV-0001	5	\N	SEDAN	\N	\N	\N	OWNED	MAINTENANCE	2	\N	\N	\N
1	t	PETROL	/images/virtus.png	Volkswagen	Virtus	2200.00	KL07AA1001	5	MANUAL	SEDAN	\N	\N	\N	VENDOR	ACTIVE	1	\N	\N	1
2	t	DIESEL	/images/thar.png	Mahindra	Thar	3500.00	KL07AA1002	4	MANUAL	SUV	\N	\N	\N	OWNED	ACTIVE	1	\N	\N	\N
\.


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

COPY public.categories (id, active, description, name, type) FROM stdin;
1	t	\N	Hatchback	VEHICLE
2	t	\N	Sedan	VEHICLE
3	t	\N	SUV	VEHICLE
4	t	\N	MUV	VEHICLE
5	t	\N	Luxury	VEHICLE
7	t	\N	Standard	DRIVER
8	t	\N	Premium	DRIVER
9	t	\N	Chauffeur	DRIVER
10	t	\N	Individual	CUSTOMER
11	t	\N	Company	CUSTOMER
12	t	\N	Corporate	CUSTOMER
13	t	\N	Convertible	VEHICLE
6	t	\N	Bike	VEHICLE
\.


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

COPY public.driver_documents (id, doc_type, expiry_date, file_url, issued_date, driver_id) FROM stdin;
2	LICENCE	2028-01-01	/uploads/1d098844-4bf8-42dd-a1f9-81774ecc8cd1.pdf	\N	1
4	LICENCE	\N	/uploads/547f9315-f272-4bc2-88af-f5e22797fc5e.pdf	\N	3
\.


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

COPY public.drivers (id, daily_charge, employment_type, hourly_charge, licence_expiry, licence_number, monthly_charge, name, phone, photo_url, status, years_experience, category_id, vendor_id) FROM stdin;
1	800.00	EMPLOYED	\N	2028-06-26	KL07-2018-0012345	\N	Rajesh Kumar	+91 9847012345	\N	AVAILABLE	6	7	\N
2	1200.00	VENDOR	\N	2027-06-26	KL01-2015-0098765	\N	Suresh Nair	+91 9847098765	\N	AVAILABLE	11	8	1
3	1500.00	EMPLOYED	\N	2029-01-06	KL05-2020-0055555	\N	Anil Joseph	9876562345	/uploads/d327034b-1819-464d-bcbe-4f96a34e0022.png	AVAILABLE	4	7	\N
\.


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

COPY public.inspection_records (id, condition, created_at, damage_notes, fuel_level, inspection_date, inspector, odometer, photo_url, type, booking_id, car_id) FROM stdin;
\.


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

COPY public.invoices (id, invoice_number, issued_at, subtotal, tax_amount, total, booking_id) FROM stdin;
1	INV-00002	2026-06-26 16:15:49.416851	10500.00	2100.00	12600.00	2
2	INV-00003	2026-06-26 16:15:49.580328	8600.00	1720.00	10320.00	3
3	INV-00004	2026-06-26 16:29:10.705891	6600.00	1320.00	7920.00	4
4	INV-00005	2026-06-27 15:00:13.544753	10500.00	2100.00	12600.00	5
5	INV-00006	2026-06-27 15:00:13.664738	12900.00	2580.00	15480.00	6
6	INV-00007	2026-06-27 16:09:16.206627	6400.00	1280.00	7680.00	7
7	INV-00008	2026-06-27 16:12:07.14763	6400.00	1280.00	7680.00	8
\.


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

COPY public.maintenance_records (id, cost, created_at, garage, next_service_date, next_service_odometer, notes, odometer, service_date, status, type, car_id) FROM stdin;
1	4800.00	2026-06-27 15:32:22.220144	AutoCare Kochi	2026-10-27	46500	Engine oil, filter, brake pads	36500	2026-04-27	COMPLETED	SERVICE	2
2	\N	2026-06-27 15:40:15.001632	\N	\N	\N	\N	\N	2026-06-27	COMPLETED	REPAIR	2
\.


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

COPY public.organization (id, address, contact_email, currency_code, gst_number, legal_name, logo_url, name, phone) FROM stdin;
1	\N	\N	INR	\N	\N	\N	MV Rent	\N
\.


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

COPY public.payments (id, amount, created_at, method, notes, paid_at, recorded_by, reference, booking_id) FROM stdin;
1	1000.00	2026-06-27 16:08:45.911914	UPI	\N	2026-06-27	admin	UPI-TEST-1	1
\.


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

COPY public.reviews (id, approved, comment, created_at, rating, booking_id, car_id, user_id) FROM stdin;
1	t	Spotless car and a smooth booking experience. Highly recommend!	2026-06-27 15:32:22.226167	5	\N	2	2
2	t	Great value for money. Pickup was quick.	2026-06-27 15:32:22.229143	4	\N	2	2
3	t	Tested via API - excellent!	2026-06-27 15:46:50.059737	5	\N	2	2
\.


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

COPY public.system_config (id, currency_code, default_commission_percent, default_driver_daily_charge, default_tax_percent, invoice_prefix, settlement_cycle) FROM stdin;
1	INR	15.00	800.00	20.00	INV	MONTHLY
\.


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

COPY public.user_permissions (user_id, permission) FROM stdin;
1	MANAGE_USERS
1	VIEW_REPORTS
1	MANAGE_VENDORS
1	MANAGE_FLEET
1	MANAGE_BOOKINGS
1	MANAGE_BILLING
1	MANAGE_DRIVERS
1	MANAGE_CONFIG
9	MANAGE_FLEET
9	MANAGE_BOOKINGS
\.


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

COPY public.users (id, email, enabled, full_name, license_number, password, phone, role, username, vendor_id, customer_category_id, driver_id) FROM stdin;
5	vendor1@evmwheels.local	t	Kerala Cabs (Vendor)	\N	$2a$10$XrJ14wd5DejnjowxQRAd/.twJfFcHYFtGGPMqGXg8ld0WnNxbmdli	\N	VENDOR	vendor1	1	\N	\N
6	v1b@evmwheels.local	t	Kerala Cabs (Vendor)	\N	$2a$10$QUmUt4ben/OZAZkfYgyVN.S/yPuTsfxzxfpgiXnn6xWGaEQkdp.V2	\N	VENDOR	vendor1b	1	\N	\N
2	demo@evmwheels.local	t	Demo Customer	\N	$2a$10$Tnkt18J40FaI/eccELPWE.wcer0pL2xoqLqBSp2N.B6mGSlQopS0O	\N	CUSTOMER	demo	\N	10	\N
7	acme2@test.com	t	Acme Corp	\N	$2a$10$dMv6PgInTGuAoawwRW7J9OFSXXETIT1hV2QhsxWvD4jcwOlv3Tlxa	\N	CUSTOMER	acme2	\N	11	\N
1	admin@evmwheels.local	t	EVM Admin	\N	$2a$10$ToT.ACMiefUqo1Qzo1aqO.bpYXEAtUiZkahRccL9xMmDVR1Zt9lri	\N	ADMIN	admin	\N	\N	\N
8	counterguest@walkin.local	t	Counter Guest	\N	$2a$10$Y/I5EOYecBc6grAYargC2ejsXvnHX9qTVDbRJShy/m/7dJwmdB9Ly	9876500000	CUSTOMER	counterguest	\N	\N	\N
9	priya@evmwheels.local	t	Priya Staff	\N	$2a$10$1ZR6RVnMjgM6jXZK5xaAm.3s6sldh30vxj3THNsk9f6JSZBbvqc5W	\N	STAFF	staff1	\N	\N	\N
10	driver1@mvrent.local	t	Anil Joseph	\N	$2a$10$WzxLal6ubyQUgixnKyA/7uVB19C4G4XD9GeVrv49jBNvjNTmdF6Re	9876562345	DRIVER	driver1	\N	\N	3
\.


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

COPY public.vehicle_locations (id, heading, ignition_on, latitude, longitude, odometer, speed_kph, updated_at, car_id) FROM stdin;
2	90	t	8.5241	76.9366	43200	42	2026-06-27 15:31:22.21293	3
3	180	f	11.2588	75.7804	48400	0	2026-06-27 15:30:22.213693	4
4	270	t	10.5276	76.2144	53600	42	2026-06-27 15:29:22.214259	5
5	360	f	9.5916	76.5222	58800	0	2026-06-27 15:28:22.214754	6
1	120	t	10	76.3	41000	55.5	2026-06-27 15:40:14.968041	2
\.


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

COPY public.vendor_settlements (id, commission_amount, driver_charges, generated_at, gross_revenue, net_payable, period_end, period_start, status, trip_count, vendor_id) FROM stdin;
1	792.00	0.00	2026-06-26 16:29:11.019085	6600.00	5808.00	2026-11-30	2026-11-01	DRAFT	1	1
\.


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

COPY public.vendors (id, active, address, commission_percent, contact_person, email, gst_number, name, phone, settlement_details) FROM stdin;
1	t	\N	12.00	Joby Thomas	ops@keralacabs.local	32ABCDE1234F1Z5	Kerala Cabs	+91 9847000000	A/C 00112233, IFSC SBIN0001234
\.


--
-- Name: audit_logs_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.audit_logs_id_seq', 35, true);


--
-- Name: bookings_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.bookings_id_seq', 8, true);


--
-- Name: car_documents_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.car_documents_id_seq', 3, true);


--
-- Name: car_photos_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.car_photos_id_seq', 3, true);


--
-- Name: cars_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.cars_id_seq', 8, true);


--
-- Name: categories_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.categories_id_seq', 14, true);


--
-- Name: driver_documents_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.driver_documents_id_seq', 4, true);


--
-- Name: drivers_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.drivers_id_seq', 4, true);


--
-- Name: inspection_records_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.inspection_records_id_seq', 1, false);


--
-- Name: invoices_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.invoices_id_seq', 7, true);


--
-- Name: maintenance_records_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.maintenance_records_id_seq', 2, true);


--
-- Name: organization_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.organization_id_seq', 1, true);


--
-- Name: payments_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.payments_id_seq', 1, true);


--
-- Name: reviews_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.reviews_id_seq', 3, true);


--
-- Name: system_config_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.system_config_id_seq', 1, true);


--
-- Name: users_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.users_id_seq', 10, true);


--
-- Name: vehicle_locations_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.vehicle_locations_id_seq', 5, true);


--
-- Name: vendor_settlements_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.vendor_settlements_id_seq', 1, true);


--
-- Name: vendors_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.vendors_id_seq', 2, true);


--
-- Name: audit_logs audit_logs_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.audit_logs
    ADD CONSTRAINT audit_logs_pkey PRIMARY KEY (id);


--
-- Name: bookings bookings_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.bookings
    ADD CONSTRAINT bookings_pkey PRIMARY KEY (id);


--
-- Name: car_documents car_documents_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.car_documents
    ADD CONSTRAINT car_documents_pkey PRIMARY KEY (id);


--
-- Name: car_photos car_photos_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.car_photos
    ADD CONSTRAINT car_photos_pkey PRIMARY KEY (id);


--
-- Name: cars cars_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.cars
    ADD CONSTRAINT cars_pkey PRIMARY KEY (id);


--
-- Name: categories categories_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.categories
    ADD CONSTRAINT categories_pkey PRIMARY KEY (id);


--
-- Name: driver_documents driver_documents_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.driver_documents
    ADD CONSTRAINT driver_documents_pkey PRIMARY KEY (id);


--
-- Name: drivers drivers_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.drivers
    ADD CONSTRAINT drivers_pkey PRIMARY KEY (id);


--
-- Name: inspection_records inspection_records_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.inspection_records
    ADD CONSTRAINT inspection_records_pkey PRIMARY KEY (id);


--
-- Name: invoices invoices_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.invoices
    ADD CONSTRAINT invoices_pkey PRIMARY KEY (id);


--
-- Name: maintenance_records maintenance_records_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.maintenance_records
    ADD CONSTRAINT maintenance_records_pkey PRIMARY KEY (id);


--
-- Name: organization organization_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.organization
    ADD CONSTRAINT organization_pkey PRIMARY KEY (id);


--
-- Name: payments payments_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

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


--
-- Name: reviews reviews_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.reviews
    ADD CONSTRAINT reviews_pkey PRIMARY KEY (id);


--
-- Name: system_config system_config_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.system_config
    ADD CONSTRAINT system_config_pkey PRIMARY KEY (id);


--
-- Name: categories uk17k21odm3kbnriiikewhatvlm; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.categories
    ADD CONSTRAINT uk17k21odm3kbnriiikewhatvlm UNIQUE (type, name);


--
-- Name: drivers uk5v2gvq951rwadgpkg6wcr8ue9; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.drivers
    ADD CONSTRAINT uk5v2gvq951rwadgpkg6wcr8ue9 UNIQUE (licence_number);


--
-- Name: users uk6dotkott2kjsp8vw4d0m25fb7; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.users
    ADD CONSTRAINT uk6dotkott2kjsp8vw4d0m25fb7 UNIQUE (email);


--
-- Name: cars uki3ldfyekqw49cw6omv99rrfkx; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.cars
    ADD CONSTRAINT uki3ldfyekqw49cw6omv99rrfkx UNIQUE (registration_number);


--
-- Name: vehicle_locations ukke1m6iutu0pt6jorg1jr4ejx2; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.vehicle_locations
    ADD CONSTRAINT ukke1m6iutu0pt6jorg1jr4ejx2 UNIQUE (car_id);


--
-- Name: invoices ukl1x55mfsay7co0r3m9ynvipd5; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.invoices
    ADD CONSTRAINT ukl1x55mfsay7co0r3m9ynvipd5 UNIQUE (invoice_number);


--
-- Name: invoices ukqn380ix1ge287r0rd8th12bwi; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.invoices
    ADD CONSTRAINT ukqn380ix1ge287r0rd8th12bwi UNIQUE (booking_id);


--
-- Name: users ukr43af9ap4edm43mmtq01oddj6; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.users
    ADD CONSTRAINT ukr43af9ap4edm43mmtq01oddj6 UNIQUE (username);


--
-- Name: users users_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.users
    ADD CONSTRAINT users_pkey PRIMARY KEY (id);


--
-- Name: vehicle_locations vehicle_locations_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.vehicle_locations
    ADD CONSTRAINT vehicle_locations_pkey PRIMARY KEY (id);


--
-- Name: vendor_settlements vendor_settlements_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.vendor_settlements
    ADD CONSTRAINT vendor_settlements_pkey PRIMARY KEY (id);


--
-- Name: vendors vendors_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.vendors
    ADD CONSTRAINT vendors_pkey PRIMARY KEY (id);


--
-- Name: idx_audit_created; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_audit_created ON public.audit_logs USING btree (created_at);


--
-- Name: idx_audit_username; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_audit_username ON public.audit_logs USING btree (username);


--
-- Name: reviews fk28an517hrxtt2bsg93uefugrm; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.reviews
    ADD CONSTRAINT fk28an517hrxtt2bsg93uefugrm FOREIGN KEY (booking_id) REFERENCES public.bookings(id);


--
-- Name: driver_documents fk4cqh5sfs29eeky0q37t2x78vq; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.driver_documents
    ADD CONSTRAINT fk4cqh5sfs29eeky0q37t2x78vq FOREIGN KEY (driver_id) REFERENCES public.drivers(id);


--
-- Name: car_feature_tags fk6js0s623ar2p4tjoa6ank1lm2; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.car_feature_tags
    ADD CONSTRAINT fk6js0s623ar2p4tjoa6ank1lm2 FOREIGN KEY (car_id) REFERENCES public.cars(id);


--
-- Name: cars fk6lq0lg9o4o6c4weriter6574f; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.cars
    ADD CONSTRAINT fk6lq0lg9o4o6c4weriter6574f FOREIGN KEY (vendor_id) REFERENCES public.vendors(id);


--
-- Name: inspection_records fk753d5fiil3olhyi5t0sbpn8eh; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.inspection_records
    ADD CONSTRAINT fk753d5fiil3olhyi5t0sbpn8eh FOREIGN KEY (booking_id) REFERENCES public.bookings(id);


--
-- Name: car_photos fk75ncp53p4jb47tewrlvtwmh41; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.car_photos
    ADD CONSTRAINT fk75ncp53p4jb47tewrlvtwmh41 FOREIGN KEY (car_id) REFERENCES public.cars(id);


--
-- Name: maintenance_records fka4dsfs77eje856jth3peepq16; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.maintenance_records
    ADD CONSTRAINT fka4dsfs77eje856jth3peepq16 FOREIGN KEY (car_id) REFERENCES public.cars(id);


--
-- Name: invoices fkb9bhb7xre5v64qvjeholh3qj0; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.invoices
    ADD CONSTRAINT fkb9bhb7xre5v64qvjeholh3qj0 FOREIGN KEY (booking_id) REFERENCES public.bookings(id);


--
-- Name: payments fkc52o2b1jkxttngufqp3t7jr3h; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.payments
    ADD CONSTRAINT fkc52o2b1jkxttngufqp3t7jr3h FOREIGN KEY (booking_id) REFERENCES public.bookings(id);


--
-- Name: reviews fkcgy7qjc1r99dp117y9en6lxye; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.reviews
    ADD CONSTRAINT fkcgy7qjc1r99dp117y9en6lxye FOREIGN KEY (user_id) REFERENCES public.users(id);


--
-- Name: drivers fkdgi05p3479yd57btyrgmp4mle; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.drivers
    ADD CONSTRAINT fkdgi05p3479yd57btyrgmp4mle FOREIGN KEY (category_id) REFERENCES public.categories(id);


--
-- Name: bookings fkeyog2oic85xg7hsu2je2lx3s6; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.bookings
    ADD CONSTRAINT fkeyog2oic85xg7hsu2je2lx3s6 FOREIGN KEY (user_id) REFERENCES public.users(id);


--
-- Name: inspection_records fkhla1wpktqjsujkg3ihm79iaxh; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.inspection_records
    ADD CONSTRAINT fkhla1wpktqjsujkg3ihm79iaxh FOREIGN KEY (car_id) REFERENCES public.cars(id);


--
-- Name: reviews fkieeb3p5v84i1xja7nbj1vkkeg; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.reviews
    ADD CONSTRAINT fkieeb3p5v84i1xja7nbj1vkkeg FOREIGN KEY (car_id) REFERENCES public.cars(id);


--
-- Name: bookings fkj0bxwbe92tfc6xwp7pdffo3pq; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.bookings
    ADD CONSTRAINT fkj0bxwbe92tfc6xwp7pdffo3pq FOREIGN KEY (driver_id) REFERENCES public.drivers(id);


--
-- Name: bookings fkj1y19nc7wf0rdp24pyhomn7ck; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.bookings
    ADD CONSTRAINT fkj1y19nc7wf0rdp24pyhomn7ck FOREIGN KEY (car_id) REFERENCES public.cars(id);


--
-- Name: car_documents fkjr1xvrrs96ey2efq4jww071bh; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.car_documents
    ADD CONSTRAINT fkjr1xvrrs96ey2efq4jww071bh FOREIGN KEY (car_id) REFERENCES public.cars(id);


--
-- Name: vehicle_locations fkkgfol016f9hl7pt1nphs5yrsn; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.vehicle_locations
    ADD CONSTRAINT fkkgfol016f9hl7pt1nphs5yrsn FOREIGN KEY (car_id) REFERENCES public.cars(id);


--
-- Name: user_permissions fkkowxl8b2bngrxd1gafh13005u; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.user_permissions
    ADD CONSTRAINT fkkowxl8b2bngrxd1gafh13005u FOREIGN KEY (user_id) REFERENCES public.users(id);


--
-- Name: users fkl4l7wq0lyhhq2pje8wro9gfh9; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.users
    ADD CONSTRAINT fkl4l7wq0lyhhq2pje8wro9gfh9 FOREIGN KEY (customer_category_id) REFERENCES public.categories(id);


--
-- Name: drivers fko2ld66drmgv084wws15u6hqor; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.drivers
    ADD CONSTRAINT fko2ld66drmgv084wws15u6hqor FOREIGN KEY (vendor_id) REFERENCES public.vendors(id);


--
-- Name: users fkp3aufrqlptl7jn77avemkbpxr; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.users
    ADD CONSTRAINT fkp3aufrqlptl7jn77avemkbpxr FOREIGN KEY (vendor_id) REFERENCES public.vendors(id);


--
-- Name: users fkrq6el5qawr0fnqofn8yjmqr0i; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.users
    ADD CONSTRAINT fkrq6el5qawr0fnqofn8yjmqr0i FOREIGN KEY (driver_id) REFERENCES public.drivers(id);


--
-- Name: bookings fkstpgklh4a1lexve7b5qn8ebwp; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.bookings
    ADD CONSTRAINT fkstpgklh4a1lexve7b5qn8ebwp FOREIGN KEY (vendor_id) REFERENCES public.vendors(id);


--
-- Name: vendor_settlements fkt7l1kk79o5lc6uod8jv910mnf; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.vendor_settlements
    ADD CONSTRAINT fkt7l1kk79o5lc6uod8jv910mnf FOREIGN KEY (vendor_id) REFERENCES public.vendors(id);


--
-- PostgreSQL database dump complete
--

\unrestrict rJe1Gy5GMPzawpaJZiQmUDxD6gCxnwjfhMGsGM8QvA0b3acVAPjT7ftg1eemfem

