/*
  Warnings:

  - You are about to drop the column `role_id` on the `cg_tbl_refresh_tokens` table. All the data in the column will be lost.
  - You are about to drop the column `token` on the `cg_tbl_refresh_tokens` table. All the data in the column will be lost.
  - You are about to drop the column `user_id` on the `cg_tbl_refresh_tokens` table. All the data in the column will be lost.
  - A unique constraint covering the columns `[ref_code]` on the table `cg_tbl_customers` will be added. If there are existing duplicate values, this will fail.
  - A unique constraint covering the columns `[helper_intern_id]` on the table `cg_tbl_helper_interns` will be added. If there are existing duplicate values, this will fail.
  - A unique constraint covering the columns `[towing_id]` on the table `cg_tbl_towing_partners` will be added. If there are existing duplicate values, this will fail.
  - Added the required column `helper_intern_id` to the `cg_tbl_helper_interns` table without a default value. This is not possible if the table is not empty.
  - Added the required column `platform` to the `cg_tbl_refresh_tokens` table without a default value. This is not possible if the table is not empty.
  - Added the required column `refresh_token` to the `cg_tbl_refresh_tokens` table without a default value. This is not possible if the table is not empty.
  - Added the required column `tokenable_id` to the `cg_tbl_refresh_tokens` table without a default value. This is not possible if the table is not empty.
  - Added the required column `tokenable_type` to the `cg_tbl_refresh_tokens` table without a default value. This is not possible if the table is not empty.
  - Added the required column `towing_id` to the `cg_tbl_towing_partners` table without a default value. This is not possible if the table is not empty.

*/
-- DropForeignKey
ALTER TABLE `cg_tbl_refresh_tokens` DROP FOREIGN KEY `cg_tbl_refresh_tokens_role_id_fkey`;

-- AlterTable
ALTER TABLE `cg_tbl_customers` ADD COLUMN `date_of_birth` DATE NULL,
    ADD COLUMN `fcm_token` TEXT NULL,
    ADD COLUMN `marriage_date` DATE NULL,
    ADD COLUMN `ref_code` VARCHAR(100) NULL,
    ADD COLUMN `referred_by` BIGINT NULL;

-- AlterTable
ALTER TABLE `cg_tbl_helper_interns` ADD COLUMN `fcm_token` TEXT NULL,
    ADD COLUMN `helper_intern_id` VARCHAR(100) NOT NULL,
    ADD COLUMN `latitude` DECIMAL(10, 8) NULL,
    ADD COLUMN `longitude` DECIMAL(11, 8) NULL,
    MODIFY `status` INTEGER NULL DEFAULT 0;

-- AlterTable
ALTER TABLE `cg_tbl_refresh_tokens` DROP COLUMN `role_id`,
    DROP COLUMN `token`,
    DROP COLUMN `user_id`,
    ADD COLUMN `device_info` VARCHAR(255) NULL,
    ADD COLUMN `platform` VARCHAR(50) NOT NULL,
    ADD COLUMN `refresh_token` VARCHAR(500) NOT NULL,
    ADD COLUMN `tokenable_id` BIGINT NOT NULL,
    ADD COLUMN `tokenable_type` VARCHAR(255) NOT NULL;

-- AlterTable
ALTER TABLE `cg_tbl_tax_setups` ADD COLUMN `created_by` BIGINT NULL;

-- AlterTable
ALTER TABLE `cg_tbl_towing_partners` ADD COLUMN `fcm_token` TEXT NULL,
    ADD COLUMN `latitude` DECIMAL(10, 8) NULL,
    ADD COLUMN `longitude` DECIMAL(11, 8) NULL,
    ADD COLUMN `towing_id` VARCHAR(100) NOT NULL,
    MODIFY `status` INTEGER NULL DEFAULT 0;

-- CreateTable
CREATE TABLE `cg_tbl_freelancers` (
    `id` BIGINT NOT NULL AUTO_INCREMENT,
    `freelancer_id` VARCHAR(100) NOT NULL,
    `first_name` VARCHAR(100) NULL,
    `last_name` VARCHAR(100) NULL,
    `mobile` VARCHAR(20) NULL,
    `email` VARCHAR(150) NULL,
    `trade_name` VARCHAR(150) NULL,
    `entity_type` VARCHAR(100) NULL,
    `language_ids` LONGTEXT NULL,
    `blood_group` VARCHAR(20) NULL,
    `aadhaar_number` VARCHAR(20) NULL,
    `pan_number` VARCHAR(20) NULL,
    `gstin_number` VARCHAR(30) NULL,
    `cin_number` VARCHAR(50) NULL,
    `dob` DATE NULL,
    `address` TEXT NULL,
    `state` VARCHAR(100) NULL,
    `latitude` DECIMAL(10, 8) NULL,
    `longitude` DECIMAL(11, 8) NULL,
    `city` VARCHAR(100) NULL,
    `zone` LONGTEXT NULL,
    `pincode` VARCHAR(10) NULL,
    `bank_name` VARCHAR(150) NULL,
    `bank_account_number` VARCHAR(50) NULL,
    `bank_ifsc_code` VARCHAR(20) NULL,
    `skills` LONGTEXT NULL,
    `vehicle_fuel_types` LONGTEXT NULL,
    `ev_safety_certificate_file` VARCHAR(255) NULL,
    `pan_card_file` VARCHAR(255) NULL,
    `gst_file` VARCHAR(255) NULL,
    `cin_file` VARCHAR(255) NULL,
    `bank_document_file` VARCHAR(255) NULL,
    `aadhaar_card_file` VARCHAR(255) NULL,
    `profile_photo_file` VARCHAR(255) NULL,
    `experience_certificate_file` VARCHAR(255) NULL,
    `education_certificate_file` VARCHAR(255) NULL,
    `police_verification_file` VARCHAR(255) NULL,
    `selfie_with_tools_file` VARCHAR(255) NULL,
    `ev_certification_file` VARCHAR(255) NULL,
    `status` INTEGER NULL DEFAULT 0,
    `is_verified` INTEGER NULL DEFAULT 0,
    `fcm_token` TEXT NULL,
    `subscription_id` BIGINT NULL,
    `subscription_start_date` TIMESTAMP(0) NULL,
    `subscription_end_date` TIMESTAMP(0) NULL,
    `created_at` TIMESTAMP(0) NULL DEFAULT CURRENT_TIMESTAMP(0),
    `updated_at` TIMESTAMP(0) NULL,

    UNIQUE INDEX `cg_tbl_freelancers_freelancer_id_key`(`freelancer_id`),
    PRIMARY KEY (`id`)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

-- CreateTable
CREATE TABLE `cg_tbl_freelancer_team_members` (
    `id` BIGINT NOT NULL AUTO_INCREMENT,
    `freelancer_id` BIGINT NULL,
    `member_name` VARCHAR(100) NULL,
    `member_mobile` VARCHAR(20) NULL,
    `member_aadhaar_number` VARCHAR(20) NULL,
    `member_photo_file` VARCHAR(255) NULL,
    `status` INTEGER NULL DEFAULT 1,
    `created_at` TIMESTAMP(0) NULL DEFAULT CURRENT_TIMESTAMP(0),
    `updated_at` TIMESTAMP(0) NULL,

    INDEX `cg_tbl_freelancer_team_members_freelancer_id_fkey`(`freelancer_id`),
    PRIMARY KEY (`id`)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

-- CreateTable
CREATE TABLE `cg_tbl_freelancer_emergency_contacts` (
    `id` BIGINT NOT NULL AUTO_INCREMENT,
    `freelancer_id` BIGINT NULL,
    `contact_name` VARCHAR(100) NULL,
    `contact_number` VARCHAR(20) NULL,
    `relationship` VARCHAR(50) NULL,
    `status` INTEGER NULL DEFAULT 1,
    `created_at` TIMESTAMP(0) NULL DEFAULT CURRENT_TIMESTAMP(0),
    `updated_at` TIMESTAMP(0) NULL,

    INDEX `cg_tbl_freelancer_emergency_contacts_freelancer_id_fkey`(`freelancer_id`),
    PRIMARY KEY (`id`)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

-- CreateTable
CREATE TABLE `cg_tbl_garages` (
    `id` BIGINT NOT NULL AUTO_INCREMENT,
    `garage_id` VARCHAR(100) NOT NULL,
    `multiple_garages` INTEGER NULL,
    `first_name` VARCHAR(100) NULL,
    `last_name` VARCHAR(100) NULL,
    `mobile` VARCHAR(20) NULL,
    `email` VARCHAR(150) NULL,
    `trade_name` VARCHAR(150) NULL,
    `entity_type` VARCHAR(100) NULL,
    `language` VARCHAR(50) NULL,
    `aadhaar_number` VARCHAR(20) NULL,
    `pan_number` VARCHAR(20) NULL,
    `gstin_number` VARCHAR(30) NULL,
    `cin_number` VARCHAR(50) NULL,
    `dob` DATE NULL,
    `address` TEXT NULL,
    `state` VARCHAR(100) NULL,
    `city` VARCHAR(100) NULL,
    `zone` LONGTEXT NULL,
    `pincode` VARCHAR(10) NULL,
    `latitude` DECIMAL(10, 8) NULL,
    `longitude` DECIMAL(11, 8) NULL,
    `bank_name` VARCHAR(150) NULL,
    `bank_account_number` VARCHAR(50) NULL,
    `bank_ifsc_code` VARCHAR(20) NULL,
    `operating_hours` LONGTEXT NULL,
    `vehicle_fuel_types` LONGTEXT NULL,
    `vehicle_classes` LONGTEXT NULL,
    `ev_safety_certificate_file` VARCHAR(255) NULL,
    `pan_card_file` VARCHAR(255) NULL,
    `gst_file` VARCHAR(255) NULL,
    `cin_file` VARCHAR(255) NULL,
    `bank_document_file` VARCHAR(255) NULL,
    `aadhaar_card_file` VARCHAR(255) NULL,
    `profile_photo_file` VARCHAR(255) NULL,
    `infrastructure_image_file` VARCHAR(255) NULL,
    `status` INTEGER NULL DEFAULT 0,
    `is_parent` TINYINT NULL DEFAULT 0,
    `parent_id` BIGINT NULL,
    `is_verified` INTEGER NULL DEFAULT 0,
    `fcm_token` TEXT NULL,
    `subscription_id` BIGINT NULL,
    `subscription_start_date` TIMESTAMP(0) NULL,
    `subscription_end_date` TIMESTAMP(0) NULL,
    `created_at` TIMESTAMP(0) NULL DEFAULT CURRENT_TIMESTAMP(0),
    `updated_at` TIMESTAMP(0) NULL,

    UNIQUE INDEX `cg_tbl_garages_garage_id_key`(`garage_id`),
    PRIMARY KEY (`id`)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

-- CreateTable
CREATE TABLE `cg_tbl_sellers` (
    `id` BIGINT NOT NULL AUTO_INCREMENT,
    `seller_id` VARCHAR(100) NULL,
    `first_name` VARCHAR(100) NULL,
    `last_name` VARCHAR(100) NULL,
    `mobile` VARCHAR(20) NULL,
    `email` VARCHAR(150) NULL,
    `trade_name` VARCHAR(150) NULL,
    `entity_type` VARCHAR(100) NULL,
    `aadhaar_number` VARCHAR(20) NULL,
    `pan_number` VARCHAR(20) NULL,
    `gstin_number` VARCHAR(30) NULL,
    `cin_number` VARCHAR(50) NULL,
    `operating_hours` LONGTEXT NULL,
    `specific_commission` INTEGER NULL,
    `customer_order_commission` DECIMAL(10, 2) NULL,
    `garage_order_commission` DECIMAL(10, 2) NULL,
    `requested_customer_order_commission` DECIMAL(10, 2) NULL,
    `requested_garage_order_commission` DECIMAL(10, 2) NULL,
    `bank_name` VARCHAR(150) NULL,
    `bank_account_number` VARCHAR(50) NULL,
    `bank_ifsc_code` VARCHAR(20) NULL,
    `address` TEXT NULL,
    `latitude` DECIMAL(10, 8) NULL,
    `longitude` DECIMAL(11, 8) NULL,
    `state` VARCHAR(100) NULL,
    `city` VARCHAR(100) NULL,
    `zone` LONGTEXT NULL,
    `pincode` VARCHAR(10) NULL,
    `pan_card_file` VARCHAR(255) NULL,
    `gst_file` VARCHAR(255) NULL,
    `cin_file` VARCHAR(255) NULL,
    `cancelled_cheque_file` VARCHAR(255) NULL,
    `aadhaar_pan_signatory_file` VARCHAR(255) NULL,
    `other_documents_file` VARCHAR(255) NULL,
    `status` INTEGER NULL DEFAULT 0,
    `is_verified` INTEGER NULL,
    `fcm_token` TEXT NULL,
    `subscription_id` BIGINT NULL,
    `subscription_start_date` TIMESTAMP(0) NULL,
    `subscription_end_date` TIMESTAMP(0) NULL,
    `created_at` TIMESTAMP(0) NULL DEFAULT CURRENT_TIMESTAMP(0),
    `updated_at` TIMESTAMP(0) NULL,

    UNIQUE INDEX `cg_tbl_sellers_seller_id_key`(`seller_id`),
    PRIMARY KEY (`id`)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

-- CreateTable
CREATE TABLE `cg_tbl_user_addresses` (
    `id` BIGINT NOT NULL AUTO_INCREMENT,
    `user_id` BIGINT NULL,
    `role_id` BIGINT NULL,
    `address_title` VARCHAR(100) NULL,
    `contact_name` VARCHAR(150) NULL,
    `phone_number` VARCHAR(20) NULL,
    `flat_house_no` VARCHAR(255) NULL,
    `area_locality` VARCHAR(255) NULL,
    `landmark` VARCHAR(255) NULL,
    `pincode` VARCHAR(10) NULL,
    `city` VARCHAR(100) NULL,
    `state` VARCHAR(100) NULL,
    `latitude` DECIMAL(10, 8) NULL,
    `longitude` DECIMAL(11, 8) NULL,
    `full_address` TEXT NULL,
    `is_default` SMALLINT NULL DEFAULT 0,
    `status` SMALLINT NULL DEFAULT 1,
    `created_at` TIMESTAMP(0) NULL DEFAULT CURRENT_TIMESTAMP(0),
    `updated_at` TIMESTAMP(0) NULL,

    INDEX `cg_tbl_user_addresses_role_id_fkey`(`role_id`),
    PRIMARY KEY (`id`)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

-- CreateTable
CREATE TABLE `cg_tbl_business_settings` (
    `id` BIGINT NOT NULL AUTO_INCREMENT,
    `key` VARCHAR(191) NOT NULL,
    `value` LONGTEXT NULL,
    `created_at` TIMESTAMP(0) NULL DEFAULT CURRENT_TIMESTAMP(0),
    `updated_at` TIMESTAMP(0) NULL,

    UNIQUE INDEX `cg_tbl_business_settings_key_key`(`key`),
    PRIMARY KEY (`id`)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

-- CreateTable
CREATE TABLE `cg_tbl_coupons` (
    `id` BIGINT NOT NULL AUTO_INCREMENT,
    `coupon_code` VARCHAR(100) NOT NULL,
    `title` VARCHAR(255) NULL,
    `created_type` VARCHAR(100) NULL,
    `created_by` BIGINT NULL,
    `vendor_id` BIGINT NULL,
    `zone_ids` VARCHAR(255) NULL,
    `module_type` ENUM('gig', 'order') NULL,
    `coupon_type` VARCHAR(50) NOT NULL,
    `applicable_user_type` VARCHAR(50) NOT NULL DEFAULT 'both',
    `user_eligibility` VARCHAR(50) NULL DEFAULT 'all_users',
    `discount_value` DECIMAL(10, 2) NOT NULL,
    `max_discount` DECIMAL(10, 2) NULL,
    `min_order_value` DECIMAL(10, 2) NOT NULL,
    `valid_from` TIMESTAMP(0) NULL,
    `valid_to` TIMESTAMP(0) NULL,
    `total_usage_limit` INTEGER NULL DEFAULT 0,
    `total_uses` INTEGER NOT NULL DEFAULT 0,
    `admin_contribution_percentage` INTEGER NULL DEFAULT 0,
    `vendor_contribution_percentage` INTEGER NULL DEFAULT 0,
    `usage_per_user` INTEGER NULL DEFAULT 1,
    `category_restrictions` LONGTEXT NULL,
    `allow_stacking` INTEGER NULL DEFAULT 0,
    `max_combined_discount` DECIMAL(10, 2) NULL,
    `status` INTEGER NULL DEFAULT 1,
    `created_at` TIMESTAMP(0) NULL DEFAULT CURRENT_TIMESTAMP(0),
    `updated_at` TIMESTAMP(0) NULL,

    UNIQUE INDEX `cg_tbl_coupons_coupon_code_key`(`coupon_code`),
    INDEX `cg_tbl_coupons_vendor_id_fkey`(`vendor_id`),
    PRIMARY KEY (`id`)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

-- CreateTable
CREATE TABLE `cg_tbl_admin_roles` (
    `id` BIGINT NOT NULL AUTO_INCREMENT,
    `role_name` VARCHAR(100) NOT NULL,
    `role_slug` VARCHAR(100) NOT NULL,
    `status` INTEGER NULL DEFAULT 1,
    `created_at` TIMESTAMP(0) NULL DEFAULT CURRENT_TIMESTAMP(0),
    `updated_at` TIMESTAMP(0) NULL,

    UNIQUE INDEX `cg_tbl_admin_roles_role_slug_key`(`role_slug`),
    PRIMARY KEY (`id`)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

-- CreateTable
CREATE TABLE `cg_tbl_admin_users` (
    `id` BIGINT NOT NULL AUTO_INCREMENT,
    `role_id` BIGINT NOT NULL,
    `full_name` VARCHAR(255) NOT NULL,
    `email` VARCHAR(150) NOT NULL,
    `mobile` VARCHAR(20) NULL,
    `password` VARCHAR(255) NOT NULL,
    `profile_photo_file` VARCHAR(255) NULL,
    `last_login_at` TIMESTAMP(0) NULL,
    `status` INTEGER NULL DEFAULT 1,
    `created_at` TIMESTAMP(0) NULL DEFAULT CURRENT_TIMESTAMP(0),
    `updated_at` TIMESTAMP(0) NULL,
    `age` INTEGER NULL,
    `address` TEXT NULL,
    `gender` ENUM('male', 'female', 'others') NULL,

    UNIQUE INDEX `cg_tbl_admin_users_email_key`(`email`),
    INDEX `cg_tbl_admin_users_role_id_fkey`(`role_id`),
    PRIMARY KEY (`id`)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

-- CreateTable
CREATE TABLE `cg_table_tutorials` (
    `id` BIGINT NOT NULL AUTO_INCREMENT,
    `role_id` BIGINT NULL,
    `youtube_url` VARCHAR(255) NOT NULL,
    `status` INTEGER NULL DEFAULT 1,
    `created_at` TIMESTAMP(0) NULL DEFAULT CURRENT_TIMESTAMP(0),
    `created_by` BIGINT NULL,
    `updated_at` TIMESTAMP(0) NULL,

    INDEX `cg_table_tutorials_role_id_fkey`(`role_id`),
    PRIMARY KEY (`id`)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

-- CreateTable
CREATE TABLE `cg_tbl_categories` (
    `id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
    `category_name` VARCHAR(255) NOT NULL,
    `slug` VARCHAR(255) NOT NULL,
    `category_image` VARCHAR(500) NULL,
    `status` TINYINT NOT NULL DEFAULT 1,
    `has_subcategory` BOOLEAN NOT NULL DEFAULT true,
    `created_at` TIMESTAMP(0) NULL DEFAULT CURRENT_TIMESTAMP(0),
    `created_by` BIGINT NULL,
    `updated_at` TIMESTAMP(0) NULL,

    UNIQUE INDEX `cg_tbl_categories_slug_key`(`slug`),
    PRIMARY KEY (`id`)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

-- CreateTable
CREATE TABLE `cg_tbl_sub_categories` (
    `id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
    `sub_category_name` VARCHAR(255) NOT NULL,
    `slug` VARCHAR(255) NOT NULL,
    `minimum_time` INTEGER NULL,
    `maximum_time` INTEGER NULL,
    `cover_image` VARCHAR(500) NULL,
    `gallery_images` JSON NULL,
    `about_services` JSON NULL,
    `prerequisites` JSON NULL,
    `content_blocks` JSON NULL,
    `status` TINYINT NOT NULL DEFAULT 1,
    `created_at` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
    `created_by` BIGINT NULL,
    `updated_at` DATETIME(3) NOT NULL,

    UNIQUE INDEX `cg_tbl_sub_categories_slug_key`(`slug`),
    PRIMARY KEY (`id`)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

-- CreateTable
CREATE TABLE `cg_tbl_category_sub_category_setup` (
    `id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
    `category_id` BIGINT UNSIGNED NOT NULL,
    `sub_category_id` BIGINT UNSIGNED NOT NULL,
    `role_id` BIGINT NOT NULL,
    `est_amount_enabled` TINYINT NOT NULL DEFAULT 0,
    `est_prepaid_amount` DECIMAL(10, 2) NOT NULL DEFAULT 0.00,
    `pickup_drop_enabled` TINYINT NOT NULL DEFAULT 0,
    `pickup_drop_amount` DECIMAL(10, 2) NULL,
    `pricing` DECIMAL(10, 2) NOT NULL,
    `priority` INTEGER NOT NULL DEFAULT 0,
    `service_type` ENUM('garage', 'home', 'both') NOT NULL DEFAULT 'garage',
    `discount_type` ENUM('flat', 'percentage') NULL,
    `discount_value` DECIMAL(10, 2) NULL,
    `status` TINYINT NOT NULL DEFAULT 1,
    `created_at` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
    `created_by` BIGINT NULL,
    `updated_at` DATETIME(3) NOT NULL,
    `vehicle_class_id` BIGINT NOT NULL,
    `vehicle_fuel_type_id` BIGINT NOT NULL,

    INDEX `cg_tbl_category_sub_category_setup_category_id_fkey`(`category_id`),
    INDEX `cg_tbl_category_sub_category_setup_sub_category_id_fkey`(`sub_category_id`),
    INDEX `cg_tbl_category_sub_category_setup_role_id_fkey`(`role_id`),
    INDEX `cg_tbl_category_sub_category_setup_vehicle_class_id_fkey`(`vehicle_class_id`),
    INDEX `cg_tbl_category_sub_category_setup_vehicle_fuel_type_id_fkey`(`vehicle_fuel_type_id`),
    UNIQUE INDEX `cg_tbl_category_sub_category_setup_category_id_sub_category__key`(`category_id`, `sub_category_id`, `role_id`, `service_type`, `vehicle_class_id`, `vehicle_fuel_type_id`),
    PRIMARY KEY (`id`)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

-- CreateTable
CREATE TABLE `cg_tbl_rattings_reason` (
    `id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
    `reason` VARCHAR(255) NOT NULL,
    `app_name` BIGINT NOT NULL,
    `status` TINYINT NOT NULL DEFAULT 1,
    `created_at` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
    `created_by` BIGINT NULL,
    `updated_at` DATETIME(3) NOT NULL,

    PRIMARY KEY (`id`)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

-- CreateTable
CREATE TABLE `cg_tbl_skill_set` (
    `id` BIGINT NOT NULL AUTO_INCREMENT,
    `skill_name` VARCHAR(255) NOT NULL,
    `status` INTEGER NULL,
    `user_role` BIGINT NULL,
    `created_at` TIMESTAMP(0) NULL DEFAULT CURRENT_TIMESTAMP(0),
    `updated_at` TIMESTAMP(0) NULL,

    PRIMARY KEY (`id`)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

-- CreateTable
CREATE TABLE `cg_tbl_service_reason` (
    `id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
    `category_id` BIGINT UNSIGNED NOT NULL,
    `reasons` JSON NULL,
    `status` TINYINT NOT NULL DEFAULT 1,
    `created_at` TIMESTAMP(0) NULL DEFAULT CURRENT_TIMESTAMP(0),
    `created_by` BIGINT NULL,
    `updated_at` TIMESTAMP(0) NULL,

    PRIMARY KEY (`id`)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

-- CreateTable
CREATE TABLE `cg_tbl_banners` (
    `id` BIGINT NOT NULL AUTO_INCREMENT,
    `title` VARCHAR(255) NOT NULL,
    `description` TEXT NULL,
    `banner_image` VARCHAR(255) NOT NULL,
    `zone_id` BIGINT NOT NULL,
    `status` TINYINT NULL DEFAULT 1,
    `created_by` BIGINT NULL,
    `created_at` TIMESTAMP(0) NULL DEFAULT CURRENT_TIMESTAMP(0),
    `updated_at` TIMESTAMP(0) NULL,

    INDEX `cg_tbl_banners_zone_id_fkey`(`zone_id`),
    PRIMARY KEY (`id`)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

-- CreateTable
CREATE TABLE `cg_tbl_advertisements` (
    `id` BIGINT NOT NULL AUTO_INCREMENT,
    `user_id` BIGINT NOT NULL,
    `user_role_id` BIGINT NULL,
    `advertisement_type` ENUM('banner', 'product', 'store') NOT NULL,
    `title` VARCHAR(255) NULL,
    `product_id` BIGINT NULL,
    `banner_image` VARCHAR(255) NOT NULL,
    `zone_id` BIGINT NOT NULL,
    `from_date` DATETIME(0) NOT NULL,
    `to_date` DATETIME(0) NOT NULL,
    `amount` DECIMAL(10, 2) NULL,
    `payment_status` ENUM('pending', 'paid', 'failed', 'refunded') NULL,
    `approval_status` ENUM('pending', 'approved', 'rejected') NULL DEFAULT 'pending',
    `rejected_remarks` TEXT NULL,
    `action_by` BIGINT NULL,
    `action_at` DATETIME(0) NULL,
    `status` TINYINT NULL DEFAULT 1,
    `created_at` TIMESTAMP(0) NULL DEFAULT CURRENT_TIMESTAMP(0),
    `updated_at` TIMESTAMP(0) NULL,

    INDEX `cg_tbl_advertisements_zone_id_fkey`(`zone_id`),
    INDEX `cg_tbl_advertisements_user_role_id_fkey`(`user_role_id`),
    PRIMARY KEY (`id`)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

-- CreateTable
CREATE TABLE `cg_tbl_zones` (
    `id` BIGINT NOT NULL AUTO_INCREMENT,
    `zone_name` VARCHAR(255) NOT NULL,
    `zone_code` VARCHAR(255) NOT NULL,
    `status` TINYINT NULL DEFAULT 1,
    `coordinates` polygon NOT NULL,
    `created_at` TIMESTAMP(0) NULL DEFAULT CURRENT_TIMESTAMP(0),
    `updated_at` TIMESTAMP(0) NULL,

    PRIMARY KEY (`id`)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

-- CreateTable
CREATE TABLE `cg_tbl_gig_modification_reason` (
    `id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
    `category_id` BIGINT UNSIGNED NOT NULL,
    `reasons` JSON NULL,
    `status` TINYINT NOT NULL DEFAULT 1,
    `created_at` TIMESTAMP(0) NULL DEFAULT CURRENT_TIMESTAMP(0),
    `created_by` BIGINT NULL,
    `updated_at` TIMESTAMP(0) NULL,

    PRIMARY KEY (`id`)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

-- CreateTable
CREATE TABLE `cg_tbl_vehicle_classes` (
    `id` BIGINT NOT NULL AUTO_INCREMENT,
    `name` VARCHAR(100) NOT NULL,
    `slug` VARCHAR(100) NOT NULL,
    `status` TINYINT NULL DEFAULT 1,
    `created_at` TIMESTAMP(0) NULL DEFAULT CURRENT_TIMESTAMP(0),
    `updated_at` TIMESTAMP(0) NULL,

    UNIQUE INDEX `cg_tbl_vehicle_classes_slug_key`(`slug`),
    PRIMARY KEY (`id`)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

-- CreateTable
CREATE TABLE `cg_tbl_vehicle_fuel_types` (
    `id` BIGINT NOT NULL AUTO_INCREMENT,
    `name` VARCHAR(100) NOT NULL,
    `slug` VARCHAR(100) NOT NULL,
    `status` TINYINT NULL DEFAULT 1,
    `created_at` TIMESTAMP(0) NULL DEFAULT CURRENT_TIMESTAMP(0),
    `updated_at` TIMESTAMP(0) NULL,

    UNIQUE INDEX `cg_tbl_vehicle_fuel_types_slug_key`(`slug`),
    PRIMARY KEY (`id`)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

-- CreateTable
CREATE TABLE `cg_tbl_languages` (
    `id` BIGINT NOT NULL AUTO_INCREMENT,
    `name` VARCHAR(100) NOT NULL,
    `slug` VARCHAR(100) NOT NULL,
    `status` TINYINT NULL DEFAULT 1,
    `created_at` TIMESTAMP(0) NULL DEFAULT CURRENT_TIMESTAMP(0),
    `updated_at` TIMESTAMP(0) NULL,

    UNIQUE INDEX `cg_tbl_languages_slug_key`(`slug`),
    PRIMARY KEY (`id`)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

-- CreateTable
CREATE TABLE `cg_tbl_profile_update_requests` (
    `id` BIGINT NOT NULL AUTO_INCREMENT,
    `user_id` BIGINT NOT NULL,
    `user_role_id` BIGINT NULL,
    `change_data` JSON NOT NULL,
    `status` TINYINT NULL DEFAULT 0,
    `action_by` BIGINT NULL,
    `action_at` TIMESTAMP(0) NULL,
    `rejection_reason` TEXT NULL,
    `created_at` TIMESTAMP(0) NULL DEFAULT CURRENT_TIMESTAMP(0),
    `updated_at` TIMESTAMP(0) NULL,

    INDEX `cg_tbl_profile_update_requests_user_role_id_fkey`(`user_role_id`),
    PRIMARY KEY (`id`)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

-- CreateTable
CREATE TABLE `cg_tbl_towing_quote_time` (
    `id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
    `time_value` VARCHAR(100) NOT NULL,
    `status` TINYINT NULL DEFAULT 0,
    `last_active` TINYINT NULL DEFAULT 0,
    `created_at` TIMESTAMP(0) NULL DEFAULT CURRENT_TIMESTAMP(0),
    `created_by` BIGINT NULL,
    `updated_at` TIMESTAMP(0) NULL,

    PRIMARY KEY (`id`)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

-- CreateTable
CREATE TABLE `cg_tbl_towing_service` (
    `id` BIGINT NOT NULL AUTO_INCREMENT,
    `towingServiceName` VARCHAR(255) NOT NULL,
    `image` LONGTEXT NOT NULL,
    `status` TINYINT NULL DEFAULT 1,
    `created_by` BIGINT NULL,
    `created_at` TIMESTAMP(0) NULL DEFAULT CURRENT_TIMESTAMP(0),
    `updated_at` TIMESTAMP(0) NULL,

    INDEX `cg_tbl_towing_service_created_by_fkey`(`created_by`),
    PRIMARY KEY (`id`)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

-- CreateTable
CREATE TABLE `cg_tbl_helper_pricing` (
    `id` INTEGER NOT NULL AUTO_INCREMENT,
    `durationHours` DOUBLE NOT NULL,
    `baseFeeAmount` DECIMAL(10, 2) NOT NULL,
    `gst_percentage_id` BIGINT NOT NULL,
    `status` TINYINT NOT NULL DEFAULT 1,
    `createdAt` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
    `created_by` BIGINT NULL,
    `updatedAt` DATETIME(3) NOT NULL,

    INDEX `cg_tbl_helper_pricing_gst_percentage_id_fkey`(`gst_percentage_id`),
    PRIMARY KEY (`id`)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

-- CreateTable
CREATE TABLE `cg_tbl_cancellation_reasons` (
    `id` BIGINT NOT NULL AUTO_INCREMENT,
    `reason` VARCHAR(255) NOT NULL,
    `app_id` BIGINT NOT NULL,
    `status` TINYINT NULL DEFAULT 1,
    `created_at` TIMESTAMP(0) NULL DEFAULT CURRENT_TIMESTAMP(0),
    `created_by` BIGINT NULL,
    `updated_at` TIMESTAMP(0) NULL,

    INDEX `cg_tbl_cancellation_reasons_app_id_fkey`(`app_id`),
    PRIMARY KEY (`id`)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

-- CreateTable
CREATE TABLE `cg_tbl_vintage_vehicle_requests` (
    `id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
    `request_type` ENUM('spare_part', 'service') NULL DEFAULT 'spare_part',
    `make` VARCHAR(100) NULL,
    `year` YEAR NULL,
    `model` VARCHAR(255) NULL,
    `fuel_type` VARCHAR(50) NULL,
    `vehicle_class` VARCHAR(100) NULL,
    `chassis_number` VARCHAR(100) NULL,
    `part_name` VARCHAR(255) NULL,
    `product_type` ENUM('oem', 'after_market') NULL,
    `quantity` INTEGER NULL DEFAULT 1,
    `remarks` TEXT NULL,
    `images` JSON NULL,
    `status` INTEGER NULL DEFAULT 0,
    `status_history` JSON NULL,
    `modification_category` VARCHAR(100) NULL,
    `user_id` BIGINT NULL,
    `role_id` BIGINT NULL,
    `platform` ENUM('app', 'web') NOT NULL,
    `created_at` TIMESTAMP(0) NULL DEFAULT CURRENT_TIMESTAMP(0),
    `updated_at` TIMESTAMP(0) NULL DEFAULT CURRENT_TIMESTAMP(0),

    PRIMARY KEY (`id`)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

-- CreateTable
CREATE TABLE `cg_tbl_vehicles_master` (
    `id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
    `user_id` BIGINT UNSIGNED NOT NULL,
    `user_role_id` BIGINT NOT NULL,
    `vehicle_no` VARCHAR(50) NOT NULL,
    `make` VARCHAR(100) NOT NULL,
    `model` VARCHAR(100) NOT NULL,
    `year` YEAR NOT NULL,
    `chassis_no` VARCHAR(100) NULL,
    `odometer_reading_km` INTEGER UNSIGNED NOT NULL DEFAULT 0,
    `vehicle_class_id` BIGINT NOT NULL,
    `vehicle_fuel_type_id` BIGINT NOT NULL,
    `vehicle_image` VARCHAR(255) NULL,
    `vehicle_rc_img` VARCHAR(255) NULL,
    `status` TINYINT NOT NULL DEFAULT 1,
    `deleted_status` TINYINT NOT NULL DEFAULT 0,
    `created_at` TIMESTAMP(0) NULL DEFAULT CURRENT_TIMESTAMP(0),
    `updated_at` TIMESTAMP(0) NULL DEFAULT CURRENT_TIMESTAMP(0),

    INDEX `cg_tbl_vehicles_master_user_role_id_fkey`(`user_role_id`),
    INDEX `cg_tbl_vehicles_master_vehicle_class_id_fkey`(`vehicle_class_id`),
    INDEX `cg_tbl_vehicles_master_vehicle_fuel_type_id_fkey`(`vehicle_fuel_type_id`),
    PRIMARY KEY (`id`)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

-- CreateTable
CREATE TABLE `cg_tbl_user_notifications` (
    `id` BIGINT NOT NULL AUTO_INCREMENT,
    `user_id` BIGINT NOT NULL,
    `user_role_id` BIGINT NOT NULL,
    `data` JSON NULL,
    `platform` VARCHAR(50) NULL,
    `is_read` BOOLEAN NOT NULL DEFAULT false,
    `created_at` TIMESTAMP(0) NULL DEFAULT CURRENT_TIMESTAMP(0),

    PRIMARY KEY (`id`)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

-- CreateTable
CREATE TABLE `cg_tbl_tickets` (
    `id` BIGINT NOT NULL AUTO_INCREMENT,
    `vehicle_no` VARCHAR(50) NULL,
    `issue_type` ENUM('gig', 'order', 'other') NOT NULL,
    `reference_no` VARCHAR(100) NULL,
    `images` JSON NULL,
    `remarks` TEXT NULL,
    `priority` ENUM('low', 'medium', 'high') NOT NULL,
    `status` ENUM('open', 'inprogress', 'closed') NOT NULL DEFAULT 'open',
    `user_id` BIGINT NULL,
    `user_role_id` BIGINT NULL,
    `platform` ENUM('app', 'web') NOT NULL,
    `created_at` TIMESTAMP(0) NULL DEFAULT CURRENT_TIMESTAMP(0),
    `updated_at` TIMESTAMP(0) NULL,

    PRIMARY KEY (`id`)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

-- CreateTable
CREATE TABLE `cg_tbl_subscription_plans` (
    `id` BIGINT NOT NULL AUTO_INCREMENT,
    `user_role_id` BIGINT NULL,
    `title` VARCHAR(255) NOT NULL,
    `plan_type` VARCHAR(50) NOT NULL,
    `price` DECIMAL(10, 2) NOT NULL,
    `gst_percentage` DECIMAL(5, 2) NULL,
    `features` JSON NOT NULL,
    `status` TINYINT NULL DEFAULT 1,
    `created_at` TIMESTAMP(0) NULL DEFAULT CURRENT_TIMESTAMP(0),
    `updated_at` TIMESTAMP(0) NULL,

    PRIMARY KEY (`id`)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

-- CreateTable
CREATE TABLE `cg_tbl_temp_subscription_orders` (
    `id` BIGINT NOT NULL AUTO_INCREMENT,
    `user_id` BIGINT NOT NULL,
    `user_role_id` BIGINT NOT NULL,
    `subscription_plan_id` BIGINT NOT NULL,
    `plan_title` VARCHAR(100) NOT NULL,
    `plan_type` ENUM('monthly', 'yearly') NOT NULL,
    `amount` DECIMAL(10, 2) NOT NULL,
    `gst_percentage` DECIMAL(5, 2) NOT NULL,
    `gst_amount` DECIMAL(10, 2) NOT NULL,
    `total_amount` DECIMAL(10, 2) NOT NULL,
    `gateway_name` VARCHAR(100) NULL,
    `gateway_order_id` VARCHAR(255) NULL,
    `gateway_payment_id` VARCHAR(255) NULL,
    `payment_status` ENUM('pending', 'success', 'failed', 'cancelled') NOT NULL,
    `status` TINYINT NULL DEFAULT 1,
    `created_at` TIMESTAMP(0) NULL DEFAULT CURRENT_TIMESTAMP(0),
    `updated_at` TIMESTAMP(0) NULL,

    PRIMARY KEY (`id`)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

-- CreateTable
CREATE TABLE `cg_tbl_user_subscriptions` (
    `id` BIGINT NOT NULL AUTO_INCREMENT,
    `user_id` BIGINT NOT NULL,
    `user_role_id` BIGINT NOT NULL,
    `subscription_plan_id` BIGINT NOT NULL,
    `plan_title` VARCHAR(100) NOT NULL,
    `plan_type` ENUM('monthly', 'yearly') NOT NULL,
    `amount` DECIMAL(10, 2) NOT NULL,
    `gst_percentage` DECIMAL(5, 2) NOT NULL,
    `gst_amount` DECIMAL(10, 2) NOT NULL,
    `total_amount` DECIMAL(10, 2) NOT NULL,
    `gateway_name` VARCHAR(100) NULL,
    `gateway_order_id` VARCHAR(255) NULL,
    `gateway_payment_id` VARCHAR(255) NULL,
    `status` TINYINT NULL DEFAULT 1,
    `subscription_start_date` TIMESTAMP(0) NULL,
    `subscription_end_date` TIMESTAMP(0) NULL,
    `created_at` TIMESTAMP(0) NULL DEFAULT CURRENT_TIMESTAMP(0),
    `updated_at` TIMESTAMP(0) NULL,

    PRIMARY KEY (`id`)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

-- CreateTable
CREATE TABLE `cg_tbl_transactions` (
    `id` BIGINT NOT NULL AUTO_INCREMENT,
    `user_id` BIGINT NOT NULL,
    `role_id` BIGINT NOT NULL,
    `platform` VARCHAR(50) NULL,
    `reference_type` VARCHAR(100) NULL,
    `reference_id` BIGINT NULL,
    `entry_type` ENUM('CREDIT', 'DEBIT') NOT NULL,
    `amount` DECIMAL(10, 2) NOT NULL,
    `gateway_name` VARCHAR(100) NULL,
    `gateway_order_id` VARCHAR(255) NULL,
    `gateway_payment_id` VARCHAR(255) NULL,
    `status` TINYINT NULL DEFAULT 1,
    `remarks` TEXT NULL,
    `created_at` TIMESTAMP(0) NULL DEFAULT CURRENT_TIMESTAMP(0),
    `updated_at` TIMESTAMP(0) NULL,

    PRIMARY KEY (`id`)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

-- CreateIndex
CREATE UNIQUE INDEX `cg_tbl_customers_ref_code_key` ON `cg_tbl_customers`(`ref_code`);

-- CreateIndex
CREATE UNIQUE INDEX `cg_tbl_helper_interns_helper_intern_id_key` ON `cg_tbl_helper_interns`(`helper_intern_id`);

-- CreateIndex
CREATE UNIQUE INDEX `cg_tbl_towing_partners_towing_id_key` ON `cg_tbl_towing_partners`(`towing_id`);

-- AddForeignKey
ALTER TABLE `cg_tbl_freelancers` ADD CONSTRAINT `cg_tbl_freelancers_subscription_id_fkey` FOREIGN KEY (`subscription_id`) REFERENCES `cg_tbl_subscription_plans`(`id`) ON DELETE NO ACTION ON UPDATE NO ACTION;

-- AddForeignKey
ALTER TABLE `cg_tbl_freelancer_team_members` ADD CONSTRAINT `cg_tbl_freelancer_team_members_freelancer_id_fkey` FOREIGN KEY (`freelancer_id`) REFERENCES `cg_tbl_freelancers`(`id`) ON DELETE CASCADE ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE `cg_tbl_freelancer_emergency_contacts` ADD CONSTRAINT `cg_tbl_freelancer_emergency_contacts_freelancer_id_fkey` FOREIGN KEY (`freelancer_id`) REFERENCES `cg_tbl_freelancers`(`id`) ON DELETE CASCADE ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE `cg_tbl_garages` ADD CONSTRAINT `cg_tbl_garages_subscription_id_fkey` FOREIGN KEY (`subscription_id`) REFERENCES `cg_tbl_subscription_plans`(`id`) ON DELETE NO ACTION ON UPDATE NO ACTION;

-- AddForeignKey
ALTER TABLE `cg_tbl_sellers` ADD CONSTRAINT `cg_tbl_sellers_subscription_id_fkey` FOREIGN KEY (`subscription_id`) REFERENCES `cg_tbl_subscription_plans`(`id`) ON DELETE NO ACTION ON UPDATE NO ACTION;

-- AddForeignKey
ALTER TABLE `cg_tbl_user_addresses` ADD CONSTRAINT `cg_tbl_user_addresses_role_id_fkey` FOREIGN KEY (`role_id`) REFERENCES `cg_tbl_user_roles`(`id`) ON DELETE NO ACTION ON UPDATE NO ACTION;

-- AddForeignKey
ALTER TABLE `cg_tbl_coupons` ADD CONSTRAINT `cg_tbl_coupons_vendor_id_fkey` FOREIGN KEY (`vendor_id`) REFERENCES `cg_tbl_sellers`(`id`) ON DELETE NO ACTION ON UPDATE NO ACTION;

-- AddForeignKey
ALTER TABLE `cg_tbl_admin_users` ADD CONSTRAINT `cg_tbl_admin_users_role_id_fkey` FOREIGN KEY (`role_id`) REFERENCES `cg_tbl_admin_roles`(`id`) ON DELETE NO ACTION ON UPDATE NO ACTION;

-- AddForeignKey
ALTER TABLE `cg_table_tutorials` ADD CONSTRAINT `cg_table_tutorials_role_id_fkey` FOREIGN KEY (`role_id`) REFERENCES `cg_tbl_user_roles`(`id`) ON DELETE NO ACTION ON UPDATE NO ACTION;

-- AddForeignKey
ALTER TABLE `cg_tbl_category_sub_category_setup` ADD CONSTRAINT `cg_tbl_category_sub_category_setup_category_id_fkey` FOREIGN KEY (`category_id`) REFERENCES `cg_tbl_categories`(`id`) ON DELETE CASCADE ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE `cg_tbl_category_sub_category_setup` ADD CONSTRAINT `cg_tbl_category_sub_category_setup_sub_category_id_fkey` FOREIGN KEY (`sub_category_id`) REFERENCES `cg_tbl_sub_categories`(`id`) ON DELETE CASCADE ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE `cg_tbl_category_sub_category_setup` ADD CONSTRAINT `cg_tbl_category_sub_category_setup_role_id_fkey` FOREIGN KEY (`role_id`) REFERENCES `cg_tbl_user_roles`(`id`) ON DELETE CASCADE ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE `cg_tbl_category_sub_category_setup` ADD CONSTRAINT `cg_tbl_category_sub_category_setup_vehicle_class_id_fkey` FOREIGN KEY (`vehicle_class_id`) REFERENCES `cg_tbl_vehicle_classes`(`id`) ON DELETE CASCADE ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE `cg_tbl_category_sub_category_setup` ADD CONSTRAINT `cg_tbl_category_sub_category_setup_vehicle_fuel_type_id_fkey` FOREIGN KEY (`vehicle_fuel_type_id`) REFERENCES `cg_tbl_vehicle_fuel_types`(`id`) ON DELETE CASCADE ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE `cg_tbl_rattings_reason` ADD CONSTRAINT `cg_tbl_rattings_reason_app_name_fkey` FOREIGN KEY (`app_name`) REFERENCES `cg_tbl_user_roles`(`id`) ON DELETE CASCADE ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE `cg_tbl_skill_set` ADD CONSTRAINT `cg_tbl_skill_set_user_role_fkey` FOREIGN KEY (`user_role`) REFERENCES `cg_tbl_user_roles`(`id`) ON DELETE SET NULL ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE `cg_tbl_service_reason` ADD CONSTRAINT `cg_tbl_service_reason_category_id_fkey` FOREIGN KEY (`category_id`) REFERENCES `cg_tbl_categories`(`id`) ON DELETE CASCADE ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE `cg_tbl_banners` ADD CONSTRAINT `cg_tbl_banners_zone_id_fkey` FOREIGN KEY (`zone_id`) REFERENCES `cg_tbl_zones`(`id`) ON DELETE CASCADE ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE `cg_tbl_advertisements` ADD CONSTRAINT `cg_tbl_advertisements_zone_id_fkey` FOREIGN KEY (`zone_id`) REFERENCES `cg_tbl_zones`(`id`) ON DELETE CASCADE ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE `cg_tbl_advertisements` ADD CONSTRAINT `cg_tbl_advertisements_user_role_id_fkey` FOREIGN KEY (`user_role_id`) REFERENCES `cg_tbl_user_roles`(`id`) ON DELETE CASCADE ON UPDATE NO ACTION;

-- AddForeignKey
ALTER TABLE `cg_tbl_gig_modification_reason` ADD CONSTRAINT `cg_tbl_gig_modification_reason_category_id_fkey` FOREIGN KEY (`category_id`) REFERENCES `cg_tbl_categories`(`id`) ON DELETE CASCADE ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE `cg_tbl_profile_update_requests` ADD CONSTRAINT `cg_tbl_profile_update_requests_user_role_id_fkey` FOREIGN KEY (`user_role_id`) REFERENCES `cg_tbl_user_roles`(`id`) ON DELETE NO ACTION ON UPDATE NO ACTION;

-- AddForeignKey
ALTER TABLE `cg_tbl_towing_service` ADD CONSTRAINT `cg_tbl_towing_service_created_by_fkey` FOREIGN KEY (`created_by`) REFERENCES `cg_tbl_admin_users`(`id`) ON DELETE NO ACTION ON UPDATE NO ACTION;

-- AddForeignKey
ALTER TABLE `cg_tbl_helper_pricing` ADD CONSTRAINT `cg_tbl_helper_pricing_gst_percentage_id_fkey` FOREIGN KEY (`gst_percentage_id`) REFERENCES `cg_tbl_tax_setups`(`id`) ON DELETE NO ACTION ON UPDATE NO ACTION;

-- AddForeignKey
ALTER TABLE `cg_tbl_cancellation_reasons` ADD CONSTRAINT `cg_tbl_cancellation_reasons_app_id_fkey` FOREIGN KEY (`app_id`) REFERENCES `cg_tbl_user_roles`(`id`) ON DELETE CASCADE ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE `cg_tbl_vehicles_master` ADD CONSTRAINT `cg_tbl_vehicles_master_user_role_id_fkey` FOREIGN KEY (`user_role_id`) REFERENCES `cg_tbl_user_roles`(`id`) ON DELETE NO ACTION ON UPDATE NO ACTION;

-- AddForeignKey
ALTER TABLE `cg_tbl_vehicles_master` ADD CONSTRAINT `cg_tbl_vehicles_master_vehicle_class_id_fkey` FOREIGN KEY (`vehicle_class_id`) REFERENCES `cg_tbl_vehicle_classes`(`id`) ON DELETE NO ACTION ON UPDATE NO ACTION;

-- AddForeignKey
ALTER TABLE `cg_tbl_vehicles_master` ADD CONSTRAINT `cg_tbl_vehicles_master_vehicle_fuel_type_id_fkey` FOREIGN KEY (`vehicle_fuel_type_id`) REFERENCES `cg_tbl_vehicle_fuel_types`(`id`) ON DELETE NO ACTION ON UPDATE NO ACTION;
