-- phpMyAdmin SQL Dump
-- version 5.2.2
-- https://www.phpmyadmin.net/
--
-- Host: localhost:3306
-- Generation Time: Feb 09, 2026 at 09:28 AM
-- Server version: 8.0.45
-- PHP Version: 8.4.17

SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
START TRANSACTION;
SET time_zone = "+00:00";


/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8mb4 */;

--
-- Database: `carbuylv_main`
--

-- --------------------------------------------------------

--
-- Table structure for table `admin_users`
--

CREATE TABLE `admin_users` (
  `id` int NOT NULL,
  `name` varchar(255) NOT NULL,
  `surname` varchar(255) NOT NULL,
  `username` varchar(255) NOT NULL,
  `password` varchar(255) NOT NULL,
  `created` int NOT NULL,
  `email` varchar(255) NOT NULL,
  `status` int NOT NULL,
  `userlevel` int NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3;

-- --------------------------------------------------------

--
-- Table structure for table `ap_makes`
--

CREATE TABLE `ap_makes` (
  `id` int NOT NULL,
  `ap_id` int NOT NULL,
  `make` varchar(255) NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb3;

-- --------------------------------------------------------

--
-- Table structure for table `ap_models`
--

CREATE TABLE `ap_models` (
  `id` int NOT NULL,
  `ap_id` int NOT NULL,
  `make_id` int NOT NULL,
  `model` varchar(255) NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb3;

-- --------------------------------------------------------

--
-- Table structure for table `awards`
--

CREATE TABLE `awards` (
  `id` int NOT NULL,
  `name` varchar(255) NOT NULL,
  `total_count` int DEFAULT NULL,
  `found_count` int DEFAULT '0',
  `created` int DEFAULT NULL,
  `status` int DEFAULT '0'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3;

-- --------------------------------------------------------

--
-- Table structure for table `awards_found`
--

CREATE TABLE `awards_found` (
  `id` int NOT NULL,
  `awards_id` int NOT NULL,
  `phone` varchar(255) NOT NULL,
  `created` int NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3;

-- --------------------------------------------------------

--
-- Table structure for table `banner`
--

CREATE TABLE `banner` (
  `id` int UNSIGNED NOT NULL,
  `link` text,
  `src` text NOT NULL,
  `sort_order` int UNSIGNED NOT NULL,
  `opens` varchar(10) NOT NULL,
  `position` varchar(10) NOT NULL,
  `user_id` int NOT NULL,
  `banner_status` int UNSIGNED NOT NULL,
  `created` int NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3;

-- --------------------------------------------------------

--
-- Table structure for table `blocks`
--

CREATE TABLE `blocks` (
  `id` int NOT NULL,
  `title` varchar(255) NOT NULL,
  `content` text NOT NULL,
  `button_url` varchar(255) NOT NULL,
  `button_title` varchar(255) NOT NULL,
  `position` varchar(255) NOT NULL,
  `image` varchar(255) NOT NULL,
  `sys_lang_id` int NOT NULL,
  `status` int NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3;

-- --------------------------------------------------------

--
-- Table structure for table `buy`
--

CREATE TABLE `buy` (
  `id` int NOT NULL,
  `nr` int NOT NULL DEFAULT '0',
  `client_id` int NOT NULL,
  `car_id` int NOT NULL,
  `price` double(10,2) NOT NULL DEFAULT '0.00',
  `expenses` double(10,2) NOT NULL DEFAULT '0.00',
  `payment_type` varchar(255) NOT NULL DEFAULT '',
  `cash` double(10,2) NOT NULL DEFAULT '0.00',
  `transfer` double(10,2) NOT NULL DEFAULT '0.00',
  `pvn` enum('0','1') NOT NULL DEFAULT '0',
  `order_id` int NOT NULL,
  `user_id` int NOT NULL,
  `comm` int NOT NULL DEFAULT '0',
  `ref_from` text NOT NULL,
  `created` int NOT NULL,
  `comment` text NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3;

-- --------------------------------------------------------

--
-- Table structure for table `buy_offers`
--

CREATE TABLE `buy_offers` (
  `id` int NOT NULL,
  `name` varchar(255) NOT NULL,
  `email` varchar(255) NOT NULL,
  `make` varchar(255) NOT NULL,
  `year` varchar(255) NOT NULL,
  `fuel_type` varchar(255) NOT NULL,
  `gearbox` varchar(200) NOT NULL,
  `comment` text NOT NULL,
  `phone` varchar(255) NOT NULL,
  `created` int NOT NULL,
  `where_from` text NOT NULL,
  `contact_phone` int NOT NULL DEFAULT '0',
  `contact_email` int NOT NULL DEFAULT '0',
  `images` text NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3;

-- --------------------------------------------------------

--
-- Table structure for table `calendar_events`
--

CREATE TABLE `calendar_events` (
  `id` int NOT NULL,
  `title` varchar(255) NOT NULL,
  `description` text NOT NULL,
  `event_start` int NOT NULL,
  `event_end` int NOT NULL,
  `leasing_id` int NOT NULL,
  `leasing_name` varchar(255) NOT NULL,
  `user` varchar(255) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3;

-- --------------------------------------------------------

--
-- Table structure for table `call_log`
--

CREATE TABLE `call_log` (
  `id` int NOT NULL,
  `type` varchar(20) NOT NULL,
  `eventType` varchar(20) NOT NULL,
  `version` varchar(10) NOT NULL,
  `callID` int NOT NULL,
  `caller` varchar(20) NOT NULL,
  `destination` varchar(20) NOT NULL,
  `status` int NOT NULL,
  `callStarted` varchar(100) NOT NULL,
  `callConnected` varchar(100) NOT NULL,
  `callEnded` varchar(100) NOT NULL,
  `contactID` int NOT NULL,
  `direction` varchar(10) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3;

-- --------------------------------------------------------

--
-- Table structure for table `cars`
--

CREATE TABLE `cars` (
  `id` int NOT NULL,
  `keycount` varchar(10) NOT NULL DEFAULT '1',
  `autotev_id` int NOT NULL DEFAULT '0',
  `iauto` int NOT NULL,
  `spa_id` int NOT NULL,
  `spa_status` int NOT NULL,
  `ssid` int NOT NULL,
  `sslv` int NOT NULL DEFAULT '0',
  `ss_ok` int DEFAULT '0',
  `fbid` varchar(255) NOT NULL,
  `fb_cat_id` varchar(255) NOT NULL,
  `tid` int DEFAULT NULL,
  `draugiemid` int NOT NULL,
  `user_id` int NOT NULL DEFAULT '0',
  `make` varchar(255) NOT NULL,
  `model` varchar(255) NOT NULL,
  `v_type` varchar(255) NOT NULL,
  `manufacturer_id` int NOT NULL,
  `model_id` int NOT NULL,
  `generation_id` int NOT NULL,
  `engine_id` int NOT NULL,
  `month` int NOT NULL,
  `year` int NOT NULL,
  `ta_month` int NOT NULL,
  `ta_year` int NOT NULL,
  `engine` double(4,2) NOT NULL,
  `engine_type` varchar(255) NOT NULL,
  `kw` int NOT NULL DEFAULT '0',
  `color` varchar(255) NOT NULL,
  `seats` int NOT NULL,
  `mileage` int NOT NULL,
  `type` varchar(255) NOT NULL,
  `gearbox` varchar(255) NOT NULL,
  `vin` varchar(255) NOT NULL,
  `plate` varchar(255) NOT NULL,
  `reg_id_nr` varchar(15) NOT NULL,
  `in_commission` int NOT NULL DEFAULT '0',
  `pvn` int NOT NULL DEFAULT '0',
  `damaged` int NOT NULL DEFAULT '0',
  `price` double(12,2) NOT NULL,
  `new_price` double(12,2) NOT NULL,
  `keynr` int NOT NULL DEFAULT '0',
  `keynr_old` int NOT NULL DEFAULT '0',
  `price_leasing` double(7,2) NOT NULL,
  `buy_price` decimal(10,2) NOT NULL DEFAULT '0.00',
  `sell_price` double(10,2) NOT NULL DEFAULT '0.00',
  `comm_price_1` double(10,2) NOT NULL DEFAULT '0.00',
  `comm_price_2` double(10,2) NOT NULL DEFAULT '0.00',
  `description_lv` text NOT NULL,
  `description_ru` text NOT NULL,
  `description_en` text NOT NULL,
  `sspretext` text NOT NULL,
  `freefuel` int NOT NULL DEFAULT '0',
  `freeocta` int NOT NULL DEFAULT '0',
  `freeall` int NOT NULL DEFAULT '0',
  `opt1` text NOT NULL,
  `opt2` text NOT NULL,
  `opt3` text NOT NULL,
  `opt4` text NOT NULL,
  `opt5` text NOT NULL,
  `opt6` text NOT NULL,
  `opt7` text NOT NULL,
  `opt8` text NOT NULL,
  `plink` varchar(255) NOT NULL,
  `status` int NOT NULL DEFAULT '0',
  `lt` int NOT NULL DEFAULT '0',
  `sold` int NOT NULL DEFAULT '0',
  `sold_by` varchar(20) NOT NULL,
  `sold_where` text NOT NULL,
  `sold_time` int NOT NULL,
  `nothere` int NOT NULL DEFAULT '0',
  `clientcar` int NOT NULL DEFAULT '0',
  `client_id` int NOT NULL DEFAULT '0',
  `client_status` int NOT NULL DEFAULT '0',
  `sms_id` int NOT NULL,
  `internal_id` int NOT NULL DEFAULT '0',
  `in_xml` int NOT NULL DEFAULT '0',
  `xml_found` int NOT NULL DEFAULT '0',
  `location` varchar(255) NOT NULL,
  `calls_owner` int NOT NULL DEFAULT '0',
  `calls_lease` int NOT NULL DEFAULT '0',
  `app_lease` int NOT NULL DEFAULT '0',
  `views` int NOT NULL DEFAULT '0',
  `thumbnail` varchar(255) NOT NULL,
  `created` int NOT NULL,
  `nowatermark` int NOT NULL DEFAULT '0',
  `returned` int NOT NULL DEFAULT '0',
  `last_edit` int NOT NULL DEFAULT '0',
  `last_sync` int NOT NULL DEFAULT '0',
  `published` int NOT NULL,
  `deleted` int NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3;

-- --------------------------------------------------------

--
-- Table structure for table `cars_images`
--

CREATE TABLE `cars_images` (
  `id` int NOT NULL,
  `car_id` int NOT NULL,
  `src` varchar(255) NOT NULL,
  `sort_order` int NOT NULL DEFAULT '0'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3;

-- --------------------------------------------------------

--
-- Table structure for table `car_call_events`
--

CREATE TABLE `car_call_events` (
  `id` int NOT NULL,
  `car_id` int NOT NULL,
  `event_type` varchar(50) NOT NULL,
  `event_time` timestamp NULL DEFAULT CURRENT_TIMESTAMP
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3;

-- --------------------------------------------------------

--
-- Table structure for table `car_data`
--

CREATE TABLE `car_data` (
  `id` int NOT NULL,
  `rn` varchar(50) COLLATE utf8mb3_unicode_ci DEFAULT NULL,
  `vin` varchar(50) COLLATE utf8mb3_unicode_ci DEFAULT NULL,
  `marka` varchar(50) COLLATE utf8mb3_unicode_ci DEFAULT NULL,
  `modelis` varchar(50) COLLATE utf8mb3_unicode_ci DEFAULT NULL,
  `gads` int DEFAULT NULL,
  `degviela` varchar(50) COLLATE utf8mb3_unicode_ci DEFAULT NULL,
  `jauda` int DEFAULT NULL,
  `elektro_jauda` int DEFAULT NULL,
  `elektro_jauda2` int DEFAULT NULL,
  `tilpums` int DEFAULT NULL,
  `reg1` int DEFAULT NULL,
  `krasa` varchar(50) COLLATE utf8mb3_unicode_ci DEFAULT NULL,
  `tl_veids` varchar(50) COLLATE utf8mb3_unicode_ci DEFAULT NULL,
  `coc_kategorija` varchar(50) COLLATE utf8mb3_unicode_ci DEFAULT NULL,
  `coc_tips` varchar(50) COLLATE utf8mb3_unicode_ci DEFAULT NULL,
  `coc_tehn_apst_num` varchar(100) COLLATE utf8mb3_unicode_ci DEFAULT NULL,
  `coc_variants` varchar(50) COLLATE utf8mb3_unicode_ci DEFAULT NULL,
  `coc_versija` varchar(50) COLLATE utf8mb3_unicode_ci DEFAULT NULL,
  `pilna_masa` int DEFAULT NULL,
  `pasmasa` int DEFAULT NULL,
  `pol_beigas` int DEFAULT NULL,
  `ta_lidz` int DEFAULT NULL,
  `last_fetch` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;

-- --------------------------------------------------------

--
-- Table structure for table `car_history`
--

CREATE TABLE `car_history` (
  `id` int NOT NULL,
  `car_id` int NOT NULL,
  `make` varchar(255) COLLATE utf8mb3_unicode_ci DEFAULT NULL,
  `model` varchar(255) COLLATE utf8mb3_unicode_ci DEFAULT NULL,
  `year` int NOT NULL,
  `price` decimal(10,2) DEFAULT NULL,
  `date` datetime DEFAULT CURRENT_TIMESTAMP,
  `vin` varchar(50) COLLATE utf8mb3_unicode_ci DEFAULT NULL,
  `plate` varchar(50) COLLATE utf8mb3_unicode_ci DEFAULT NULL,
  `mileage` int DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;

-- --------------------------------------------------------

--
-- Table structure for table `car_shares`
--

CREATE TABLE `car_shares` (
  `id` int NOT NULL,
  `car_id` int NOT NULL,
  `social` varchar(255) NOT NULL,
  `count` int NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3;

-- --------------------------------------------------------

--
-- Table structure for table `category`
--

CREATE TABLE `category` (
  `id` int UNSIGNED NOT NULL,
  `sys_lang_id` int UNSIGNED NOT NULL,
  `sys_template_id` int UNSIGNED NOT NULL,
  `parent_id` int UNSIGNED DEFAULT NULL,
  `name` text NOT NULL,
  `plink` text NOT NULL,
  `page_title` text NOT NULL,
  `meta_descr` text NOT NULL,
  `meta_keywords` text NOT NULL,
  `pic_path` text,
  `sort_order` int UNSIGNED NOT NULL DEFAULT '0',
  `depth` int UNSIGNED NOT NULL DEFAULT '0',
  `has_page_text` int UNSIGNED NOT NULL DEFAULT '0',
  `is_main_menu` int UNSIGNED NOT NULL DEFAULT '0',
  `category_status` int UNSIGNED NOT NULL DEFAULT '0',
  `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `requires_login` int NOT NULL DEFAULT '0',
  `bottom_menu` int NOT NULL DEFAULT '0',
  `top_menu` int NOT NULL DEFAULT '0',
  `first_page` int NOT NULL DEFAULT '0'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3;

-- --------------------------------------------------------

--
-- Table structure for table `cat_engine`
--

CREATE TABLE `cat_engine` (
  `engine_id` int NOT NULL,
  `name` varchar(255) DEFAULT NULL,
  `slug` varchar(255) DEFAULT NULL,
  `year` int DEFAULT NULL,
  `type` varchar(255) DEFAULT NULL,
  `cylinders` int DEFAULT NULL,
  `capacity` int DEFAULT NULL,
  `engineCode` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT NULL,
  `ecu` varchar(255) DEFAULT NULL,
  `fuelName` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT NULL,
  `powerHP` int NOT NULL,
  `powerKW` int NOT NULL,
  `torqueNm` int NOT NULL,
  `torqueFtlb` int NOT NULL,
  `generation_id` int DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3;

-- --------------------------------------------------------

--
-- Table structure for table `cat_generation`
--

CREATE TABLE `cat_generation` (
  `generation_id` int NOT NULL,
  `name` varchar(255) DEFAULT NULL,
  `slug` varchar(255) DEFAULT NULL,
  `year` int DEFAULT NULL,
  `yearEnd` int DEFAULT NULL,
  `model_id` int DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3;

-- --------------------------------------------------------

--
-- Table structure for table `cat_manufacturer`
--

CREATE TABLE `cat_manufacturer` (
  `manufacturer_id` int NOT NULL,
  `name` varchar(255) DEFAULT NULL,
  `slug` varchar(255) DEFAULT NULL,
  `type` varchar(15) NOT NULL,
  `count` int NOT NULL,
  `cb_count` int NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3;

-- --------------------------------------------------------

--
-- Table structure for table `cat_model`
--

CREATE TABLE `cat_model` (
  `model_id` int NOT NULL,
  `name` varchar(255) DEFAULT NULL,
  `slug` varchar(255) DEFAULT NULL,
  `manufacturer_id` int DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3;

-- --------------------------------------------------------

--
-- Table structure for table `ci_sessions`
--

CREATE TABLE `ci_sessions` (
  `session_id` varchar(40) NOT NULL DEFAULT '0',
  `ip_address` varchar(16) NOT NULL DEFAULT '0',
  `user_agent` varchar(50) NOT NULL,
  `last_activity` int UNSIGNED NOT NULL DEFAULT '0',
  `user_data` text NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3;

-- --------------------------------------------------------

--
-- Table structure for table `clients`
--

CREATE TABLE `clients` (
  `id` int NOT NULL,
  `client_type` varchar(255) NOT NULL,
  `name` varchar(255) NOT NULL,
  `clientid` varchar(255) NOT NULL,
  `code` varchar(15) NOT NULL,
  `company_name` varchar(255) NOT NULL,
  `company_id` varchar(255) NOT NULL,
  `company_vat` varchar(255) NOT NULL,
  `company_bank` text NOT NULL,
  `bank_account` varchar(21) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL,
  `phone` varchar(255) NOT NULL,
  `address` text NOT NULL,
  `document` varchar(255) NOT NULL,
  `documentnr` varchar(255) NOT NULL,
  `documentplace` varchar(255) NOT NULL,
  `email` varchar(255) NOT NULL,
  `created` int NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3;

-- --------------------------------------------------------

--
-- Table structure for table `commisions`
--

CREATE TABLE `commisions` (
  `id` int NOT NULL,
  `nr` int NOT NULL DEFAULT '0',
  `client_id` int NOT NULL,
  `car_id` int NOT NULL,
  `price_1` double(10,2) NOT NULL,
  `price_2` double(10,2) NOT NULL,
  `price_3` double(10,2) NOT NULL,
  `desired_price` float(10,2) NOT NULL DEFAULT '0.00',
  `commision` varchar(255) NOT NULL,
  `user_id` int NOT NULL,
  `created` int NOT NULL,
  `paid` int NOT NULL DEFAULT '0',
  `returned` int NOT NULL DEFAULT '0'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3;

-- --------------------------------------------------------

--
-- Table structure for table `defective_cars`
--

CREATE TABLE `defective_cars` (
  `id` int NOT NULL,
  `car_id` int NOT NULL,
  `user_id` int NOT NULL,
  `user_name` varchar(255) NOT NULL,
  `message` text NOT NULL,
  `price` float(10,2) NOT NULL,
  `price_real` float(10,2) NOT NULL,
  `service_status` int NOT NULL DEFAULT '0',
  `service_name` varchar(255) NOT NULL,
  `created` int NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3;

-- --------------------------------------------------------

--
-- Table structure for table `expenses`
--

CREATE TABLE `expenses` (
  `id` int NOT NULL,
  `purpose` text NOT NULL,
  `comment` text NOT NULL,
  `total` float(10,2) NOT NULL,
  `created` int NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb3;

-- --------------------------------------------------------

--
-- Table structure for table `invoices`
--

CREATE TABLE `invoices` (
  `id` int NOT NULL,
  `client_id` int NOT NULL,
  `client_name` varchar(255) NOT NULL,
  `invoice_number` varchar(255) NOT NULL,
  `amount` decimal(10,2) NOT NULL,
  `vat` int NOT NULL DEFAULT '1',
  `date` int NOT NULL,
  `created_at` int NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3;

-- --------------------------------------------------------

--
-- Table structure for table `key_numbers`
--

CREATE TABLE `key_numbers` (
  `id` int NOT NULL,
  `number` int NOT NULL,
  `carid` int NOT NULL DEFAULT '0'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3;

-- --------------------------------------------------------

--
-- Table structure for table `last_bill`
--

CREATE TABLE `last_bill` (
  `id` int NOT NULL,
  `nr` int NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb3;

-- --------------------------------------------------------

--
-- Table structure for table `leasing_check`
--

CREATE TABLE `leasing_check` (
  `id` int NOT NULL,
  `car_id` int NOT NULL,
  `car_name` varchar(255) NOT NULL,
  `name` varchar(255) NOT NULL,
  `phone` varchar(255) NOT NULL,
  `email` varchar(255) NOT NULL,
  `personalcode` varchar(255) NOT NULL,
  `language` varchar(10) NOT NULL DEFAULT '',
  `type` varchar(15) NOT NULL DEFAULT 'old',
  `sallary` double(10,2) NOT NULL DEFAULT '0.00',
  `created` int NOT NULL,
  `ads` enum('0','1') NOT NULL DEFAULT '0',
  `agree` enum('0','1') NOT NULL DEFAULT '0',
  `referral` varchar(255) NOT NULL,
  `reviewed` int NOT NULL DEFAULT '0',
  `ip` varchar(255) NOT NULL DEFAULT ''
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3;

-- --------------------------------------------------------

--
-- Table structure for table `leasing_check_comments`
--

CREATE TABLE `leasing_check_comments` (
  `id` int NOT NULL,
  `leasing_id` int NOT NULL,
  `user_id` int NOT NULL,
  `user_name` varchar(255) NOT NULL,
  `comment` text NOT NULL,
  `created` int NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3;

-- --------------------------------------------------------

--
-- Table structure for table `leasing_profiles`
--

CREATE TABLE `leasing_profiles` (
  `id` int NOT NULL,
  `client_id` int NOT NULL DEFAULT '0',
  `telegramId` bigint NOT NULL,
  `leasing_id` int NOT NULL,
  `inbank_id` varchar(255) NOT NULL,
  `bigbank_id` varchar(255) NOT NULL,
  `tfbank_id` varchar(255) NOT NULL DEFAULT '',
  `tf_push` text NOT NULL,
  `tfbank_nobas_id` varchar(255) NOT NULL,
  `tfbank_nobas_status` varchar(255) NOT NULL,
  `aizdevums_id` varchar(255) NOT NULL DEFAULT '',
  `incredit_id` varchar(255) NOT NULL DEFAULT '',
  `mogo_id` varchar(255) NOT NULL,
  `mc_id` int NOT NULL DEFAULT '0',
  `inbank_status` text NOT NULL,
  `bigbank_status` text NOT NULL,
  `mogo_status` text NOT NULL,
  `incredit_status` text NOT NULL,
  `aizdevums_status` text NOT NULL,
  `holm_id` varchar(255) NOT NULL,
  `holm_status` varchar(255) NOT NULL,
  `holm_status_readable` text NOT NULL,
  `holm_status_comment` text NOT NULL,
  `blender_id` varchar(255) NOT NULL,
  `blender_status` varchar(255) NOT NULL,
  `blender_comment` text NOT NULL,
  `finto_id` varchar(255) NOT NULL,
  `finto_status` varchar(255) NOT NULL,
  `elats_id` varchar(255) NOT NULL,
  `elats_status` varchar(255) NOT NULL,
  `elats_comment` text NOT NULL,
  `delfin_id` varchar(255) NOT NULL,
  `delfin_client_id` varchar(255) NOT NULL,
  `delfin_status` text NOT NULL,
  `banknote_id` varchar(255) NOT NULL,
  `banknote_client_id` varchar(255) NOT NULL,
  `banknote_status` text NOT NULL,
  `nord_id` varchar(255) NOT NULL,
  `nord_message` text NOT NULL,
  `nord_status` int NOT NULL,
  `nordigen` varchar(255) NOT NULL,
  `nordigen_loaded` int NOT NULL DEFAULT '0',
  `nordigen_accounts` text NOT NULL,
  `ava_ref` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL,
  `ava_id` int NOT NULL,
  `ava_status` int NOT NULL,
  `sefinance_id` int DEFAULT NULL,
  `sefinance_status` varchar(255) NOT NULL,
  `finea_id` varchar(40) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL,
  `creditmind_id` int DEFAULT NULL,
  `creditmind_lead_id` int DEFAULT NULL,
  `creditmind_company_id` int DEFAULT NULL,
  `creditmind_status` varchar(50) DEFAULT NULL,
  `finea_status` text NOT NULL,
  `name` varchar(255) NOT NULL,
  `surname` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL DEFAULT '',
  `language` varchar(255) NOT NULL,
  `gender` varchar(255) NOT NULL,
  `personalcode` varchar(15) NOT NULL,
  `bdate` int NOT NULL,
  `phone` varchar(255) NOT NULL,
  `email` varchar(255) NOT NULL,
  `address` varchar(255) NOT NULL,
  `address2` varchar(255) NOT NULL,
  `district` varchar(255) NOT NULL,
  `city` varchar(255) NOT NULL,
  `street` varchar(255) NOT NULL,
  `house_number` varchar(255) NOT NULL,
  `flat_number` varchar(255) NOT NULL,
  `post_index` varchar(255) NOT NULL,
  `district2` varchar(255) NOT NULL,
  `city2` varchar(255) NOT NULL,
  `street2` varchar(255) NOT NULL,
  `house_number2` varchar(255) NOT NULL,
  `flat_number2` varchar(255) NOT NULL,
  `post_index2` varchar(255) NOT NULL,
  `address_id` varchar(255) NOT NULL,
  `drivers_licence` varchar(255) NOT NULL,
  `document_nr` varchar(255) NOT NULL,
  `document_type` varchar(255) NOT NULL,
  `document_valid` varchar(255) NOT NULL,
  `account` varchar(255) NOT NULL,
  `workplace` varchar(255) NOT NULL,
  `experience` int NOT NULL,
  `position` varchar(255) NOT NULL,
  `income` double(10,2) NOT NULL,
  `total_income` double(10,2) NOT NULL,
  `other_expenses` varchar(255) NOT NULL,
  `friend_name` varchar(255) NOT NULL,
  `car_id` int NOT NULL,
  `model` varchar(255) NOT NULL,
  `external_id` int NOT NULL,
  `source` varchar(255) NOT NULL,
  `total_price` double(10,2) NOT NULL,
  `term` int NOT NULL DEFAULT '60',
  `best_date` int NOT NULL DEFAULT '20',
  `bank` varchar(255) NOT NULL,
  `pep` enum('0','1','') NOT NULL DEFAULT '0',
  `maritalStatus` enum('MARRIED','DIVORCED','SINGLE','WIDOW','COHABITING') CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL DEFAULT 'COHABITING',
  `residenceType` enum('PRIVATE_APARTMENT','PRIVATE_HOUSE','RENTAL_PREMISES','LIVING_WITH_PARENTS','OTHER') NOT NULL DEFAULT 'PRIVATE_APARTMENT',
  `residenceType2` enum('PRIVATE_APARTMENT','PRIVATE_HOUSE','RENTAL_PREMISES','LIVING_WITH_PARENTS','OTHER') NOT NULL DEFAULT 'PRIVATE_APARTMENT',
  `education` enum('BASIC','SECONDARY','SECONDARY_SPECIALISED','HIGHER') NOT NULL DEFAULT 'SECONDARY',
  `declaredIncomeType` enum('SALARY','PENSION') NOT NULL DEFAULT 'SALARY',
  `dependents` enum('0','1','2','3','4','5','6','7','8','9','10_OR_MORE','') NOT NULL DEFAULT '0',
  `citizenCountryCodes` enum('LV','XA','OTHER') NOT NULL DEFAULT 'LV',
  `workingAbroad` int NOT NULL DEFAULT '0',
  `created` int NOT NULL,
  `last_edit` int NOT NULL,
  `created_by_user_id` int NOT NULL,
  `created_by_username` varchar(255) NOT NULL,
  `leasing_1` int NOT NULL DEFAULT '0',
  `leasing_2` int NOT NULL DEFAULT '0',
  `leasing_3` int NOT NULL DEFAULT '0',
  `leasing_4` int NOT NULL DEFAULT '0',
  `leasing_5` int NOT NULL DEFAULT '0',
  `leasing_6` int NOT NULL DEFAULT '0',
  `leasing_7` int NOT NULL DEFAULT '0',
  `leasing_8` int NOT NULL DEFAULT '0',
  `bad_history` int NOT NULL DEFAULT '0',
  `lease_ammount` float(10,2) NOT NULL,
  `lease_company` varchar(255) NOT NULL,
  `lease_closed` int NOT NULL DEFAULT '0',
  `lease_other` int NOT NULL DEFAULT '0',
  `agree` enum('0','1') NOT NULL DEFAULT '0',
  `ads` enum('0','1') NOT NULL DEFAULT '0',
  `ip` varchar(255) NOT NULL DEFAULT '127.0.0.1',
  `statement` text NOT NULL,
  `status` int NOT NULL DEFAULT '0',
  `referral` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL DEFAULT '',
  `archived` int NOT NULL DEFAULT '0',
  `sefinance_uid` varchar(255) DEFAULT NULL,
  `sefinance_submitted_at` datetime DEFAULT NULL,
  `car_url` text NOT NULL,
  `app_progress` varchar(100) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3;

-- --------------------------------------------------------

--
-- Table structure for table `leasing_profiles_agreements`
--

CREATE TABLE `leasing_profiles_agreements` (
  `id` int NOT NULL,
  `institution_id` varchar(255) COLLATE utf8mb3_unicode_ci NOT NULL,
  `bankName` varchar(255) COLLATE utf8mb3_unicode_ci NOT NULL,
  `leasing_id` int NOT NULL,
  `reference` varchar(255) COLLATE utf8mb3_unicode_ci NOT NULL,
  `requisition_id` varchar(255) COLLATE utf8mb3_unicode_ci NOT NULL,
  `accounts` text COLLATE utf8mb3_unicode_ci NOT NULL,
  `status` varchar(255) COLLATE utf8mb3_unicode_ci NOT NULL,
  `iban` varchar(1024) CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci NOT NULL,
  `created_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;

-- --------------------------------------------------------

--
-- Table structure for table `leasing_profile_comments`
--

CREATE TABLE `leasing_profile_comments` (
  `id` int NOT NULL,
  `profile_id` int NOT NULL,
  `user_id` int NOT NULL,
  `user_name` varchar(255) NOT NULL,
  `comment` text NOT NULL,
  `created` int NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3;

-- --------------------------------------------------------

--
-- Table structure for table `leasing_sms_log`
--

CREATE TABLE `leasing_sms_log` (
  `id` int NOT NULL,
  `leasing_id` int NOT NULL,
  `sms_id` int NOT NULL,
  `text` text NOT NULL,
  `nr` varchar(255) NOT NULL,
  `time` int NOT NULL,
  `status` varchar(15) NOT NULL DEFAULT '0',
  `user` varchar(255) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3;

-- --------------------------------------------------------

--
-- Table structure for table `makes`
--

CREATE TABLE `makes` (
  `id` int NOT NULL,
  `ap_id` int NOT NULL,
  `name` varchar(255) NOT NULL,
  `slug` varchar(255) NOT NULL,
  `type` varchar(255) NOT NULL,
  `status` int NOT NULL DEFAULT '1'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3;

-- --------------------------------------------------------

--
-- Table structure for table `merc_location`
--

CREATE TABLE `merc_location` (
  `id` int NOT NULL,
  `lat` text NOT NULL,
  `lng` text NOT NULL,
  `speed` text NOT NULL,
  `direction` text NOT NULL,
  `altitude` text NOT NULL,
  `gmt` text NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3;

-- --------------------------------------------------------

--
-- Table structure for table `models`
--

CREATE TABLE `models` (
  `id` int NOT NULL,
  `ap_id` int NOT NULL,
  `name` varchar(255) NOT NULL,
  `slug` varchar(255) NOT NULL,
  `make_id` int NOT NULL,
  `status` int NOT NULL DEFAULT '1'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3;

-- --------------------------------------------------------

--
-- Table structure for table `options`
--

CREATE TABLE `options` (
  `id` int NOT NULL,
  `where` varchar(255) NOT NULL,
  `standart` varchar(255) NOT NULL,
  `limit` varchar(255) NOT NULL,
  `overprice` varchar(255) NOT NULL,
  `sys_lang_id` int NOT NULL DEFAULT '1',
  `status` int NOT NULL DEFAULT '1',
  `sort_order` int NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3;

-- --------------------------------------------------------

--
-- Table structure for table `orders`
--

CREATE TABLE `orders` (
  `id` int NOT NULL,
  `type` varchar(255) NOT NULL,
  `nr` int NOT NULL,
  `created` int NOT NULL,
  `client_id` int NOT NULL,
  `client_name` varchar(255) NOT NULL,
  `client_identification` varchar(255) NOT NULL,
  `buy_reson` varchar(255) NOT NULL,
  `user_id` int NOT NULL DEFAULT '0',
  `cashier` varchar(255) NOT NULL,
  `cashier2` varchar(255) NOT NULL,
  `price` double(10,2) NOT NULL,
  `price_in_words` varchar(255) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3;

-- --------------------------------------------------------

--
-- Table structure for table `page_text`
--

CREATE TABLE `page_text` (
  `id` int UNSIGNED NOT NULL,
  `category_id` int UNSIGNED NOT NULL,
  `title` text NOT NULL,
  `content` text NOT NULL,
  `text_status` int UNSIGNED NOT NULL DEFAULT '0',
  `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3;

-- --------------------------------------------------------

--
-- Table structure for table `parameters`
--

CREATE TABLE `parameters` (
  `id` int NOT NULL,
  `name` varchar(255) NOT NULL,
  `php` varchar(255) NOT NULL,
  `value` varchar(255) NOT NULL,
  `type` varchar(250) NOT NULL,
  `field` varchar(255) NOT NULL,
  `description` text NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3;

-- --------------------------------------------------------

--
-- Table structure for table `sell`
--

CREATE TABLE `sell` (
  `id` int NOT NULL,
  `csddnr` varchar(255) NOT NULL DEFAULT '0',
  `buy_no` varchar(255) NOT NULL,
  `nr` int NOT NULL,
  `car_id` int NOT NULL,
  `client_id` int NOT NULL,
  `user_id` int NOT NULL,
  `price` double(10,2) NOT NULL,
  `cheque_nr` varchar(255) NOT NULL,
  `payment_type` varchar(255) NOT NULL,
  `cash` decimal(10,2) NOT NULL DEFAULT '0.00',
  `transfer` decimal(10,2) NOT NULL DEFAULT '0.00',
  `leasing_comm` int NOT NULL DEFAULT '0',
  `csdd_comm` int NOT NULL DEFAULT '0',
  `comm_cash` int NOT NULL DEFAULT '0',
  `comment` text NOT NULL,
  `first_payment` text NOT NULL,
  `ref_from` text NOT NULL,
  `seller` varchar(255) NOT NULL,
  `created` int NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3;

-- --------------------------------------------------------

--
-- Table structure for table `site_text`
--

CREATE TABLE `site_text` (
  `id` int UNSIGNED NOT NULL,
  `name` mediumtext NOT NULL,
  `text_status` int UNSIGNED NOT NULL,
  `domain_id` int NOT NULL,
  `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3;

-- --------------------------------------------------------

--
-- Table structure for table `site_text_lang`
--

CREATE TABLE `site_text_lang` (
  `site_text_id` int UNSIGNED NOT NULL,
  `sys_lang_id` int UNSIGNED NOT NULL,
  `body` text NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3;

-- --------------------------------------------------------

--
-- Table structure for table `slide`
--

CREATE TABLE `slide` (
  `id` int NOT NULL,
  `title` varchar(255) NOT NULL,
  `pic` varchar(255) NOT NULL,
  `url` varchar(255) NOT NULL,
  `status` int NOT NULL DEFAULT '0',
  `sys_lang_id` int NOT NULL,
  `text_line_1` text NOT NULL,
  `text_line_2` text NOT NULL,
  `text_line_3` text NOT NULL,
  `color` varchar(255) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3;

-- --------------------------------------------------------

--
-- Table structure for table `social`
--

CREATE TABLE `social` (
  `id` int NOT NULL,
  `title` varchar(255) NOT NULL,
  `link` varchar(255) NOT NULL,
  `type` varchar(255) NOT NULL,
  `time` int NOT NULL,
  `domain_id` int NOT NULL DEFAULT '0',
  `status` int NOT NULL DEFAULT '0'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3;

-- --------------------------------------------------------

--
-- Table structure for table `sys_lang`
--

CREATE TABLE `sys_lang` (
  `id` int UNSIGNED NOT NULL,
  `title` varchar(255) NOT NULL,
  `name` text NOT NULL,
  `lang_status` int UNSIGNED NOT NULL DEFAULT '1',
  `lang_status_pub` int NOT NULL DEFAULT '0',
  `created` varchar(255) NOT NULL DEFAULT '0',
  `default` int NOT NULL DEFAULT '0'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3;

-- --------------------------------------------------------

--
-- Table structure for table `sys_module`
--

CREATE TABLE `sys_module` (
  `id` int UNSIGNED NOT NULL,
  `name` text NOT NULL,
  `adm_path` text NOT NULL,
  `body_name` text NOT NULL,
  `config_params` text,
  `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3;

-- --------------------------------------------------------

--
-- Table structure for table `sys_template`
--

CREATE TABLE `sys_template` (
  `id` int UNSIGNED NOT NULL,
  `name` text NOT NULL,
  `source_path` text NOT NULL,
  `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3;

-- --------------------------------------------------------

--
-- Table structure for table `sys_template_has_element`
--

CREATE TABLE `sys_template_has_element` (
  `id` int UNSIGNED NOT NULL,
  `sys_template_id` int UNSIGNED NOT NULL,
  `sys_module_id` int UNSIGNED DEFAULT NULL,
  `sys_template_region_id` int UNSIGNED DEFAULT NULL,
  `sort_order` int UNSIGNED NOT NULL DEFAULT '0',
  `position` int UNSIGNED NOT NULL,
  `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3;

-- --------------------------------------------------------

--
-- Table structure for table `sys_template_region`
--

CREATE TABLE `sys_template_region` (
  `id` int UNSIGNED NOT NULL,
  `region_name` text NOT NULL,
  `description` text,
  `content` text,
  `view_path` text NOT NULL,
  `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3;

-- --------------------------------------------------------

--
-- Table structure for table `translations`
--

CREATE TABLE `translations` (
  `id` int NOT NULL,
  `key` varchar(255) NOT NULL,
  `translation` text NOT NULL,
  `desc` text NOT NULL,
  `sys_lang_id` int NOT NULL,
  `type` varchar(100) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3;

-- --------------------------------------------------------

--
-- Table structure for table `tyres`
--

CREATE TABLE `tyres` (
  `id` int NOT NULL,
  `name` varchar(255) NOT NULL,
  `count` int NOT NULL,
  `size` varchar(10) NOT NULL,
  `width` varchar(10) NOT NULL,
  `season` set('','winter','summer','studded','m+s') CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL,
  `price` float(10,2) NOT NULL,
  `created` int NOT NULL,
  `user_id` int NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3;

-- --------------------------------------------------------

--
-- Table structure for table `tyres_images`
--

CREATE TABLE `tyres_images` (
  `id` int NOT NULL,
  `tyre_id` int NOT NULL,
  `src` varchar(255) NOT NULL,
  `sort_order` int NOT NULL DEFAULT '0'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3;

-- --------------------------------------------------------

--
-- Table structure for table `urls`
--

CREATE TABLE `urls` (
  `id` int NOT NULL,
  `short_code` varchar(255) NOT NULL,
  `long_url` varchar(2083) NOT NULL,
  `redirect_count` int NOT NULL DEFAULT '0',
  `created_at` int NOT NULL DEFAULT '0'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3;

-- --------------------------------------------------------

--
-- Table structure for table `users`
--

CREATE TABLE `users` (
  `id` int NOT NULL,
  `type` varchar(255) NOT NULL DEFAULT 'personal',
  `feed` int NOT NULL DEFAULT '0',
  `google_id` varchar(255) NOT NULL,
  `email` varchar(255) NOT NULL,
  `name` varchar(100) NOT NULL,
  `plink` varchar(255) NOT NULL,
  `web` varchar(255) NOT NULL,
  `phone` varchar(12) NOT NULL,
  `password` varchar(255) NOT NULL,
  `created` int NOT NULL,
  `whatsapp` int NOT NULL DEFAULT '0',
  `telegram` int NOT NULL DEFAULT '0',
  `ip` varchar(255) NOT NULL,
  `agree` int NOT NULL DEFAULT '0',
  `image` varchar(255) NOT NULL,
  `last_login` int NOT NULL,
  `smscode` varchar(6) NOT NULL,
  `referral` varchar(255) NOT NULL,
  `status` int NOT NULL DEFAULT '0',
  `verified` int NOT NULL DEFAULT '0',
  `subscribed` int NOT NULL DEFAULT '1'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3;

-- --------------------------------------------------------

--
-- Table structure for table `user_activities`
--

CREATE TABLE `user_activities` (
  `id` int NOT NULL,
  `activity_type` varchar(255) NOT NULL,
  `activity_details` text,
  `ip` varchar(255) NOT NULL,
  `created_at` int DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3;

--
-- Indexes for dumped tables
--

--
-- Indexes for table `admin_users`
--
ALTER TABLE `admin_users`
  ADD PRIMARY KEY (`id`);

--
-- Indexes for table `ap_makes`
--
ALTER TABLE `ap_makes`
  ADD PRIMARY KEY (`id`);

--
-- Indexes for table `ap_models`
--
ALTER TABLE `ap_models`
  ADD PRIMARY KEY (`id`);

--
-- Indexes for table `awards`
--
ALTER TABLE `awards`
  ADD PRIMARY KEY (`id`);

--
-- Indexes for table `awards_found`
--
ALTER TABLE `awards_found`
  ADD PRIMARY KEY (`id`);

--
-- Indexes for table `banner`
--
ALTER TABLE `banner`
  ADD PRIMARY KEY (`id`);

--
-- Indexes for table `blocks`
--
ALTER TABLE `blocks`
  ADD PRIMARY KEY (`id`);

--
-- Indexes for table `buy`
--
ALTER TABLE `buy`
  ADD PRIMARY KEY (`id`);

--
-- Indexes for table `buy_offers`
--
ALTER TABLE `buy_offers`
  ADD PRIMARY KEY (`id`);

--
-- Indexes for table `calendar_events`
--
ALTER TABLE `calendar_events`
  ADD PRIMARY KEY (`id`);

--
-- Indexes for table `call_log`
--
ALTER TABLE `call_log`
  ADD PRIMARY KEY (`id`);

--
-- Indexes for table `cars`
--
ALTER TABLE `cars`
  ADD PRIMARY KEY (`id`),
  ADD KEY `plink` (`plink`),
  ADD KEY `status_d_s` (`status`,`damaged`,`sold`);

--
-- Indexes for table `cars_images`
--
ALTER TABLE `cars_images`
  ADD PRIMARY KEY (`id`),
  ADD KEY `car_id` (`car_id`);

--
-- Indexes for table `car_call_events`
--
ALTER TABLE `car_call_events`
  ADD PRIMARY KEY (`id`);

--
-- Indexes for table `car_data`
--
ALTER TABLE `car_data`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `vin` (`vin`);

--
-- Indexes for table `car_history`
--
ALTER TABLE `car_history`
  ADD PRIMARY KEY (`id`),
  ADD KEY `car_id` (`car_id`);

--
-- Indexes for table `car_shares`
--
ALTER TABLE `car_shares`
  ADD PRIMARY KEY (`id`);

--
-- Indexes for table `category`
--
ALTER TABLE `category`
  ADD PRIMARY KEY (`id`),
  ADD KEY `category_FKIndex1` (`sys_template_id`),
  ADD KEY `category_FKIndex2` (`sys_lang_id`);

--
-- Indexes for table `cat_engine`
--
ALTER TABLE `cat_engine`
  ADD PRIMARY KEY (`engine_id`),
  ADD KEY `generation_id` (`generation_id`);

--
-- Indexes for table `cat_generation`
--
ALTER TABLE `cat_generation`
  ADD PRIMARY KEY (`generation_id`),
  ADD KEY `model_id` (`model_id`);

--
-- Indexes for table `cat_manufacturer`
--
ALTER TABLE `cat_manufacturer`
  ADD PRIMARY KEY (`manufacturer_id`);

--
-- Indexes for table `cat_model`
--
ALTER TABLE `cat_model`
  ADD PRIMARY KEY (`model_id`),
  ADD KEY `manufacturer_id` (`manufacturer_id`);

--
-- Indexes for table `ci_sessions`
--
ALTER TABLE `ci_sessions`
  ADD PRIMARY KEY (`session_id`);

--
-- Indexes for table `clients`
--
ALTER TABLE `clients`
  ADD PRIMARY KEY (`id`);

--
-- Indexes for table `commisions`
--
ALTER TABLE `commisions`
  ADD PRIMARY KEY (`id`);

--
-- Indexes for table `defective_cars`
--
ALTER TABLE `defective_cars`
  ADD PRIMARY KEY (`id`);

--
-- Indexes for table `expenses`
--
ALTER TABLE `expenses`
  ADD PRIMARY KEY (`id`);

--
-- Indexes for table `invoices`
--
ALTER TABLE `invoices`
  ADD PRIMARY KEY (`id`);

--
-- Indexes for table `key_numbers`
--
ALTER TABLE `key_numbers`
  ADD PRIMARY KEY (`id`);

--
-- Indexes for table `last_bill`
--
ALTER TABLE `last_bill`
  ADD PRIMARY KEY (`id`);

--
-- Indexes for table `leasing_check`
--
ALTER TABLE `leasing_check`
  ADD PRIMARY KEY (`id`);

--
-- Indexes for table `leasing_check_comments`
--
ALTER TABLE `leasing_check_comments`
  ADD PRIMARY KEY (`id`),
  ADD KEY `leasing_id_k` (`leasing_id`);

--
-- Indexes for table `leasing_profiles`
--
ALTER TABLE `leasing_profiles`
  ADD PRIMARY KEY (`id`),
  ADD KEY `idx_creditmind_id` (`creditmind_id`);

--
-- Indexes for table `leasing_profiles_agreements`
--
ALTER TABLE `leasing_profiles_agreements`
  ADD PRIMARY KEY (`id`);

--
-- Indexes for table `leasing_profile_comments`
--
ALTER TABLE `leasing_profile_comments`
  ADD PRIMARY KEY (`id`);

--
-- Indexes for table `leasing_sms_log`
--
ALTER TABLE `leasing_sms_log`
  ADD PRIMARY KEY (`id`);

--
-- Indexes for table `makes`
--
ALTER TABLE `makes`
  ADD PRIMARY KEY (`id`);

--
-- Indexes for table `merc_location`
--
ALTER TABLE `merc_location`
  ADD PRIMARY KEY (`id`);

--
-- Indexes for table `models`
--
ALTER TABLE `models`
  ADD PRIMARY KEY (`id`);

--
-- Indexes for table `options`
--
ALTER TABLE `options`
  ADD PRIMARY KEY (`id`);

--
-- Indexes for table `orders`
--
ALTER TABLE `orders`
  ADD PRIMARY KEY (`id`);

--
-- Indexes for table `page_text`
--
ALTER TABLE `page_text`
  ADD PRIMARY KEY (`id`),
  ADD KEY `page_text_FKIndex1` (`category_id`);

--
-- Indexes for table `parameters`
--
ALTER TABLE `parameters`
  ADD PRIMARY KEY (`id`);

--
-- Indexes for table `sell`
--
ALTER TABLE `sell`
  ADD PRIMARY KEY (`id`);

--
-- Indexes for table `site_text`
--
ALTER TABLE `site_text`
  ADD PRIMARY KEY (`id`);

--
-- Indexes for table `site_text_lang`
--
ALTER TABLE `site_text_lang`
  ADD PRIMARY KEY (`site_text_id`,`sys_lang_id`),
  ADD KEY `site_text_lang_FKIndex1` (`site_text_id`),
  ADD KEY `site_text_lang_FKIndex2` (`sys_lang_id`);

--
-- Indexes for table `slide`
--
ALTER TABLE `slide`
  ADD PRIMARY KEY (`id`);

--
-- Indexes for table `social`
--
ALTER TABLE `social`
  ADD PRIMARY KEY (`id`);

--
-- Indexes for table `sys_lang`
--
ALTER TABLE `sys_lang`
  ADD PRIMARY KEY (`id`);

--
-- Indexes for table `sys_module`
--
ALTER TABLE `sys_module`
  ADD PRIMARY KEY (`id`);

--
-- Indexes for table `sys_template`
--
ALTER TABLE `sys_template`
  ADD PRIMARY KEY (`id`);

--
-- Indexes for table `sys_template_has_element`
--
ALTER TABLE `sys_template_has_element`
  ADD PRIMARY KEY (`id`),
  ADD KEY `sys_template_has_element_FKIndex1` (`sys_template_id`),
  ADD KEY `sys_template_has_element_FKIndex2` (`sys_template_region_id`),
  ADD KEY `sys_template_has_element_FKIndex3` (`sys_module_id`);

--
-- Indexes for table `sys_template_region`
--
ALTER TABLE `sys_template_region`
  ADD PRIMARY KEY (`id`);

--
-- Indexes for table `translations`
--
ALTER TABLE `translations`
  ADD PRIMARY KEY (`id`);

--
-- Indexes for table `tyres`
--
ALTER TABLE `tyres`
  ADD PRIMARY KEY (`id`);

--
-- Indexes for table `tyres_images`
--
ALTER TABLE `tyres_images`
  ADD PRIMARY KEY (`id`);

--
-- Indexes for table `urls`
--
ALTER TABLE `urls`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `short_code` (`short_code`);

--
-- Indexes for table `users`
--
ALTER TABLE `users`
  ADD PRIMARY KEY (`id`);

--
-- Indexes for table `user_activities`
--
ALTER TABLE `user_activities`
  ADD PRIMARY KEY (`id`);

--
-- AUTO_INCREMENT for dumped tables
--

--
-- AUTO_INCREMENT for table `admin_users`
--
ALTER TABLE `admin_users`
  MODIFY `id` int NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `ap_makes`
--
ALTER TABLE `ap_makes`
  MODIFY `id` int NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `ap_models`
--
ALTER TABLE `ap_models`
  MODIFY `id` int NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `awards`
--
ALTER TABLE `awards`
  MODIFY `id` int NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `awards_found`
--
ALTER TABLE `awards_found`
  MODIFY `id` int NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `banner`
--
ALTER TABLE `banner`
  MODIFY `id` int UNSIGNED NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `blocks`
--
ALTER TABLE `blocks`
  MODIFY `id` int NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `buy`
--
ALTER TABLE `buy`
  MODIFY `id` int NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `buy_offers`
--
ALTER TABLE `buy_offers`
  MODIFY `id` int NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `calendar_events`
--
ALTER TABLE `calendar_events`
  MODIFY `id` int NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `call_log`
--
ALTER TABLE `call_log`
  MODIFY `id` int NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `cars`
--
ALTER TABLE `cars`
  MODIFY `id` int NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `cars_images`
--
ALTER TABLE `cars_images`
  MODIFY `id` int NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `car_call_events`
--
ALTER TABLE `car_call_events`
  MODIFY `id` int NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `car_data`
--
ALTER TABLE `car_data`
  MODIFY `id` int NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `car_history`
--
ALTER TABLE `car_history`
  MODIFY `id` int NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `car_shares`
--
ALTER TABLE `car_shares`
  MODIFY `id` int NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `category`
--
ALTER TABLE `category`
  MODIFY `id` int UNSIGNED NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `cat_engine`
--
ALTER TABLE `cat_engine`
  MODIFY `engine_id` int NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `cat_generation`
--
ALTER TABLE `cat_generation`
  MODIFY `generation_id` int NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `cat_manufacturer`
--
ALTER TABLE `cat_manufacturer`
  MODIFY `manufacturer_id` int NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `cat_model`
--
ALTER TABLE `cat_model`
  MODIFY `model_id` int NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `clients`
--
ALTER TABLE `clients`
  MODIFY `id` int NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `commisions`
--
ALTER TABLE `commisions`
  MODIFY `id` int NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `defective_cars`
--
ALTER TABLE `defective_cars`
  MODIFY `id` int NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `expenses`
--
ALTER TABLE `expenses`
  MODIFY `id` int NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `invoices`
--
ALTER TABLE `invoices`
  MODIFY `id` int NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `key_numbers`
--
ALTER TABLE `key_numbers`
  MODIFY `id` int NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `last_bill`
--
ALTER TABLE `last_bill`
  MODIFY `id` int NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `leasing_check`
--
ALTER TABLE `leasing_check`
  MODIFY `id` int NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `leasing_check_comments`
--
ALTER TABLE `leasing_check_comments`
  MODIFY `id` int NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `leasing_profiles`
--
ALTER TABLE `leasing_profiles`
  MODIFY `id` int NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `leasing_profiles_agreements`
--
ALTER TABLE `leasing_profiles_agreements`
  MODIFY `id` int NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `leasing_profile_comments`
--
ALTER TABLE `leasing_profile_comments`
  MODIFY `id` int NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `leasing_sms_log`
--
ALTER TABLE `leasing_sms_log`
  MODIFY `id` int NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `makes`
--
ALTER TABLE `makes`
  MODIFY `id` int NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `merc_location`
--
ALTER TABLE `merc_location`
  MODIFY `id` int NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `models`
--
ALTER TABLE `models`
  MODIFY `id` int NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `options`
--
ALTER TABLE `options`
  MODIFY `id` int NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `orders`
--
ALTER TABLE `orders`
  MODIFY `id` int NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `page_text`
--
ALTER TABLE `page_text`
  MODIFY `id` int UNSIGNED NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `parameters`
--
ALTER TABLE `parameters`
  MODIFY `id` int NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `sell`
--
ALTER TABLE `sell`
  MODIFY `id` int NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `site_text`
--
ALTER TABLE `site_text`
  MODIFY `id` int UNSIGNED NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `slide`
--
ALTER TABLE `slide`
  MODIFY `id` int NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `social`
--
ALTER TABLE `social`
  MODIFY `id` int NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `sys_lang`
--
ALTER TABLE `sys_lang`
  MODIFY `id` int UNSIGNED NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `sys_module`
--
ALTER TABLE `sys_module`
  MODIFY `id` int UNSIGNED NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `sys_template`
--
ALTER TABLE `sys_template`
  MODIFY `id` int UNSIGNED NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `sys_template_has_element`
--
ALTER TABLE `sys_template_has_element`
  MODIFY `id` int UNSIGNED NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `sys_template_region`
--
ALTER TABLE `sys_template_region`
  MODIFY `id` int UNSIGNED NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `translations`
--
ALTER TABLE `translations`
  MODIFY `id` int NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `tyres`
--
ALTER TABLE `tyres`
  MODIFY `id` int NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `tyres_images`
--
ALTER TABLE `tyres_images`
  MODIFY `id` int NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `urls`
--
ALTER TABLE `urls`
  MODIFY `id` int NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `users`
--
ALTER TABLE `users`
  MODIFY `id` int NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `user_activities`
--
ALTER TABLE `user_activities`
  MODIFY `id` int NOT NULL AUTO_INCREMENT;

--
-- Constraints for dumped tables
--

--
-- Constraints for table `car_history`
--
ALTER TABLE `car_history`
  ADD CONSTRAINT `car_history_ibfk_1` FOREIGN KEY (`car_id`) REFERENCES `cars` (`id`) ON DELETE CASCADE;

--
-- Constraints for table `cat_engine`
--
ALTER TABLE `cat_engine`
  ADD CONSTRAINT `cat_engine_ibfk_1` FOREIGN KEY (`generation_id`) REFERENCES `cat_generation` (`generation_id`);

--
-- Constraints for table `cat_generation`
--
ALTER TABLE `cat_generation`
  ADD CONSTRAINT `cat_generation_ibfk_1` FOREIGN KEY (`model_id`) REFERENCES `cat_model` (`model_id`) ON DELETE RESTRICT ON UPDATE RESTRICT;

--
-- Constraints for table `cat_model`
--
ALTER TABLE `cat_model`
  ADD CONSTRAINT `cat_model_ibfk_1` FOREIGN KEY (`manufacturer_id`) REFERENCES `cat_manufacturer` (`manufacturer_id`) ON DELETE RESTRICT ON UPDATE RESTRICT;
COMMIT;

/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
