-- Database Structure Dump
-- Generated by dump_full_schema.php
-- Date: 2026-01-28 13:13:41

-- Table: public.admins
CREATE TABLE public.admins (
    id BIGINT NOT NULL DEFAULT nextval('admins_id_seq'::regclass),
    user_table_id BIGINT NOT NULL,
    isactive BOOLEAN NOT NULL DEFAULT true,
    created_at TIMESTAMP WITHOUT TIME ZONE,
    updated_at TIMESTAMP WITHOUT TIME ZONE,
    PRIMARY KEY (id)
);

-- Table: public.businesses
CREATE TABLE public.businesses (
    id BIGINT NOT NULL DEFAULT nextval('businesses_id_seq'::regclass),
    created_at TIMESTAMP WITHOUT TIME ZONE,
    updated_at TIMESTAMP WITHOUT TIME ZONE,
    PRIMARY KEY (id)
);

-- Table: public.bux_amount_histories
CREATE TABLE public.bux_amount_histories (
    id BIGINT NOT NULL DEFAULT nextval('bux_amount_histories_id_seq'::regclass),
    old_amount NUMERIC,
    new_amount NUMERIC NOT NULL,
    changed_by BIGINT,
    reason CHARACTER VARYING(255),
    created_at TIMESTAMP WITHOUT TIME ZONE,
    updated_at TIMESTAMP WITHOUT TIME ZONE,
    added_amount NUMERIC,
    PRIMARY KEY (id)
);

-- Table: public.bux_calculator_settings
CREATE TABLE public.bux_calculator_settings (
    id BIGINT NOT NULL DEFAULT nextval('bux_calculator_settings_id_seq'::regclass),
    premium_merchants JSON NOT NULL DEFAULT '[0,0]'::json,
    economy_merchants JSON NOT NULL DEFAULT '[0,0]'::json,
    free_merchants JSON NOT NULL DEFAULT '[0,0]'::json,
    created_at TIMESTAMP WITHOUT TIME ZONE,
    updated_at TIMESTAMP WITHOUT TIME ZONE,
    PRIMARY KEY (id)
);

-- Table: public.categories
CREATE TABLE public.categories (
    id BIGINT NOT NULL DEFAULT nextval('categories_id_seq'::regclass),
    name CHARACTER VARYING(255) NOT NULL,
    description TEXT,
    slug CHARACTER VARYING(255) NOT NULL,
    is_active BOOLEAN NOT NULL DEFAULT true,
    created_at TIMESTAMP WITHOUT TIME ZONE,
    updated_at TIMESTAMP WITHOUT TIME ZONE,
    required_documents JSON,
    bux_value NUMERIC NOT NULL DEFAULT 0,
    icon_url CHARACTER VARYING(255),
    icon_s3_key CHARACTER VARYING(255),
    icon_original_filename CHARACTER VARYING(255),
    icon_file_size INTEGER,
    icon_mime_type CHARACTER VARYING(255),
    image_url TEXT,
    PRIMARY KEY (id)
);

-- Table: public.category_images
CREATE TABLE public.category_images (
    id BIGINT NOT NULL DEFAULT nextval('category_images_id_seq'::regclass),
    category_id BIGINT NOT NULL,
    image_url CHARACTER VARYING(255) NOT NULL,
    s3_key CHARACTER VARYING(255) NOT NULL,
    original_filename CHARACTER VARYING(255) NOT NULL,
    file_size INTEGER,
    mime_type CHARACTER VARYING(255),
    usage_count INTEGER NOT NULL DEFAULT 0,
    is_active BOOLEAN NOT NULL DEFAULT true,
    created_at TIMESTAMP WITHOUT TIME ZONE,
    updated_at TIMESTAMP WITHOUT TIME ZONE,
    PRIMARY KEY (id)
);

-- Table: public.ci_sessions
CREATE TABLE public.ci_sessions (
    id CHARACTER VARYING(128) NOT NULL,
    ip_address CHARACTER VARYING(45),
    timestamp BIGINT NOT NULL DEFAULT 0,
    data TEXT NOT NULL,
    PRIMARY KEY (id)
);

-- Table: public.cities
CREATE TABLE public.cities (
    id UUID NOT NULL DEFAULT gen_random_uuid(),
    name CHARACTER VARYING(255) NOT NULL,
    created_at TIMESTAMP WITH TIME ZONE DEFAULT now(),
    PRIMARY KEY (id)
);

-- Table: public.customers
CREATE TABLE public.customers (
    id BIGINT NOT NULL DEFAULT nextval('customers_id_seq'::regclass),
    user_table_id BIGINT NOT NULL,
    fullname CHARACTER VARYING(255) NOT NULL,
    dateofbirth DATE,
    address TEXT,
    current_plan CHARACTER VARYING(255),
    plan_activated_at TIMESTAMP WITHOUT TIME ZONE,
    isactive BOOLEAN NOT NULL DEFAULT true,
    created_at TIMESTAMP WITHOUT TIME ZONE,
    updated_at TIMESTAMP WITHOUT TIME ZONE,
    PRIMARY KEY (id)
);

-- Table: public.global_settings
CREATE TABLE public.global_settings (
    id BIGINT NOT NULL DEFAULT nextval('global_settings_id_seq'::regclass),
    key CHARACTER VARYING(255) NOT NULL,
    value TEXT,
    created_at TIMESTAMP WITHOUT TIME ZONE,
    updated_at TIMESTAMP WITHOUT TIME ZONE,
    PRIMARY KEY (id)
);

-- Table: public.industries
CREATE TABLE public.industries (
    id BIGINT NOT NULL DEFAULT nextval('industries_id_seq'::regclass),
    name CHARACTER VARYING(255) NOT NULL,
    description TEXT,
    slug CHARACTER VARYING(255) NOT NULL,
    is_active BOOLEAN NOT NULL DEFAULT true,
    created_at TIMESTAMP WITHOUT TIME ZONE,
    updated_at TIMESTAMP WITHOUT TIME ZONE,
    PRIMARY KEY (id)
);

-- Table: public.merchant_banners
CREATE TABLE public.merchant_banners (
    id UUID NOT NULL DEFAULT gen_random_uuid(),
    merchant_id INTEGER,
    banner_title CHARACTER VARYING(255),
    image_url TEXT NOT NULL,
    link_url TEXT,
    sort_order INTEGER DEFAULT 0,
    created_at TIMESTAMP WITHOUT TIME ZONE DEFAULT CURRENT_TIMESTAMP,
    updated_at TIMESTAMP WITHOUT TIME ZONE DEFAULT CURRENT_TIMESTAMP,
    PRIMARY KEY (id)
);

-- Table: public.merchant_bin
CREATE TABLE public.merchant_bin (
    id BIGINT NOT NULL DEFAULT nextval('merchant_bin_id_seq'::regclass),
    merchant_name CHARACTER VARYING(255) NOT NULL,
    email CHARACTER VARYING(255) NOT NULL,
    phone CHARACTER VARYING(255) NOT NULL,
    action CHARACTER VARYING(255) NOT NULL,
    reason TEXT,
    original_data JSON,
    deleted_at TIMESTAMP WITHOUT TIME ZONE NOT NULL,
    created_at TIMESTAMP WITHOUT TIME ZONE,
    updated_at TIMESTAMP WITHOUT TIME ZONE,
    PRIMARY KEY (id)
);

-- Table: public.merchant_category
CREATE TABLE public.merchant_category (
    id UUID NOT NULL,
    merchant_id BIGINT NOT NULL,
    category_id BIGINT NOT NULL,
    is_primary BOOLEAN DEFAULT false,
    created_at TIMESTAMP WITHOUT TIME ZONE DEFAULT now(),
    updated_at TIMESTAMP WITHOUT TIME ZONE DEFAULT now(),
    PRIMARY KEY (id)
);

-- Table: public.merchant_category_assets
CREATE TABLE public.merchant_category_assets (
    id BIGINT NOT NULL DEFAULT nextval('merchant_category_assets_id_seq'::regclass),
    merchant_id BIGINT NOT NULL,
    category_id BIGINT NOT NULL,
    logo CHARACTER VARYING(255),
    gallery_images JSON,
    created_at TIMESTAMP WITHOUT TIME ZONE,
    updated_at TIMESTAMP WITHOUT TIME ZONE,
    PRIMARY KEY (id)
);

-- Table: public.merchant_documents
CREATE TABLE public.merchant_documents (
    id INTEGER NOT NULL DEFAULT nextval('merchant_documents_id_seq'::regclass),
    merchant_id INTEGER NOT NULL,
    document_name CHARACTER VARYING(100) NOT NULL,
    field_value TEXT,
    file_url CHARACTER VARYING(255),
    status CHARACTER VARYING(20) NOT NULL DEFAULT 'pending'::character varying,
    comment TEXT,
    created_at TIMESTAMP WITHOUT TIME ZONE,
    updated_at TIMESTAMP WITHOUT TIME ZONE,
    PRIMARY KEY (id)
);

-- Table: public.merchant_gallery
CREATE TABLE public.merchant_gallery (
    id UUID NOT NULL DEFAULT gen_random_uuid(),
    merchant_id INTEGER NOT NULL,
    image_url TEXT NOT NULL,
    display_order INTEGER DEFAULT 0,
    created_at TIMESTAMP WITHOUT TIME ZONE DEFAULT CURRENT_TIMESTAMP,
    updated_at TIMESTAMP WITHOUT TIME ZONE DEFAULT CURRENT_TIMESTAMP,
    PRIMARY KEY (id)
);

-- Table: public.merchants
CREATE TABLE public.merchants (
    id BIGINT NOT NULL DEFAULT nextval('merchants_id_seq'::regclass),
    user_table_id BIGINT NOT NULL,
    merchant_name CHARACTER VARYING(255) NOT NULL,
    location CHARACTER VARYING(255),
    address TEXT,
    plan_activated_at TIMESTAMP WITHOUT TIME ZONE,
    isactive BOOLEAN NOT NULL DEFAULT true,
    is_approved BOOLEAN NOT NULL DEFAULT false,
    created_at TIMESTAMP WITHOUT TIME ZONE,
    updated_at TIMESTAMP WITHOUT TIME ZONE,
    plan_id BIGINT,
    referral_code CHARACTER VARYING(50),
    description TEXT,
    contact_person_name CHARACTER VARYING(255),
    contact_email CHARACTER VARYING(255),
    contact_phone CHARACTER VARYING(255),
    website CHARACTER VARYING(255),
    place_id CHARACTER VARYING(255),
    formatted_address TEXT,
    latitude NUMERIC,
    longitude NUMERIC,
    is_rejected BOOLEAN NOT NULL DEFAULT false,
    image_url TEXT,
    city CHARACTER VARYING(255),
    documents JSONB,
    category_id INTEGER,
    is_mon_open BOOLEAN DEFAULT false,
    is_tue_open BOOLEAN DEFAULT false,
    is_wed_open BOOLEAN DEFAULT false,
    is_thu_open BOOLEAN DEFAULT false,
    is_fri_open BOOLEAN DEFAULT false,
    is_sat_open BOOLEAN DEFAULT false,
    is_sun_open BOOLEAN DEFAULT false,
    opening_time CHARACTER VARYING(30),
    closing_time CHARACTER VARYING(30),
    verification_status CHARACTER VARYING(20) DEFAULT 'not_submitted'::character varying,
    PRIMARY KEY (id)
);

-- Table: public.migrations
CREATE TABLE public.migrations (
    id INTEGER NOT NULL DEFAULT nextval('migrations_id_seq'::regclass),
    version CHARACTER VARYING(255) NOT NULL,
    batch INTEGER NOT NULL,
    namespace CHARACTER VARYING(255) DEFAULT 'App'::character varying,
    class CHARACTER VARYING(255) NOT NULL DEFAULT ''::character varying,
    group CHARACTER VARYING(255) NOT NULL DEFAULT 'default'::character varying,
    time INTEGER NOT NULL DEFAULT (EXTRACT(epoch FROM CURRENT_TIMESTAMP))::integer,
    PRIMARY KEY (id)
);

-- Table: public.oauth_access_tokens
CREATE TABLE public.oauth_access_tokens (
    id CHARACTER VARYING(100) NOT NULL,
    user_id BIGINT,
    client_id UUID NOT NULL,
    name CHARACTER VARYING(255),
    scopes TEXT,
    revoked BOOLEAN NOT NULL,
    created_at TIMESTAMP WITHOUT TIME ZONE,
    updated_at TIMESTAMP WITHOUT TIME ZONE,
    PRIMARY KEY (id)
);

-- Table: public.oauth_clients
CREATE TABLE public.oauth_clients (
    id UUID NOT NULL,
    user_id BIGINT,
    name CHARACTER VARYING(255) NOT NULL,
    secret CHARACTER VARYING(100),
    provider CHARACTER VARYING(255),
    redirect TEXT NOT NULL,
    personal_access_client BOOLEAN NOT NULL,
    password_client BOOLEAN NOT NULL,
    revoked BOOLEAN NOT NULL,
    created_at TIMESTAMP WITHOUT TIME ZONE,
    updated_at TIMESTAMP WITHOUT TIME ZONE,
    PRIMARY KEY (id)
);

-- Table: public.oauth_personal_access_clients
CREATE TABLE public.oauth_personal_access_clients (
    id BIGINT NOT NULL DEFAULT nextval('oauth_personal_access_clients_id_seq'::regclass),
    client_id UUID NOT NULL,
    created_at TIMESTAMP WITHOUT TIME ZONE,
    updated_at TIMESTAMP WITHOUT TIME ZONE,
    PRIMARY KEY (id)
);

-- Table: public.oauth_refresh_tokens
CREATE TABLE public.oauth_refresh_tokens (
    id CHARACTER VARYING(100) NOT NULL,
    access_token_id CHARACTER VARYING(100) NOT NULL,
    revoked BOOLEAN NOT NULL,
    expires_at TIMESTAMP WITHOUT TIME ZONE,
    PRIMARY KEY (id)
);

-- Table: public.sales_admins
CREATE TABLE public.sales_admins (
    id BIGINT NOT NULL DEFAULT nextval('sales_admins_id_seq'::regclass),
    user_table_id BIGINT NOT NULL,
    role CHARACTER VARYING(255),
    district CHARACTER VARYING(255),
    zone CHARACTER VARYING(255),
    reports_to BIGINT,
    sale_point CHARACTER VARYING(255),
    isactive BOOLEAN NOT NULL DEFAULT true,
    referral_code CHARACTER VARYING(255),
    created_at TIMESTAMP WITHOUT TIME ZONE,
    updated_at TIMESTAMP WITHOUT TIME ZONE,
    PRIMARY KEY (id)
);

-- Table: public.tasks
CREATE TABLE public.tasks (
    id INTEGER NOT NULL DEFAULT nextval('tasks_id_seq'::regclass),
    title TEXT NOT NULL,
    description TEXT,
    status TEXT DEFAULT 'pending'::text,
    due_date TIMESTAMP WITH TIME ZONE,
    assignee_id INTEGER,
    created_at TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP,
    updated_at TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP,
    PRIMARY KEY (id)
);

-- Table: public.user_vouchers
CREATE TABLE public.user_vouchers (
    id INTEGER NOT NULL DEFAULT nextval('user_vouchers_id_seq'::regclass),
    user_id INTEGER,
    voucher_id INTEGER,
    status TEXT DEFAULT 'active'::text,
    assigned_at TIMESTAMP WITH TIME ZONE DEFAULT now(),
    redeemed_at TIMESTAMP WITH TIME ZONE,
    PRIMARY KEY (id)
);

-- Table: public.users
CREATE TABLE public.users (
    id BIGINT NOT NULL DEFAULT nextval('users_id_seq'::regclass),
    user_name CHARACTER VARYING(255) NOT NULL,
    email_id CHARACTER VARYING(255),
    phone_number CHARACTER VARYING(255),
    password CHARACTER VARYING(255),
    password_changed_at TIMESTAMP WITHOUT TIME ZONE,
    user_type CHARACTER VARYING(255) NOT NULL,
    isActive BOOLEAN NOT NULL DEFAULT true,
    is_kyc_verified BOOLEAN NOT NULL DEFAULT false,
    created_at TIMESTAMP WITHOUT TIME ZONE,
    updated_at TIMESTAMP WITHOUT TIME ZONE,
    remember_token CHARACTER VARYING(500),
    permissions JSONB DEFAULT '[]'::jsonb,
    PRIMARY KEY (id)
);

-- Table: public.voucher_redeem_terms
CREATE TABLE public.voucher_redeem_terms (
    id BIGINT NOT NULL DEFAULT nextval('voucher_redeem_terms_id_seq'::regclass),
    voucher_id BIGINT,
    how_to_redeem TEXT,
    terms TEXT,
    created_at TIMESTAMP WITHOUT TIME ZONE,
    updated_at TIMESTAMP WITHOUT TIME ZONE,
    PRIMARY KEY (id)
);

-- Table: public.voucher_templates
CREATE TABLE public.voucher_templates (
    id BIGINT NOT NULL DEFAULT nextval('voucher_templates_id_seq'::regclass),
    name CHARACTER VARYING(255) NOT NULL,
    description TEXT,
    draft TEXT NOT NULL,
    is_active BOOLEAN NOT NULL DEFAULT true,
    created_at TIMESTAMP WITHOUT TIME ZONE,
    updated_at TIMESTAMP WITHOUT TIME ZONE,
    voucher_type CHARACTER VARYING(255) NOT NULL DEFAULT 'flat'::character varying,
    PRIMARY KEY (id)
);

-- Table: public.vouchers
CREATE TABLE public.vouchers (
    id BIGINT NOT NULL DEFAULT nextval('vouchers_id_seq'::regclass),
    merchant_id BIGINT NOT NULL,
    category_id BIGINT NOT NULL,
    voucher_template_id BIGINT,
    voucher_count INTEGER NOT NULL,
    expiry_date DATE NOT NULL,
    redeem_type CHARACTER VARYING(255) NOT NULL DEFAULT 'both'::character varying,
    voucher_type CHARACTER VARYING(255) NOT NULL,
    flat_discount_amount NUMERIC,
    minimum_purchase_amount NUMERIC,
    percent_value NUMERIC,
    minimum_redeemable_amount NUMERIC,
    maximum_discount_amount NUMERIC,
    buy_quantity INTEGER,
    get_quantity INTEGER,
    status CHARACTER VARYING(255) NOT NULL DEFAULT 'draft'::character varying,
    current_step INTEGER NOT NULL DEFAULT 1,
    created_at TIMESTAMP WITHOUT TIME ZONE,
    updated_at TIMESTAMP WITHOUT TIME ZONE,
    voucher_title TEXT,
    image_url TEXT,
    short_description TEXT,
    redeemed_count INTEGER DEFAULT 0,
    claimed_count INTEGER DEFAULT 0,
    bux_value NUMERIC NOT NULL DEFAULT 0,
    clicks INTEGER NOT NULL DEFAULT 0,
    buy_count INTEGER NOT NULL DEFAULT 0,
    rating NUMERIC NOT NULL DEFAULT 0,
    number_of_reviews INTEGER NOT NULL DEFAULT 0,
    PRIMARY KEY (id)
);

