-- phpMyAdmin SQL Dump
-- version 5.2.1
-- https://www.phpmyadmin.net/
--
-- Host: 127.0.0.1
-- Generation Time: Mar 13, 2026 at 02:51 PM
-- Wersja serwera: 10.4.32-MariaDB
-- Wersja PHP: 8.2.12

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: `atelier_20260227`
--

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

--
-- Struktura tabeli dla tabeli `admin_panel_user`
--

CREATE TABLE `admin_panel_user` (
  `id` int(11) NOT NULL,
  `id_brand` int(11) NOT NULL,
  `first_name` varchar(255) NOT NULL,
  `surname` varchar(255) NOT NULL,
  `display_name` varchar(255) NOT NULL,
  `active` int(11) NOT NULL DEFAULT 1,
  `login` varchar(255) NOT NULL,
  `password` varchar(255) NOT NULL,
  `id_role` int(11) NOT NULL,
  `create_timestamp` timestamp NOT NULL DEFAULT current_timestamp(),
  `refresh_token` text NOT NULL,
  `is_system_user` tinyint(1) NOT NULL DEFAULT 0,
  `lang_code` varchar(12) NOT NULL DEFAULT 'fr',
  `operational_region_code` varchar(5) NOT NULL DEFAULT 'BE'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `admin_panel_user_permission`
--

CREATE TABLE `admin_panel_user_permission` (
  `id` int(11) NOT NULL,
  `name` varchar(255) NOT NULL,
  `description` varchar(255) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `admin_panel_user_permission_group`
--

CREATE TABLE `admin_panel_user_permission_group` (
  `id` int(11) NOT NULL,
  `name` varchar(255) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `admin_panel_user_permission_group_connection`
--

CREATE TABLE `admin_panel_user_permission_group_connection` (
  `id_group` int(11) NOT NULL,
  `id_permission` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `admin_panel_user_role`
--

CREATE TABLE `admin_panel_user_role` (
  `id_brand` int(11) NOT NULL,
  `id` int(11) NOT NULL,
  `name` varchar(255) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `admin_panel_user_role_alias`
--

CREATE TABLE `admin_panel_user_role_alias` (
  `id` int(11) NOT NULL,
  `id_admin_panel_user_role` int(11) NOT NULL,
  `lang_code` varchar(5) NOT NULL,
  `alias` varchar(255) NOT NULL,
  `alias_type` varchar(50) NOT NULL DEFAULT 'default',
  `create_timestamp` datetime NOT NULL DEFAULT current_timestamp(),
  `update_timestamp` datetime NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `admin_panel_user_role_permission_connection`
--

CREATE TABLE `admin_panel_user_role_permission_connection` (
  `id_role` int(11) NOT NULL,
  `id_permission` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `allergen`
--

CREATE TABLE `allergen` (
  `id` int(11) NOT NULL,
  `code` varchar(50) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `auth_session`
--

CREATE TABLE `auth_session` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `auth_user_id` int(11) NOT NULL,
  `app` varchar(20) NOT NULL,
  `membership_id` bigint(20) UNSIGNED DEFAULT NULL,
  `token_hash` binary(32) NOT NULL,
  `created_at` datetime NOT NULL DEFAULT current_timestamp(),
  `expires_at` datetime NOT NULL,
  `revoked_at` datetime DEFAULT NULL,
  `replaced_by_id` bigint(20) UNSIGNED DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `auth_user`
--

CREATE TABLE `auth_user` (
  `id` int(11) NOT NULL,
  `login` varchar(255) DEFAULT NULL,
  `password_hash` varchar(255) NOT NULL,
  `phone` varchar(255) DEFAULT NULL,
  `created_at` datetime NOT NULL DEFAULT current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `b2b_client_company_department`
--

CREATE TABLE `b2b_client_company_department` (
  `id` int(11) NOT NULL,
  `id_client` int(11) NOT NULL,
  `name` varchar(255) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `b2b_client_interest`
--

CREATE TABLE `b2b_client_interest` (
  `id_brand` int(11) NOT NULL,
  `id` int(11) NOT NULL,
  `name` varchar(255) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `b2b_client_interest_alias`
--

CREATE TABLE `b2b_client_interest_alias` (
  `id` int(11) NOT NULL,
  `id_b2b_client_interest` int(11) NOT NULL,
  `lang_code` varchar(5) NOT NULL,
  `alias` varchar(255) NOT NULL,
  `alias_type` varchar(50) NOT NULL DEFAULT 'default',
  `create_timestamp` datetime NOT NULL DEFAULT current_timestamp(),
  `update_timestamp` datetime NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `b2b_client_interest_connection`
--

CREATE TABLE `b2b_client_interest_connection` (
  `id_b2b_client` int(11) NOT NULL,
  `id_interest` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `b2b_client_sector`
--

CREATE TABLE `b2b_client_sector` (
  `id_brand` int(11) NOT NULL,
  `id` int(11) NOT NULL,
  `name` varchar(255) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `b2b_client_sector_alias`
--

CREATE TABLE `b2b_client_sector_alias` (
  `id` int(11) NOT NULL,
  `id_b2b_client_sector` int(11) NOT NULL,
  `lang_code` varchar(5) NOT NULL,
  `alias` varchar(255) NOT NULL,
  `alias_type` varchar(50) NOT NULL DEFAULT 'default',
  `create_timestamp` datetime NOT NULL DEFAULT current_timestamp(),
  `update_timestamp` datetime NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `b2b_client_type`
--

CREATE TABLE `b2b_client_type` (
  `id_brand` int(11) NOT NULL,
  `id` int(11) NOT NULL,
  `name` varchar(255) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `b2b_client_type_alias`
--

CREATE TABLE `b2b_client_type_alias` (
  `id` int(11) NOT NULL,
  `id_b2b_client_type` int(11) NOT NULL,
  `lang_code` varchar(5) NOT NULL,
  `alias` varchar(255) NOT NULL,
  `alias_type` varchar(50) NOT NULL DEFAULT 'default',
  `create_timestamp` datetime NOT NULL DEFAULT current_timestamp(),
  `update_timestamp` datetime NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `benchmark_competitor`
--

CREATE TABLE `benchmark_competitor` (
  `id` int(11) NOT NULL,
  `shop_id` int(11) NOT NULL,
  `name` varchar(128) NOT NULL,
  `type` varchar(32) DEFAULT NULL,
  `distance_km` decimal(6,2) DEFAULT NULL,
  `city` varchar(64) DEFAULT NULL,
  `notes` text DEFAULT NULL,
  `is_active` tinyint(1) NOT NULL DEFAULT 1,
  `created_at` datetime NOT NULL DEFAULT current_timestamp(),
  `updated_at` datetime NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `benchmark_observation`
--

CREATE TABLE `benchmark_observation` (
  `id` int(11) NOT NULL,
  `shop_id` int(11) NOT NULL,
  `competitor_id` int(11) NOT NULL,
  `observed_at` date NOT NULL,
  `notes` text DEFAULT NULL,
  `created_at` datetime NOT NULL DEFAULT current_timestamp(),
  `updated_at` datetime NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `benchmark_observation_item`
--

CREATE TABLE `benchmark_observation_item` (
  `id` int(11) NOT NULL,
  `observation_id` int(11) NOT NULL,
  `shop_id` int(11) NOT NULL,
  `competitor_id` int(11) NOT NULL,
  `name_raw` varchar(255) NOT NULL,
  `my_category_id` int(11) NOT NULL,
  `unit_type` enum('piece','100g','kg','portion') NOT NULL DEFAULT 'piece',
  `unit_size` decimal(10,3) DEFAULT NULL,
  `price` decimal(10,2) NOT NULL,
  `promo_price` decimal(10,2) DEFAULT NULL,
  `is_promo` tinyint(1) NOT NULL DEFAULT 0,
  `quality_score` tinyint(4) DEFAULT NULL,
  `notes` varchar(255) DEFAULT NULL,
  `my_product_id` int(11) DEFAULT NULL,
  `created_at` datetime NOT NULL DEFAULT current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `client`
--

CREATE TABLE `client` (
  `id` int(11) NOT NULL,
  `id_main_shop` int(11) NOT NULL,
  `is_b2b` tinyint(1) NOT NULL DEFAULT 0,
  `name` varchar(255) DEFAULT NULL,
  `surname` varchar(255) DEFAULT NULL,
  `company_name` text DEFAULT NULL,
  `tax_number` varchar(35) DEFAULT NULL,
  `can_deferral` tinyint(1) NOT NULL DEFAULT 0,
  `street` varchar(255) NOT NULL DEFAULT '',
  `street_number` varchar(15) NOT NULL DEFAULT '',
  `city` varchar(255) NOT NULL DEFAULT '',
  `zip` varchar(55) NOT NULL DEFAULT '',
  `comment` varchar(255) NOT NULL DEFAULT '',
  `phone` varchar(255) DEFAULT NULL,
  `email` varchar(255) DEFAULT NULL,
  `payment_terms` int(11) NOT NULL DEFAULT 0,
  `personal_discount_percent` int(11) NOT NULL DEFAULT 0,
  `create_timestamp` timestamp NOT NULL DEFAULT current_timestamp(),
  `peppol_identifier` varchar(64) DEFAULT NULL,
  `peppol_verified` tinyint(1) NOT NULL DEFAULT 0,
  `updated_at` timestamp NULL DEFAULT NULL ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `client_invoice`
--

CREATE TABLE `client_invoice` (
  `id` int(11) NOT NULL,
  `id_shop` int(11) NOT NULL,
  `is_b2b_client` tinyint(1) NOT NULL,
  `document_number` varchar(35) NOT NULL,
  `invoice_number` varchar(25) NOT NULL DEFAULT '',
  `id_client` int(11) NOT NULL,
  `consignor_name` text NOT NULL,
  `consignor_phone` text NOT NULL,
  `consignor_address_1` text NOT NULL,
  `consignor_address_2` text NOT NULL,
  `consignor_tax_number` text NOT NULL,
  `consignor_bank` text NOT NULL,
  `consignee_name` text NOT NULL,
  `consignee_address_1` text NOT NULL,
  `consignee_address_2` text NOT NULL,
  `consignee_tax_number` text NOT NULL,
  `due_date` date DEFAULT NULL,
  `invoiced_date` timestamp NOT NULL DEFAULT current_timestamp(),
  `deferral_invoice` tinyint(1) NOT NULL DEFAULT 0,
  `date_of_payment` date DEFAULT NULL,
  `date_last_emailed` datetime DEFAULT NULL,
  `reference_comment` varchar(255) NOT NULL DEFAULT '',
  `invoice_type` enum('NORMAL','CORRECTION') NOT NULL DEFAULT 'NORMAL',
  `correction_number` varchar(255) DEFAULT NULL,
  `id_original_invoice` int(11) DEFAULT NULL,
  `correction_reason` text DEFAULT NULL,
  `currency` varchar(5) NOT NULL DEFAULT 'EUR',
  `po_hash` varchar(255) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `client_invoice_product`
--

CREATE TABLE `client_invoice_product` (
  `id` int(11) NOT NULL,
  `id_original_invoice_product` int(11) DEFAULT NULL,
  `id_invoice` int(11) NOT NULL,
  `id_transaction` int(11) DEFAULT NULL,
  `ticket_key` bigint(20) DEFAULT NULL,
  `id_product` int(11) NOT NULL,
  `product_name` varchar(255) NOT NULL,
  `unit_gross_price` decimal(10,2) NOT NULL,
  `quantity` decimal(10,3) NOT NULL,
  `item_tax_perc` int(11) NOT NULL,
  `item_discount_value` decimal(10,2) NOT NULL COMMENT 'Obniżka całkowitej ceny',
  `total_gross_value_after_discount` decimal(10,2) NOT NULL,
  `total_tax_value_after_discount` decimal(10,2) NOT NULL,
  `sell_date` datetime NOT NULL,
  `group_key` varchar(100) NOT NULL DEFAULT ''
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `client_offer`
--

CREATE TABLE `client_offer` (
  `id` int(11) NOT NULL,
  `id_shop` int(11) NOT NULL,
  `name` varchar(255) NOT NULL,
  `description` text NOT NULL,
  `id_client` int(11) DEFAULT NULL,
  `in_store_pickup` tinyint(1) NOT NULL DEFAULT 0 COMMENT '0 -> false, 1 -> true',
  `delivery_street` varchar(255) DEFAULT NULL,
  `delivery_zip` varchar(15) DEFAULT NULL,
  `delivery_city` varchar(255) DEFAULT NULL,
  `delivery_cost` decimal(10,2) DEFAULT NULL,
  `conditions` text NOT NULL,
  `event_day` datetime DEFAULT NULL,
  `realised` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'was created order from this offer	',
  `active` tinyint(1) NOT NULL DEFAULT 1,
  `status` int(11) NOT NULL DEFAULT 0 COMMENT '0 -> waiting for confirm 1 -> confirmed 2 -> deadcrash	',
  `create_timestamp` timestamp NOT NULL DEFAULT current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `client_offer_product`
--

CREATE TABLE `client_offer_product` (
  `id` int(11) NOT NULL,
  `id_offer` int(11) NOT NULL,
  `id_product` int(11) NOT NULL,
  `product_name` varchar(255) NOT NULL,
  `quantity` decimal(10,2) NOT NULL,
  `unit_price` decimal(10,2) NOT NULL,
  `discount_value` decimal(10,2) NOT NULL,
  `discount_amount` decimal(10,2) NOT NULL,
  `id_discount_type` int(11) NOT NULL,
  `final_total_price` decimal(10,2) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `client_order`
--

CREATE TABLE `client_order` (
  `id` int(11) NOT NULL,
  `id_shop` int(11) NOT NULL,
  `id_client` int(11) DEFAULT NULL,
  `id_client_department` int(11) DEFAULT NULL,
  `id_transaction` int(11) DEFAULT NULL,
  `comment` text NOT NULL,
  `pick_up_datetime` datetime NOT NULL,
  `id_order_status` int(11) NOT NULL DEFAULT 1 COMMENT '1 -> new, 2 -> completed, 3 -> picked_up,\r\n4 -> unpicked',
  `order_status` enum('new','completed','picked_up','unpicked','in_production') DEFAULT NULL,
  `id_accepting_employee` int(11) NOT NULL,
  `id_issuing_employee` int(11) DEFAULT NULL,
  `accepting_timestamp` timestamp NOT NULL DEFAULT current_timestamp(),
  `completion_timestamp` timestamp NULL DEFAULT NULL,
  `issuing_timestamp` timestamp NULL DEFAULT NULL,
  `non_collection_id_reason` int(11) DEFAULT NULL,
  `non_collection_comment` text DEFAULT NULL,
  `po_hash` text DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `client_order_product`
--

CREATE TABLE `client_order_product` (
  `id` int(11) NOT NULL,
  `id_order` int(11) NOT NULL,
  `id_product` int(11) NOT NULL,
  `name` varchar(255) NOT NULL,
  `quantity` decimal(10,3) NOT NULL,
  `weight` int(11) DEFAULT NULL,
  `unit_gross_price` decimal(10,2) NOT NULL,
  `item_tax_perc` int(11) NOT NULL,
  `item_discount_value` decimal(10,2) NOT NULL,
  `total_gross_value_after_discount` decimal(10,2) NOT NULL,
  `total_tax_value_after_discount` decimal(10,2) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `client_order_rejection_reason`
--

CREATE TABLE `client_order_rejection_reason` (
  `id` int(11) NOT NULL,
  `id_brand` int(11) NOT NULL,
  `content` text NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `client_order_rejection_reason_alias`
--

CREATE TABLE `client_order_rejection_reason_alias` (
  `id` int(11) NOT NULL,
  `id_client_order_rejection_reason` int(11) NOT NULL,
  `lang_code` varchar(5) NOT NULL,
  `alias` varchar(255) NOT NULL,
  `alias_type` varchar(50) NOT NULL DEFAULT 'default',
  `create_timestamp` datetime NOT NULL DEFAULT current_timestamp(),
  `update_timestamp` datetime NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `competency`
--

CREATE TABLE `competency` (
  `id` int(11) NOT NULL,
  `id_subcategory` int(11) NOT NULL,
  `name` varchar(255) NOT NULL DEFAULT '',
  `description` text NOT NULL,
  `related_link` varchar(255) DEFAULT NULL,
  `verification_method` enum('self','instructor') NOT NULL DEFAULT 'self',
  `created_at` datetime NOT NULL DEFAULT current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `competency_category`
--

CREATE TABLE `competency_category` (
  `id` int(11) NOT NULL,
  `name` varchar(255) NOT NULL,
  `description` text NOT NULL,
  `category_type` enum('operational','product') NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `competency_knowledge_resource_connection`
--

CREATE TABLE `competency_knowledge_resource_connection` (
  `id` int(11) NOT NULL,
  `id_competency` int(11) NOT NULL,
  `knowledge_resource_id` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `competency_operational_procedure_connection`
--

CREATE TABLE `competency_operational_procedure_connection` (
  `id` int(11) NOT NULL,
  `id_competency` int(11) NOT NULL,
  `id_operational_procedure` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `competency_subcategory`
--

CREATE TABLE `competency_subcategory` (
  `id` int(11) NOT NULL,
  `id_category` int(11) NOT NULL,
  `name` varchar(255) NOT NULL,
  `description` text NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `competency_training_connection`
--

CREATE TABLE `competency_training_connection` (
  `id` int(11) NOT NULL,
  `id_competency` int(11) NOT NULL,
  `training_id` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `complaint`
--

CREATE TABLE `complaint` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `complaint_key` varchar(36) NOT NULL,
  `id_shop` int(11) NOT NULL,
  `reported_at` datetime NOT NULL,
  `status` enum('NEW','IN_REVIEW','RESOLVED','REJECTED','READY') NOT NULL DEFAULT 'NEW',
  `id_material` bigint(20) UNSIGNED NOT NULL,
  `supplier_sku` varchar(255) NOT NULL,
  `id_supplier` bigint(20) UNSIGNED DEFAULT NULL,
  `id_order` bigint(20) UNSIGNED DEFAULT NULL,
  `qty` decimal(12,3) NOT NULL,
  `id_unit` int(11) NOT NULL,
  `reason_code` enum('size_or_weight_issue','broken_packaging','incorrect_information','lack_of_conformity','incorrect_quantity_of_products_in_package','product_quality','other') NOT NULL,
  `description` text DEFAULT NULL,
  `requested_action` enum('REFUND','REPLACEMENT','CREDIT') DEFAULT NULL,
  `created_at` datetime NOT NULL DEFAULT current_timestamp(),
  `updated_at` datetime NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
  `production_response` text DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `complaint_attachment`
--

CREATE TABLE `complaint_attachment` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `complaint_id` bigint(20) UNSIGNED NOT NULL,
  `attachment_uuid` char(36) NOT NULL,
  `original_name` varchar(255) DEFAULT NULL,
  `mime_type` varchar(64) DEFAULT NULL,
  `shop_uid` char(26) NOT NULL,
  `s3_bucket` varchar(128) NOT NULL,
  `s3_key` varchar(512) NOT NULL,
  `checksum_sha256` char(64) NOT NULL,
  `size_bytes` int(11) NOT NULL,
  `issued_at` datetime DEFAULT NULL,
  `created_at` datetime NOT NULL DEFAULT current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `complaint_outbox`
--

CREATE TABLE `complaint_outbox` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `uuid` char(36) NOT NULL,
  `complaint_id` bigint(20) UNSIGNED NOT NULL,
  `id_shop` int(11) NOT NULL,
  `id_supplier` int(11) NOT NULL,
  `shop_uid` char(26) NOT NULL,
  `payload_json` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL CHECK (json_valid(`payload_json`)),
  `export_status` enum('NEW','DELIVERED','FAILED') NOT NULL DEFAULT 'NEW',
  `export_delivered_at` datetime DEFAULT NULL,
  `created_at` datetime NOT NULL DEFAULT current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `complaint_reason`
--

CREATE TABLE `complaint_reason` (
  `code` varchar(64) NOT NULL,
  `name` varchar(128) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `country`
--

CREATE TABLE `country` (
  `country_code` char(2) NOT NULL COMMENT 'ISO 3166-1 alpha-2',
  `currency` varchar(5) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `country_translation`
--

CREATE TABLE `country_translation` (
  `country_code` char(2) NOT NULL,
  `locale` char(5) NOT NULL,
  `name` varchar(100) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `course`
--

CREATE TABLE `course` (
  `id_brand` int(11) NOT NULL,
  `id` int(11) NOT NULL,
  `name` varchar(255) NOT NULL,
  `description` text NOT NULL,
  `id_subgroup` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `course_commission`
--

CREATE TABLE `course_commission` (
  `id_brand` int(11) NOT NULL,
  `id` int(11) NOT NULL,
  `id_course_set` int(11) NOT NULL,
  `id_shop` int(11) NOT NULL,
  `insert_timestamp` timestamp NOT NULL DEFAULT current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `course_commissioning_course`
--

CREATE TABLE `course_commissioning_course` (
  `id` int(11) NOT NULL,
  `id_commission` int(11) NOT NULL,
  `id_course` int(11) NOT NULL,
  `id_employee` int(11) NOT NULL,
  `comment_for_instructor` text NOT NULL,
  `start_date` date NOT NULL,
  `end_date` date DEFAULT NULL,
  `is_realised` int(11) NOT NULL DEFAULT 0,
  `id_instructor` int(11) NOT NULL,
  `instructor_comment` text DEFAULT NULL,
  `mark_from_instructor` int(11) DEFAULT 0
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `course_completion_by_employee`
--

CREATE TABLE `course_completion_by_employee` (
  `id` int(11) NOT NULL,
  `id_commission` int(11) NOT NULL,
  `id_employee` int(11) NOT NULL,
  `comment` text NOT NULL,
  `finished_date` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `course_group`
--

CREATE TABLE `course_group` (
  `id_brand` int(11) NOT NULL,
  `id` int(11) NOT NULL,
  `name` varchar(255) NOT NULL,
  `description` text NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `course_instructor`
--

CREATE TABLE `course_instructor` (
  `id` int(11) NOT NULL,
  `id_brand` int(11) NOT NULL,
  `first_name` varchar(255) NOT NULL,
  `surname` varchar(255) NOT NULL,
  `display_name` varchar(255) NOT NULL,
  `active` int(11) NOT NULL DEFAULT 1,
  `login` varchar(255) NOT NULL,
  `password` varchar(255) NOT NULL,
  `lang_code` varchar(12) NOT NULL,
  `create_timestamp` timestamp NOT NULL DEFAULT current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `course_set`
--

CREATE TABLE `course_set` (
  `id_brand` int(11) NOT NULL,
  `id` int(11) NOT NULL,
  `name` varchar(255) NOT NULL,
  `description` text NOT NULL,
  `sequence` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `course_set_course_connection`
--

CREATE TABLE `course_set_course_connection` (
  `id_set` int(11) NOT NULL,
  `id_course` int(11) NOT NULL,
  `sequence` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `course_subgroup`
--

CREATE TABLE `course_subgroup` (
  `id` int(11) NOT NULL,
  `id_group` int(11) NOT NULL,
  `name` varchar(255) NOT NULL,
  `description` text NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `customer_survey_question`
--

CREATE TABLE `customer_survey_question` (
  `id_brand` int(11) NOT NULL,
  `id` int(11) NOT NULL,
  `content` text NOT NULL,
  `start_date` date NOT NULL,
  `end_date` date NOT NULL,
  `is_mandatory` tinyint(1) NOT NULL,
  `create_timestamp` timestamp NOT NULL DEFAULT current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `customer_survey_question_alias`
--

CREATE TABLE `customer_survey_question_alias` (
  `id` int(11) NOT NULL,
  `id_customer_survey_question` int(11) NOT NULL,
  `lang_code` varchar(5) NOT NULL,
  `alias` varchar(255) NOT NULL,
  `alias_type` varchar(50) NOT NULL DEFAULT 'default',
  `create_timestamp` datetime NOT NULL DEFAULT current_timestamp(),
  `update_timestamp` datetime NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `customer_survey_question_answer`
--

CREATE TABLE `customer_survey_question_answer` (
  `id` int(11) NOT NULL,
  `id_customer_survey_question` int(11) NOT NULL,
  `content` text NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `customer_survey_question_answer_alias`
--

CREATE TABLE `customer_survey_question_answer_alias` (
  `id` int(11) NOT NULL,
  `id_answer` int(11) NOT NULL,
  `lang_code` varchar(5) NOT NULL,
  `alias` varchar(255) NOT NULL,
  `alias_type` varchar(50) NOT NULL DEFAULT 'default',
  `create_timestamp` datetime NOT NULL DEFAULT current_timestamp(),
  `update_timestamp` datetime NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `customer_survey_question_answer_connection`
--

CREATE TABLE `customer_survey_question_answer_connection` (
  `id_shop` int(11) NOT NULL,
  `id_customer_survey_question` int(11) NOT NULL,
  `id_customer_survey_question_answer` int(11) NOT NULL,
  `id_employee` int(11) NOT NULL,
  `keyticket` int(11) NOT NULL,
  `insert_timestamp` timestamp NOT NULL DEFAULT current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `daily_shift`
--

CREATE TABLE `daily_shift` (
  `id` int(11) NOT NULL,
  `shift_date` date NOT NULL,
  `id_device` int(11) NOT NULL,
  `id_opening_employee` int(11) NOT NULL,
  `id_closing_employee` int(11) DEFAULT NULL,
  `opening_time` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
  `closing_time` timestamp NULL DEFAULT NULL,
  `initial_cash` decimal(10,2) NOT NULL,
  `final_cash` decimal(10,2) DEFAULT NULL,
  `left_cash_for_next_day` decimal(10,2) DEFAULT NULL,
  `create_timestamp` timestamp NOT NULL DEFAULT current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `demand`
--

CREATE TABLE `demand` (
  `id` int(10) UNSIGNED NOT NULL,
  `ref` varchar(32) NOT NULL COMMENT 'Unique reference, e.g. DMD-20240101-AB12C',
  `type` enum('SOCIAL_MEDIA','NEW_PRODUCT','SAAS_DEV') NOT NULL,
  `status` enum('NEW','IN_PROGRESS','IN_REVIEW','APPROVED','PUBLISHED','REJECTED') NOT NULL DEFAULT 'NEW',
  `title` varchar(255) NOT NULL,
  `description` text DEFAULT NULL,
  `meta_json` text DEFAULT NULL COMMENT 'Optional structured metadata as JSON',
  `shop_id` int(10) UNSIGNED DEFAULT NULL COMMENT 'Franchisee shop scope (no id_brand)',
  `created_by_user_id` int(10) UNSIGNED NOT NULL COMMENT 'auth_user.id of the creator',
  `assigned_to_user_id` int(10) UNSIGNED DEFAULT NULL COMMENT 'auth_user.id of assigned admin',
  `created_at` datetime NOT NULL DEFAULT current_timestamp(),
  `updated_at` datetime NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

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

--
-- Struktura tabeli dla tabeli `demand_comment`
--

CREATE TABLE `demand_comment` (
  `id` int(10) UNSIGNED NOT NULL,
  `demand_id` int(10) UNSIGNED NOT NULL,
  `author_user_id` int(10) UNSIGNED NOT NULL COMMENT 'auth_user.id',
  `body` text NOT NULL,
  `is_internal` tinyint(1) NOT NULL DEFAULT 0 COMMENT '1 = visible only to admins',
  `created_at` datetime NOT NULL DEFAULT current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

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

--
-- Struktura tabeli dla tabeli `demand_status_history`
--

CREATE TABLE `demand_status_history` (
  `id` int(10) UNSIGNED NOT NULL,
  `demand_id` int(10) UNSIGNED NOT NULL,
  `changed_by_user_id` int(10) UNSIGNED NOT NULL COMMENT 'auth_user.id of admin who changed status',
  `status_from` varchar(32) NOT NULL,
  `status_to` varchar(32) NOT NULL,
  `note` varchar(512) DEFAULT NULL,
  `created_at` datetime NOT NULL DEFAULT current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

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

--
-- Struktura tabeli dla tabeli `device_auth_session`
--

CREATE TABLE `device_auth_session` (
  `id` int(11) NOT NULL,
  `device_id` int(11) NOT NULL,
  `token_hash` varbinary(32) NOT NULL,
  `expires_at` datetime NOT NULL,
  `revoked_at` datetime DEFAULT NULL,
  `replaced_by_id` int(11) DEFAULT NULL,
  `ip_created` varchar(45) DEFAULT NULL,
  `user_agent` varchar(255) DEFAULT NULL,
  `created_at` datetime NOT NULL DEFAULT current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `device_withdrawing_money`
--

CREATE TABLE `device_withdrawing_money` (
  `id` int(11) NOT NULL,
  `id_employee` int(11) NOT NULL,
  `id_device` int(11) NOT NULL,
  `amount` decimal(10,2) NOT NULL,
  `id_reason` int(11) NOT NULL,
  `withdrawing_timestamp` timestamp NOT NULL DEFAULT current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `domain_functional_category`
--

CREATE TABLE `domain_functional_category` (
  `id` int(11) NOT NULL,
  `name` varchar(255) NOT NULL,
  `description` text NOT NULL,
  `section_id` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `domain_functional_category_description_alias`
--

CREATE TABLE `domain_functional_category_description_alias` (
  `id` int(11) NOT NULL,
  `category_id` int(11) NOT NULL,
  `lang_code` varchar(5) NOT NULL,
  `alias` varchar(255) NOT NULL,
  `alias_type` varchar(50) NOT NULL DEFAULT 'default',
  `create_timestamp` datetime NOT NULL DEFAULT current_timestamp(),
  `update_timestamp` datetime NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `domain_functional_category_name_alias`
--

CREATE TABLE `domain_functional_category_name_alias` (
  `id` int(11) NOT NULL,
  `category_id` int(11) NOT NULL,
  `lang_code` varchar(5) NOT NULL,
  `alias` varchar(255) NOT NULL,
  `alias_type` varchar(50) NOT NULL DEFAULT 'default',
  `create_timestamp` datetime NOT NULL DEFAULT current_timestamp(),
  `update_timestamp` datetime NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `domain_functional_section`
--

CREATE TABLE `domain_functional_section` (
  `id` int(11) NOT NULL,
  `name` varchar(255) NOT NULL,
  `description` text NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `domain_functional_section_description_alias`
--

CREATE TABLE `domain_functional_section_description_alias` (
  `id` int(11) NOT NULL,
  `section_id` int(11) NOT NULL,
  `lang_code` varchar(5) NOT NULL,
  `alias` varchar(255) NOT NULL,
  `alias_type` varchar(50) NOT NULL DEFAULT 'default',
  `create_timestamp` datetime NOT NULL DEFAULT current_timestamp(),
  `update_timestamp` datetime NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `domain_functional_section_name_alias`
--

CREATE TABLE `domain_functional_section_name_alias` (
  `id` int(11) NOT NULL,
  `section_id` int(11) NOT NULL,
  `lang_code` varchar(5) NOT NULL,
  `alias` varchar(255) NOT NULL,
  `alias_type` varchar(50) NOT NULL DEFAULT 'default',
  `create_timestamp` datetime NOT NULL DEFAULT current_timestamp(),
  `update_timestamp` datetime NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `domain_functional_subcategory`
--

CREATE TABLE `domain_functional_subcategory` (
  `id` int(11) NOT NULL,
  `name` varchar(255) NOT NULL,
  `description` text NOT NULL,
  `category_id` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `domain_functional_subcategory_description_alias`
--

CREATE TABLE `domain_functional_subcategory_description_alias` (
  `id` int(11) NOT NULL,
  `subcategory_id` int(11) NOT NULL,
  `lang_code` varchar(5) NOT NULL,
  `alias` varchar(255) NOT NULL,
  `alias_type` varchar(50) NOT NULL DEFAULT 'default',
  `create_timestamp` datetime NOT NULL DEFAULT current_timestamp(),
  `update_timestamp` datetime NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `domain_functional_subcategory_name_alias`
--

CREATE TABLE `domain_functional_subcategory_name_alias` (
  `id` int(11) NOT NULL,
  `subcategory_id` int(11) NOT NULL,
  `lang_code` varchar(5) NOT NULL,
  `alias` varchar(255) NOT NULL,
  `alias_type` varchar(50) NOT NULL DEFAULT 'default',
  `create_timestamp` datetime NOT NULL DEFAULT current_timestamp(),
  `update_timestamp` datetime NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `email_log`
--

CREATE TABLE `email_log` (
  `id` bigint(20) NOT NULL,
  `id_shop` int(11) NOT NULL,
  `recipient_email` varchar(255) NOT NULL,
  `recipient_name` varchar(255) DEFAULT NULL,
  `subject` text NOT NULL,
  `body` mediumtext NOT NULL,
  `sent_at` datetime NOT NULL DEFAULT current_timestamp(),
  `status` enum('success','failure') NOT NULL,
  `error_message` text DEFAULT NULL,
  `email_type` varchar(100) DEFAULT NULL,
  `id_employee` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `email_template`
--

CREATE TABLE `email_template` (
  `id` int(11) NOT NULL,
  `id_shop` int(11) NOT NULL,
  `email_type` varchar(50) NOT NULL,
  `email_bc` varchar(255) NOT NULL DEFAULT '',
  `email_bcc` varchar(255) NOT NULL DEFAULT '',
  `subject_content` text NOT NULL,
  `body_content` text NOT NULL,
  `franchisee_additional_body` text NOT NULL,
  `franchisor_additional_body` text NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `employee_competency_connection`
--

CREATE TABLE `employee_competency_connection` (
  `id` int(11) NOT NULL,
  `employee_id` int(11) NOT NULL,
  `competency_id` int(11) NOT NULL,
  `created_at` timestamp NOT NULL DEFAULT current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `employee_position_connection`
--

CREATE TABLE `employee_position_connection` (
  `id` int(11) NOT NULL,
  `employee_id` int(11) NOT NULL,
  `position_id` int(11) NOT NULL,
  `level_id` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `employee_role`
--

CREATE TABLE `employee_role` (
  `id` int(11) NOT NULL,
  `name` varchar(255) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `employee_workstation_connection`
--

CREATE TABLE `employee_workstation_connection` (
  `employee_id` int(11) NOT NULL,
  `workstation_id` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `external_supplier_auth`
--

CREATE TABLE `external_supplier_auth` (
  `id` int(11) NOT NULL,
  `supplier_id` int(11) NOT NULL,
  `login` varchar(255) NOT NULL,
  `password_hash` varchar(255) NOT NULL,
  `lang_code` varchar(5) NOT NULL,
  `first_name` varchar(255) NOT NULL,
  `last_name` varchar(255) NOT NULL,
  `phone` varchar(255) DEFAULT NULL,
  `created_at` datetime NOT NULL DEFAULT current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `external_supplier_auth_session`
--

CREATE TABLE `external_supplier_auth_session` (
  `id` int(11) NOT NULL,
  `external_supplier_auth_id` int(11) NOT NULL,
  `token_hash` varbinary(32) NOT NULL,
  `expires_at` datetime NOT NULL,
  `revoked_at` datetime DEFAULT NULL,
  `replaced_by_id` int(11) DEFAULT NULL,
  `ip_created` varchar(45) DEFAULT NULL,
  `user_agent` varchar(255) DEFAULT NULL,
  `created_at` datetime NOT NULL DEFAULT current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `file_attachment`
--

CREATE TABLE `file_attachment` (
  `id` int(11) NOT NULL,
  `shop_id` int(11) DEFAULT NULL,
  `related_type` varchar(32) NOT NULL,
  `related_id` int(11) NOT NULL,
  `object_key` text NOT NULL,
  `original_name` varchar(255) DEFAULT NULL,
  `mime_type` varchar(64) DEFAULT NULL,
  `size_bytes` int(11) DEFAULT NULL,
  `created_at` datetime DEFAULT current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `flattened_recipe_for_label`
--

CREATE TABLE `flattened_recipe_for_label` (
  `id_recipe` int(11) NOT NULL,
  `lang_code` varchar(6) NOT NULL,
  `ingredients_text` text NOT NULL,
  `last_generated_at` datetime NOT NULL DEFAULT current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `flattened_recipe_ingredient`
--

CREATE TABLE `flattened_recipe_ingredient` (
  `id_recipe` int(11) NOT NULL,
  `id_material` int(11) NOT NULL,
  `quantity` decimal(10,2) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `flattened_recipe_recipe`
--

CREATE TABLE `flattened_recipe_recipe` (
  `id_recipe` int(11) NOT NULL,
  `id_subrecipe` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `franchisee_brand`
--

CREATE TABLE `franchisee_brand` (
  `id` int(11) NOT NULL,
  `name` varchar(255) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `franchisee_category_availability`
--

CREATE TABLE `franchisee_category_availability` (
  `id_shop` int(11) NOT NULL,
  `id_category` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `franchisee_employee`
--

CREATE TABLE `franchisee_employee` (
  `id` int(11) NOT NULL,
  `id_shop` int(11) NOT NULL,
  `name` varchar(255) NOT NULL,
  `surname` varchar(255) NOT NULL,
  `display_name` varchar(255) NOT NULL,
  `phone` varchar(35) NOT NULL,
  `lang_code` varchar(5) NOT NULL,
  `id_role` int(11) NOT NULL DEFAULT 1,
  `login` varchar(255) NOT NULL,
  `password` varchar(255) NOT NULL,
  `refresh_token` text NOT NULL,
  `create_timestamp` timestamp NOT NULL DEFAULT current_timestamp(),
  `money_per_hour` decimal(10,2) NOT NULL DEFAULT 0.00,
  `id_production_area` int(11) DEFAULT NULL,
  `email` varchar(255) NOT NULL DEFAULT '',
  `pin` varchar(6) NOT NULL DEFAULT ''
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `franchisee_employee_competence`
--

CREATE TABLE `franchisee_employee_competence` (
  `id_brand` int(11) NOT NULL,
  `id` int(11) NOT NULL,
  `name` varchar(255) NOT NULL,
  `description` text NOT NULL,
  `related_link` text DEFAULT NULL,
  `related_file` text DEFAULT NULL,
  `id_subgroup` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `franchisee_employee_competence_description_alias`
--

CREATE TABLE `franchisee_employee_competence_description_alias` (
  `id` int(11) NOT NULL,
  `id_competence` int(11) NOT NULL,
  `lang_code` varchar(5) NOT NULL,
  `alias` text NOT NULL,
  `alias_type` varchar(50) NOT NULL DEFAULT 'default',
  `create_timestamp` datetime NOT NULL DEFAULT current_timestamp(),
  `update_timestamp` datetime NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `franchisee_employee_competence_group`
--

CREATE TABLE `franchisee_employee_competence_group` (
  `id_brand` int(11) NOT NULL,
  `id` int(11) NOT NULL,
  `name` varchar(255) NOT NULL,
  `description` text NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `franchisee_employee_competence_group_description_alias`
--

CREATE TABLE `franchisee_employee_competence_group_description_alias` (
  `id` int(11) NOT NULL,
  `id_competence_group` int(11) NOT NULL,
  `lang_code` varchar(5) NOT NULL,
  `alias` text NOT NULL,
  `alias_type` varchar(50) NOT NULL DEFAULT 'default',
  `create_timestamp` datetime NOT NULL DEFAULT current_timestamp(),
  `update_timestamp` datetime NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `franchisee_employee_competence_group_name_alias`
--

CREATE TABLE `franchisee_employee_competence_group_name_alias` (
  `id` int(11) NOT NULL,
  `id_competence_group` int(11) NOT NULL,
  `lang_code` varchar(5) NOT NULL,
  `alias` varchar(255) NOT NULL,
  `alias_type` varchar(50) NOT NULL DEFAULT 'default',
  `create_timestamp` datetime NOT NULL DEFAULT current_timestamp(),
  `update_timestamp` datetime NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `franchisee_employee_competence_name_alias`
--

CREATE TABLE `franchisee_employee_competence_name_alias` (
  `id` int(11) NOT NULL,
  `id_competence` int(11) NOT NULL,
  `lang_code` varchar(5) NOT NULL,
  `alias` varchar(255) NOT NULL,
  `alias_type` varchar(50) NOT NULL DEFAULT 'default',
  `create_timestamp` datetime NOT NULL DEFAULT current_timestamp(),
  `update_timestamp` datetime NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `franchisee_employee_competence_subgroup`
--

CREATE TABLE `franchisee_employee_competence_subgroup` (
  `id` int(11) NOT NULL,
  `id_group` int(11) NOT NULL,
  `name` varchar(255) NOT NULL,
  `description` text NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `franchisee_employee_competence_subgroup_description_alias`
--

CREATE TABLE `franchisee_employee_competence_subgroup_description_alias` (
  `id` int(11) NOT NULL,
  `id_subgroup` int(11) NOT NULL,
  `lang_code` varchar(5) NOT NULL,
  `alias` text NOT NULL,
  `alias_type` varchar(50) NOT NULL DEFAULT 'default',
  `create_timestamp` datetime NOT NULL DEFAULT current_timestamp(),
  `update_timestamp` datetime NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `franchisee_employee_competence_subgroup_name_alias`
--

CREATE TABLE `franchisee_employee_competence_subgroup_name_alias` (
  `id` int(11) NOT NULL,
  `id_subgroup` int(11) NOT NULL,
  `lang_code` varchar(5) NOT NULL,
  `alias` varchar(255) NOT NULL,
  `alias_type` varchar(50) NOT NULL DEFAULT 'default',
  `create_timestamp` datetime NOT NULL DEFAULT current_timestamp(),
  `update_timestamp` datetime NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `franchisee_employee_production_area`
--

CREATE TABLE `franchisee_employee_production_area` (
  `id` int(11) NOT NULL,
  `id_brand` int(11) NOT NULL,
  `name` varchar(255) NOT NULL,
  `description` text NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `franchisee_employee_production_area_description_alias`
--

CREATE TABLE `franchisee_employee_production_area_description_alias` (
  `id` int(11) NOT NULL,
  `id_production_area` int(11) NOT NULL,
  `lang_code` varchar(5) NOT NULL,
  `alias` text NOT NULL,
  `alias_type` varchar(50) NOT NULL DEFAULT 'default',
  `create_timestamp` datetime NOT NULL DEFAULT current_timestamp(),
  `update_timestamp` datetime NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `franchisee_employee_production_area_name_alias`
--

CREATE TABLE `franchisee_employee_production_area_name_alias` (
  `id` int(11) NOT NULL,
  `id_production_area` int(11) NOT NULL,
  `lang_code` varchar(5) NOT NULL,
  `alias` varchar(255) NOT NULL,
  `alias_type` varchar(50) NOT NULL DEFAULT 'default',
  `create_timestamp` datetime NOT NULL DEFAULT current_timestamp(),
  `update_timestamp` datetime NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `franchisee_employee_production_role`
--

CREATE TABLE `franchisee_employee_production_role` (
  `id` int(11) NOT NULL,
  `id_brand` int(11) NOT NULL,
  `name` varchar(255) NOT NULL,
  `description` text NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `franchisee_employee_role`
--

CREATE TABLE `franchisee_employee_role` (
  `id_brand` int(11) NOT NULL,
  `id` int(11) NOT NULL,
  `name` varchar(255) NOT NULL,
  `description` text NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `franchisee_employee_role_connection`
--

CREATE TABLE `franchisee_employee_role_connection` (
  `id_employee` int(11) NOT NULL,
  `id_employee_role` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `franchisee_employee_role_course_connection`
--

CREATE TABLE `franchisee_employee_role_course_connection` (
  `id_employee_role` int(11) NOT NULL,
  `id_course` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `franchisee_employee_role_skill_connection`
--

CREATE TABLE `franchisee_employee_role_skill_connection` (
  `id_role` int(11) NOT NULL,
  `id_skill` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `franchisee_employee_schedule`
--

CREATE TABLE `franchisee_employee_schedule` (
  `id` int(11) NOT NULL,
  `id_employee` int(11) NOT NULL,
  `start_hour` time NOT NULL,
  `end_hour` time NOT NULL,
  `work_date` date NOT NULL,
  `create_timestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `franchisee_employee_workstation`
--

CREATE TABLE `franchisee_employee_workstation` (
  `id` int(11) NOT NULL,
  `id_brand` int(11) NOT NULL,
  `name` varchar(255) NOT NULL,
  `description` text NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `franchisee_employee_workstation_alias`
--

CREATE TABLE `franchisee_employee_workstation_alias` (
  `id` int(11) NOT NULL,
  `id_workstation` int(11) NOT NULL,
  `lang_code` varchar(5) NOT NULL,
  `alias` varchar(255) NOT NULL,
  `alias_type` varchar(50) NOT NULL DEFAULT 'default',
  `create_timestamp` datetime NOT NULL DEFAULT current_timestamp(),
  `update_timestamp` datetime NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `franchisee_employee_workstation_connection`
--

CREATE TABLE `franchisee_employee_workstation_connection` (
  `id_workstation` int(11) NOT NULL,
  `id_employee` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `franchisee_shop`
--

CREATE TABLE `franchisee_shop` (
  `id_brand` int(11) NOT NULL,
  `id` int(11) NOT NULL,
  `representative_name` text NOT NULL,
  `name` varchar(255) NOT NULL,
  `email` varchar(255) NOT NULL,
  `email_password` varchar(255) NOT NULL DEFAULT '',
  `street` varchar(255) NOT NULL,
  `street_num` varchar(10) NOT NULL,
  `city` varchar(255) NOT NULL,
  `zip` varchar(15) NOT NULL,
  `phone` varchar(255) NOT NULL,
  `opening_hour` int(11) NOT NULL,
  `opening_minute` int(11) NOT NULL,
  `closing_hour` int(11) NOT NULL,
  `closing_minute` int(11) NOT NULL,
  `tax_number_prefixe` varchar(5) NOT NULL,
  `tax_number` varchar(255) NOT NULL DEFAULT '',
  `bank_account_number` varchar(255) NOT NULL,
  `bank_name` varchar(255) NOT NULL,
  `bank_swift` varchar(255) NOT NULL,
  `bank_iban` varchar(255) NOT NULL,
  `country_code` char(2) NOT NULL,
  `peppol_id` varchar(64) DEFAULT NULL,
  `peppol_verified` tinyint(1) NOT NULL DEFAULT 0
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `franchisee_shop_device`
--

CREATE TABLE `franchisee_shop_device` (
  `id` int(11) NOT NULL,
  `id_shop` int(11) NOT NULL,
  `login` varchar(255) NOT NULL,
  `password` varchar(255) NOT NULL,
  `device_connection_key` varchar(255) NOT NULL,
  `name` varchar(255) NOT NULL,
  `register_datetime` datetime NOT NULL DEFAULT current_timestamp(),
  `refresh_token` varchar(255) NOT NULL DEFAULT '',
  `admin_pin` varchar(5) NOT NULL DEFAULT '12',
  `configuration` varchar(25) NOT NULL DEFAULT 'fr',
  `type` enum('pos','kitchen_tablet') NOT NULL DEFAULT 'pos'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `franchisee_system_user_role`
--

CREATE TABLE `franchisee_system_user_role` (
  `id_brand` int(11) NOT NULL,
  `id` int(11) NOT NULL,
  `name` varchar(255) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `franchisee_task_type`
--

CREATE TABLE `franchisee_task_type` (
  `id` int(11) NOT NULL,
  `name` varchar(255) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `franchisee_task_type_alias`
--

CREATE TABLE `franchisee_task_type_alias` (
  `id` int(11) NOT NULL,
  `id_task_type` int(11) NOT NULL,
  `lang_code` varchar(5) NOT NULL,
  `alias` varchar(255) NOT NULL,
  `alias_type` varchar(50) NOT NULL DEFAULT 'default',
  `create_timestamp` datetime NOT NULL DEFAULT current_timestamp(),
  `update_timestamp` datetime NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `knowledge_base_resource`
--

CREATE TABLE `knowledge_base_resource` (
  `id` int(11) NOT NULL,
  `title` varchar(200) NOT NULL,
  `slug` varchar(220) NOT NULL,
  `summary` text DEFAULT NULL,
  `url` varchar(2048) NOT NULL,
  `id_category` int(11) NOT NULL,
  `status` enum('draft','published','archived') NOT NULL DEFAULT 'published',
  `publish_at` datetime DEFAULT NULL,
  `expires_at` datetime DEFAULT NULL,
  `created_by` int(11) DEFAULT NULL,
  `updated_by` int(11) DEFAULT NULL,
  `created_at` timestamp NOT NULL DEFAULT current_timestamp(),
  `updated_at` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
  `ulid_str` char(26) CHARACTER SET ascii COLLATE ascii_bin DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `knowledge_base_resource_category`
--

CREATE TABLE `knowledge_base_resource_category` (
  `id` int(11) NOT NULL,
  `name` varchar(255) NOT NULL,
  `created_at` datetime DEFAULT current_timestamp(),
  `updated_at` datetime DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `knowledge_base_resource_shop_connection`
--

CREATE TABLE `knowledge_base_resource_shop_connection` (
  `id_resource` int(11) NOT NULL,
  `id_shop` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `marketing_campaign`
--

CREATE TABLE `marketing_campaign` (
  `id_brand` int(11) NOT NULL,
  `id` int(11) NOT NULL,
  `name` text NOT NULL,
  `start_date` date NOT NULL,
  `end_date` date NOT NULL,
  `link` text NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `marketing_campaign_alias`
--

CREATE TABLE `marketing_campaign_alias` (
  `id` int(11) NOT NULL,
  `id_marketing_campaign` int(11) NOT NULL,
  `lang_code` varchar(5) NOT NULL,
  `alias` varchar(255) NOT NULL,
  `alias_type` varchar(50) NOT NULL DEFAULT 'default',
  `create_timestamp` datetime NOT NULL DEFAULT current_timestamp(),
  `update_timestamp` datetime NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `marketing_material`
--

CREATE TABLE `marketing_material` (
  `id` int(11) NOT NULL,
  `title` varchar(200) NOT NULL,
  `slug` varchar(220) NOT NULL,
  `summary` text DEFAULT NULL,
  `url` varchar(2048) NOT NULL,
  `primary_type` enum('logo','photo','document','video','other') DEFAULT NULL,
  `status` enum('draft','published','archived') NOT NULL DEFAULT 'published',
  `publish_at` datetime DEFAULT NULL,
  `expires_at` datetime DEFAULT NULL,
  `created_by` int(11) DEFAULT NULL,
  `updated_by` int(11) DEFAULT NULL,
  `created_at` timestamp NOT NULL DEFAULT current_timestamp(),
  `updated_at` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
  `ulid_str` char(26) CHARACTER SET ascii COLLATE ascii_bin DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `marketing_material_shop_connection`
--

CREATE TABLE `marketing_material_shop_connection` (
  `id_material` int(11) NOT NULL,
  `id_shop` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `marketing_material_summary_alias`
--

CREATE TABLE `marketing_material_summary_alias` (
  `id` int(11) NOT NULL,
  `id_marketing_material` int(11) NOT NULL,
  `lang_code` varchar(5) NOT NULL,
  `alias` text NOT NULL,
  `alias_type` varchar(50) NOT NULL DEFAULT 'default',
  `create_timestamp` datetime NOT NULL DEFAULT current_timestamp(),
  `update_timestamp` datetime NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `marketing_material_title_alias`
--

CREATE TABLE `marketing_material_title_alias` (
  `id` int(11) NOT NULL,
  `id_marketing_material` int(11) NOT NULL,
  `lang_code` varchar(5) NOT NULL,
  `alias` varchar(255) NOT NULL,
  `alias_type` varchar(50) NOT NULL DEFAULT 'default',
  `create_timestamp` datetime NOT NULL DEFAULT current_timestamp(),
  `update_timestamp` datetime NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `material`
--

CREATE TABLE `material` (
  `id_brand` int(11) NOT NULL,
  `id` int(11) NOT NULL,
  `name` varchar(255) NOT NULL,
  `id_category` int(11) NOT NULL,
  `id_unit` int(11) NOT NULL,
  `is_part_of_package` tinyint(1) NOT NULL DEFAULT 0,
  `waste_amount_perc` int(11) NOT NULL DEFAULT 0,
  `source_type` varchar(25) NOT NULL COMMENT 'CENTRAL, OPEN	',
  `kind` enum('simple','composite') NOT NULL DEFAULT 'simple'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `material_alias`
--

CREATE TABLE `material_alias` (
  `id` int(11) NOT NULL,
  `id_material` int(11) NOT NULL,
  `lang_code` varchar(5) NOT NULL,
  `alias` varchar(255) NOT NULL,
  `alias_type` varchar(50) NOT NULL DEFAULT 'default',
  `create_timestamp` datetime NOT NULL DEFAULT current_timestamp(),
  `update_timestamp` datetime NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `material_allergen_connection`
--

CREATE TABLE `material_allergen_connection` (
  `id_material` int(11) NOT NULL,
  `id_allergen` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `material_category`
--

CREATE TABLE `material_category` (
  `id_brand` int(11) NOT NULL,
  `id` int(11) NOT NULL,
  `name` varchar(255) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `material_category_alias`
--

CREATE TABLE `material_category_alias` (
  `id` int(11) NOT NULL,
  `id_material_category` int(11) NOT NULL,
  `lang_code` varchar(5) NOT NULL,
  `alias` varchar(255) NOT NULL,
  `alias_type` varchar(50) NOT NULL DEFAULT 'default',
  `create_timestamp` datetime NOT NULL DEFAULT current_timestamp(),
  `update_timestamp` datetime NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `material_country_vat_rates_connection`
--

CREATE TABLE `material_country_vat_rates_connection` (
  `id` int(11) NOT NULL,
  `id_material` int(11) NOT NULL,
  `country_code` char(2) NOT NULL,
  `vat_rate` decimal(5,2) NOT NULL,
  `valid_from` date NOT NULL DEFAULT curdate(),
  `valid_to` date DEFAULT NULL,
  `created_at` timestamp NOT NULL DEFAULT current_timestamp(),
  `updated_at` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `material_inventory`
--

CREATE TABLE `material_inventory` (
  `id` int(11) NOT NULL,
  `id_shop` int(11) NOT NULL,
  `id_material` int(11) NOT NULL,
  `current_quantity` decimal(22,2) NOT NULL DEFAULT 0.00,
  `minimum_quantity_per_day` decimal(22,2) NOT NULL DEFAULT 0.00,
  `last_modified` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `material_inventory_log`
--

CREATE TABLE `material_inventory_log` (
  `id` int(11) NOT NULL,
  `id_shop` int(11) NOT NULL,
  `id_employee` int(11) NOT NULL,
  `id_material` int(11) NOT NULL,
  `change_quantity_in_base_unit` decimal(22,2) NOT NULL,
  `change_type` varchar(25) NOT NULL,
  `reason` varchar(35) NOT NULL,
  `id_order` int(11) DEFAULT NULL,
  `id_stocktaking` bigint(20) DEFAULT NULL,
  `previous_balance` decimal(22,2) NOT NULL,
  `new_balance` decimal(22,2) NOT NULL,
  `note` text DEFAULT NULL,
  `created_at` timestamp NOT NULL DEFAULT current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `material_movement_reason`
--

CREATE TABLE `material_movement_reason` (
  `code` varchar(32) NOT NULL COMMENT 'skrót powodu, np. ORDER, ADJUST, RETURN'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `material_order`
--

CREATE TABLE `material_order` (
  `id` int(11) NOT NULL,
  `order_key` varchar(150) NOT NULL,
  `id_shop` int(11) NOT NULL,
  `id_supplier` int(11) NOT NULL,
  `id_requisition` int(11) NOT NULL,
  `id_employee` int(11) NOT NULL,
  `order_date` datetime NOT NULL DEFAULT current_timestamp(),
  `in_transit_sent_at` datetime DEFAULT NULL,
  `in_transit_expected_date` date DEFAULT NULL,
  `carrier_info` longtext DEFAULT NULL,
  `expected_date` date NOT NULL,
  `delivered_on` datetime DEFAULT NULL,
  `status` varchar(25) NOT NULL COMMENT '''NEW'', ''IN_TRANSIT'', ''DELIVERED'',''CANCELLED'' ',
  `sending_email_date` datetime DEFAULT NULL,
  `rabbitmq_send_attempts` int(10) UNSIGNED NOT NULL DEFAULT 0,
  `rabbitmq_last_send_at` datetime DEFAULT NULL,
  `rabbitmq_send_status` enum('pending','sent','failed','acknowledged','sending','sent_but_failed_to_log') DEFAULT NULL,
  `rabbitmq_acknowledged_at` datetime DEFAULT NULL,
  `proforma_status` varchar(25) DEFAULT NULL,
  `proforma_uuid` char(36) DEFAULT NULL,
  `proforma_received_at` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `material_order_in_transit_item`
--

CREATE TABLE `material_order_in_transit_item` (
  `id` int(11) NOT NULL,
  `id_order` int(11) NOT NULL,
  `id_material` int(11) DEFAULT NULL,
  `supplier_sku` varchar(150) NOT NULL,
  `declared_name` varchar(255) DEFAULT NULL,
  `declared_pack_qty` int(11) NOT NULL,
  `pack_size_in_base_unit` int(11) NOT NULL,
  `id_unit` int(11) NOT NULL,
  `pack_price_net` decimal(22,6) NOT NULL,
  `created_at` datetime NOT NULL DEFAULT current_timestamp(),
  `updated_at` datetime NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `material_order_item`
--

CREATE TABLE `material_order_item` (
  `id` int(11) NOT NULL,
  `id_order` int(11) NOT NULL,
  `id_material` int(11) NOT NULL,
  `id_pack` int(11) DEFAULT NULL,
  `id_supplier` int(11) NOT NULL,
  `supplier_sku` varchar(150) NOT NULL,
  `material_name` varchar(255) NOT NULL,
  `pack_quantity` int(11) NOT NULL,
  `pack_size_in_base_unit` int(11) NOT NULL,
  `id_unit` int(11) NOT NULL,
  `pack_price_net` decimal(22,6) NOT NULL,
  `status` varchar(15) NOT NULL COMMENT '	PENDING, SUPPLIED, REJECTED	'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `material_order_item_delivery_log`
--

CREATE TABLE `material_order_item_delivery_log` (
  `id_order` int(11) NOT NULL,
  `supplier_sku` varchar(150) NOT NULL,
  `id_material` int(11) NOT NULL,
  `ordered_pack_qty` int(11) NOT NULL,
  `delivered_pack_qty` int(11) NOT NULL,
  `pack_diff_qty` int(11) NOT NULL,
  `pack_size_in_base_unit` int(11) NOT NULL,
  `id_unit` int(11) NOT NULL,
  `pack_price` decimal(22,6) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `material_pack`
--

CREATE TABLE `material_pack` (
  `id` int(11) NOT NULL,
  `country_code` varchar(5) NOT NULL,
  `added_by_id_shop` int(11) NOT NULL,
  `id_material` int(11) NOT NULL,
  `identifier_type` varchar(20) NOT NULL COMMENT '''EAN13'',''SUPPLIER'',''REGEX''',
  `identifier_value` varchar(100) NOT NULL,
  `identifier_regex` text DEFAULT NULL,
  `package_size_in_base_unit` int(11) NOT NULL,
  `id_unit` int(11) NOT NULL,
  `description` text NOT NULL,
  `soft_delete` int(11) NOT NULL DEFAULT 0
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `material_proforma_documents`
--

CREATE TABLE `material_proforma_documents` (
  `id` int(11) NOT NULL,
  `proforma_uuid` char(36) NOT NULL,
  `order_key` varchar(55) NOT NULL,
  `shop_uid` char(26) NOT NULL,
  `s3_bucket` varchar(128) NOT NULL,
  `s3_key` varchar(512) NOT NULL,
  `checksum_sha256` char(64) NOT NULL,
  `size_bytes` int(11) NOT NULL,
  `issued_at` datetime DEFAULT NULL,
  `raw_data_json` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL,
  `created_at` datetime NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `material_proforma_download_log`
--

CREATE TABLE `material_proforma_download_log` (
  `id` bigint(20) NOT NULL,
  `proforma_uuid` char(36) NOT NULL,
  `shop_id` bigint(20) NOT NULL,
  `requested_at` datetime NOT NULL DEFAULT current_timestamp(),
  `outcome` enum('issued','denied') NOT NULL,
  `shop_ip` varbinary(16) DEFAULT NULL,
  `ua_hash` char(40) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `material_proforma_download_quota`
--

CREATE TABLE `material_proforma_download_quota` (
  `proforma_uuid` char(36) NOT NULL,
  `shop_id` bigint(20) NOT NULL,
  `day_date` date NOT NULL,
  `cnt` int(10) UNSIGNED NOT NULL DEFAULT 0,
  `updated_at` datetime NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `material_proforma_receipts`
--

CREATE TABLE `material_proforma_receipts` (
  `id` int(11) NOT NULL,
  `idempotency_key` varchar(128) NOT NULL,
  `order_key` varchar(64) NOT NULL,
  `proforma_uuid` char(36) NOT NULL,
  `received_at` datetime NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `material_requisition`
--

CREATE TABLE `material_requisition` (
  `id` int(11) NOT NULL,
  `id_shop` int(11) NOT NULL,
  `id_employee` int(11) NOT NULL,
  `requisition_period_days` int(11) NOT NULL,
  `beginning_of_period` date NOT NULL,
  `sales_forecast` int(11) NOT NULL,
  `type_of_requisition` varchar(50) NOT NULL COMMENT 'STANDARD, STOCK_MINIMUM',
  `status` varchar(50) NOT NULL DEFAULT 'PENDING' COMMENT '	PENDING, REALISED, REJECTED',
  `created_at` datetime NOT NULL DEFAULT current_timestamp(),
  `updated_at` datetime NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `material_requisition_item`
--

CREATE TABLE `material_requisition_item` (
  `id` int(11) NOT NULL,
  `id_requisition` int(11) NOT NULL,
  `id_material` int(11) NOT NULL,
  `in_stock_quantity` int(11) NOT NULL DEFAULT 0,
  `in_order` int(11) NOT NULL DEFAULT 0,
  `minimum_quantity` int(11) NOT NULL DEFAULT 0,
  `usage_period` int(11) NOT NULL DEFAULT 0,
  `order_by_client` int(11) NOT NULL DEFAULT 0,
  `markup_qty` int(11) NOT NULL DEFAULT 0,
  `qty_to_order` int(11) NOT NULL DEFAULT 0,
  `ordered_qty` int(11) NOT NULL DEFAULT 0,
  `base_unit_price_net` decimal(22,6) NOT NULL DEFAULT 0.000000,
  `vat_rate` decimal(10,2) NOT NULL DEFAULT 0.00,
  `base_unit_price_gross` decimal(22,6) NOT NULL,
  `total_value_gross` decimal(22,2) NOT NULL,
  `id_unit` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `material_supplier`
--

CREATE TABLE `material_supplier` (
  `id_brand` int(11) NOT NULL,
  `id` int(11) NOT NULL,
  `id_type` int(11) NOT NULL,
  `added_by_shop_id` int(11) DEFAULT NULL,
  `name` varchar(255) NOT NULL,
  `tax_number` varchar(255) NOT NULL,
  `street` varchar(255) NOT NULL DEFAULT '',
  `street_number` varchar(255) NOT NULL DEFAULT '',
  `city` varchar(255) NOT NULL DEFAULT '',
  `zip` varchar(255) NOT NULL DEFAULT '',
  `phone` varchar(255) NOT NULL DEFAULT '',
  `email` varchar(255) NOT NULL DEFAULT '',
  `country_code` varchar(2) NOT NULL,
  `integrated_supplier` tinyint(1) NOT NULL DEFAULT 0,
  `type` varchar(25) NOT NULL COMMENT 'CENTRAL, OPEN'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `material_supplier_api_connection`
--

CREATE TABLE `material_supplier_api_connection` (
  `id` int(11) NOT NULL,
  `id_supplier` int(11) DEFAULT NULL,
  `id_shop` int(11) NOT NULL,
  `token` varchar(64) NOT NULL,
  `franchisee_code` varchar(64) NOT NULL,
  `name` varchar(255) DEFAULT 'Production',
  `created_at` datetime DEFAULT current_timestamp(),
  `expires_at` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `material_supplier_contact`
--

CREATE TABLE `material_supplier_contact` (
  `id` int(11) NOT NULL,
  `id_shop` int(11) NOT NULL,
  `id_supplier` int(11) NOT NULL,
  `name` varchar(255) DEFAULT NULL,
  `phone` varchar(50) DEFAULT NULL,
  `email` varchar(255) DEFAULT NULL,
  `note` text DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `material_supplier_type`
--

CREATE TABLE `material_supplier_type` (
  `id` int(11) NOT NULL,
  `code` varchar(100) DEFAULT NULL,
  `editable_price_by_franchisee` tinyint(1) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `membership_position_level`
--

CREATE TABLE `membership_position_level` (
  `membership_id` int(11) NOT NULL,
  `position_id` int(11) NOT NULL,
  `level_id` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `network_countries`
--

CREATE TABLE `network_countries` (
  `id` int(11) NOT NULL,
  `iso2` char(2) NOT NULL,
  `name` varchar(100) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `network_franchise_types`
--

CREATE TABLE `network_franchise_types` (
  `id` int(11) NOT NULL,
  `code` varchar(64) NOT NULL,
  `label` varchar(128) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `notification`
--

CREATE TABLE `notification` (
  `id` int(11) NOT NULL,
  `title` varchar(255) NOT NULL,
  `message` text NOT NULL,
  `priority` enum('info','warning','urgent') DEFAULT 'info',
  `type` enum('once','daily','weekly','cyclic') DEFAULT 'once',
  `day_of_week` tinyint(4) DEFAULT NULL,
  `repeat_interval` int(11) DEFAULT NULL,
  `status` enum('published','expired') DEFAULT 'published',
  `visible_from` datetime DEFAULT NULL,
  `visible_to` datetime DEFAULT NULL,
  `created_by` bigint(20) DEFAULT NULL,
  `created_at` datetime DEFAULT current_timestamp(),
  `updated_at` datetime DEFAULT current_timestamp() ON UPDATE current_timestamp(),
  `is_global` tinyint(1) DEFAULT 0
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `notification_read_log`
--

CREATE TABLE `notification_read_log` (
  `id_notification` int(11) NOT NULL,
  `id_employee` bigint(20) NOT NULL,
  `id_shop` int(11) NOT NULL,
  `last_read_at` datetime DEFAULT current_timestamp(),
  `last_seen_date` date DEFAULT NULL,
  `read_count` int(11) DEFAULT 1
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `notification_target`
--

CREATE TABLE `notification_target` (
  `id_notification` int(11) NOT NULL,
  `id_shop` bigint(20) NOT NULL,
  `created_at` datetime DEFAULT current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `operational_procedure`
--

CREATE TABLE `operational_procedure` (
  `id` int(11) NOT NULL,
  `title` varchar(255) NOT NULL,
  `description` text NOT NULL,
  `subcategory_id` int(11) NOT NULL,
  `created_at` datetime NOT NULL DEFAULT current_timestamp(),
  `updated_at` datetime NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `operational_procedure_attachment`
--

CREATE TABLE `operational_procedure_attachment` (
  `id` int(11) NOT NULL,
  `procedure_id` int(11) NOT NULL,
  `file_path` varchar(500) NOT NULL,
  `label` varchar(255) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `operational_procedure_attachment_label_alias`
--

CREATE TABLE `operational_procedure_attachment_label_alias` (
  `id` int(11) NOT NULL,
  `id_attachment` int(11) NOT NULL,
  `lang_code` varchar(5) NOT NULL,
  `alias` varchar(255) NOT NULL,
  `alias_type` varchar(50) NOT NULL DEFAULT 'default',
  `create_timestamp` datetime NOT NULL DEFAULT current_timestamp(),
  `update_timestamp` datetime NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `operational_procedure_category`
--

CREATE TABLE `operational_procedure_category` (
  `id` int(11) NOT NULL,
  `name` varchar(255) NOT NULL,
  `description` text NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `operational_procedure_category_description_alias`
--

CREATE TABLE `operational_procedure_category_description_alias` (
  `id` int(11) NOT NULL,
  `id_category` int(11) NOT NULL,
  `lang_code` varchar(5) NOT NULL,
  `alias` varchar(255) NOT NULL,
  `alias_type` varchar(50) NOT NULL DEFAULT 'default',
  `create_timestamp` datetime NOT NULL DEFAULT current_timestamp(),
  `update_timestamp` datetime NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `operational_procedure_category_name_alias`
--

CREATE TABLE `operational_procedure_category_name_alias` (
  `id` int(11) NOT NULL,
  `id_category` int(11) NOT NULL,
  `lang_code` varchar(5) NOT NULL,
  `alias` varchar(255) NOT NULL,
  `alias_type` varchar(50) NOT NULL DEFAULT 'default',
  `create_timestamp` datetime NOT NULL DEFAULT current_timestamp(),
  `update_timestamp` datetime NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `operational_procedure_description_alias`
--

CREATE TABLE `operational_procedure_description_alias` (
  `id` int(11) NOT NULL,
  `id_procedure` int(11) NOT NULL,
  `lang_code` varchar(5) NOT NULL,
  `alias` varchar(255) NOT NULL,
  `alias_type` varchar(50) NOT NULL DEFAULT 'default',
  `create_timestamp` datetime NOT NULL DEFAULT current_timestamp(),
  `update_timestamp` datetime NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `operational_procedure_section`
--

CREATE TABLE `operational_procedure_section` (
  `id` int(11) NOT NULL,
  `procedure_id` int(11) NOT NULL,
  `section_title_id` int(11) NOT NULL,
  `content` text NOT NULL,
  `sort_order` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `operational_procedure_section_content_alias`
--

CREATE TABLE `operational_procedure_section_content_alias` (
  `id` int(11) NOT NULL,
  `id_procedure` int(11) NOT NULL,
  `lang_code` varchar(5) NOT NULL,
  `alias` varchar(255) NOT NULL,
  `alias_type` varchar(50) NOT NULL DEFAULT 'default',
  `create_timestamp` datetime NOT NULL DEFAULT current_timestamp(),
  `update_timestamp` datetime NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `operational_procedure_section_title`
--

CREATE TABLE `operational_procedure_section_title` (
  `id` int(11) NOT NULL,
  `title` varchar(255) NOT NULL,
  `system_default` tinyint(1) NOT NULL DEFAULT 1
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `operational_procedure_section_title_alias`
--

CREATE TABLE `operational_procedure_section_title_alias` (
  `id` int(11) NOT NULL,
  `id_title` int(11) NOT NULL,
  `lang_code` varchar(5) NOT NULL,
  `alias` varchar(255) NOT NULL,
  `alias_type` varchar(50) NOT NULL DEFAULT 'default',
  `create_timestamp` datetime NOT NULL DEFAULT current_timestamp(),
  `update_timestamp` datetime NOT NULL DEFAULT current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `operational_procedure_title_alias`
--

CREATE TABLE `operational_procedure_title_alias` (
  `id` int(11) NOT NULL,
  `id_procedure` int(11) NOT NULL,
  `lang_code` varchar(5) NOT NULL,
  `alias` varchar(255) NOT NULL,
  `alias_type` varchar(50) NOT NULL DEFAULT 'default',
  `create_timestamp` datetime NOT NULL DEFAULT current_timestamp(),
  `update_timestamp` datetime NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `operational_procedure_todo_link`
--

CREATE TABLE `operational_procedure_todo_link` (
  `id` int(11) NOT NULL,
  `procedure_id` int(11) NOT NULL,
  `todo_list_id` int(11) NOT NULL,
  `note` varchar(255) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `operational_procedure_todo_link_note_alias`
--

CREATE TABLE `operational_procedure_todo_link_note_alias` (
  `id` int(11) NOT NULL,
  `id_link` int(11) NOT NULL,
  `lang_code` varchar(5) NOT NULL,
  `alias` varchar(255) NOT NULL,
  `alias_type` varchar(50) NOT NULL DEFAULT 'default',
  `create_timestamp` datetime NOT NULL DEFAULT current_timestamp(),
  `update_timestamp` datetime NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `package_material_connection`
--

CREATE TABLE `package_material_connection` (
  `id` int(11) NOT NULL,
  `id_package` int(11) NOT NULL,
  `id_material` int(11) NOT NULL,
  `quantity` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `payment_method`
--

CREATE TABLE `payment_method` (
  `id` int(11) NOT NULL,
  `code` varchar(55) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `peppol_documents`
--

CREATE TABLE `peppol_documents` (
  `id` int(11) NOT NULL,
  `id_invoice` int(11) DEFAULT NULL,
  `id_shop` int(11) NOT NULL,
  `document_type` enum('INVOICE','CREDIT_NOTE') NOT NULL,
  `peppol_document_id` varchar(100) DEFAULT NULL,
  `receiver_party_id` varchar(100) NOT NULL,
  `supplier_nip` varchar(20) NOT NULL,
  `status` enum('PENDING','SENT','DELIVERED','ERROR') DEFAULT 'PENDING',
  `xml` longtext NOT NULL,
  `error_message` text DEFAULT NULL,
  `created_at` datetime DEFAULT current_timestamp(),
  `updated_at` datetime DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `peppol_error_log`
--

CREATE TABLE `peppol_error_log` (
  `id` int(11) NOT NULL,
  `id_shop` int(11) NOT NULL,
  `shop_identifier` varchar(64) NOT NULL,
  `client_identifier` varchar(64) NOT NULL,
  `request_body` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL,
  `error_message` text DEFAULT NULL,
  `created_at` datetime NOT NULL DEFAULT current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `peppol_participant`
--

CREATE TABLE `peppol_participant` (
  `id` int(11) NOT NULL,
  `id_shop` int(11) NOT NULL,
  `identifier` varchar(255) NOT NULL,
  `is_active` tinyint(1) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `peppol_registration_error_log`
--

CREATE TABLE `peppol_registration_error_log` (
  `id` int(11) NOT NULL,
  `id_shop` int(11) NOT NULL,
  `supplier_nip` varchar(30) NOT NULL,
  `identifier` varchar(255) NOT NULL DEFAULT '',
  `request_body` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL CHECK (json_valid(`request_body`)),
  `error_message` text DEFAULT NULL,
  `created_at` datetime NOT NULL DEFAULT current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `permission`
--

CREATE TABLE `permission` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `app` varchar(20) NOT NULL,
  `code` varchar(120) NOT NULL,
  `name` varchar(160) NOT NULL,
  `description` varchar(255) DEFAULT NULL,
  `module` varchar(64) DEFAULT NULL,
  `is_active` tinyint(1) NOT NULL DEFAULT 1,
  `created_at` datetime NOT NULL DEFAULT current_timestamp(),
  `updated_at` datetime NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `position`
--

CREATE TABLE `position` (
  `id` int(11) NOT NULL,
  `app_type` enum('EMPLOYEE','PANEL','ADMIN','CONSULTANT') NOT NULL DEFAULT 'EMPLOYEE',
  `name` varchar(255) NOT NULL,
  `description` text NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `position_level`
--

CREATE TABLE `position_level` (
  `id` int(11) NOT NULL,
  `position_id` int(11) NOT NULL,
  `level_order` int(11) NOT NULL,
  `name` varchar(255) NOT NULL,
  `description` text NOT NULL,
  `created_at` datetime NOT NULL DEFAULT current_timestamp(),
  `updated_at` datetime NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `position_level_competency_connection`
--

CREATE TABLE `position_level_competency_connection` (
  `id` int(11) NOT NULL,
  `level_id` int(11) NOT NULL,
  `competency_id` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `position_level_permission`
--

CREATE TABLE `position_level_permission` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `position_level_id` bigint(20) UNSIGNED NOT NULL,
  `permission_id` bigint(20) UNSIGNED NOT NULL,
  `created_at` datetime NOT NULL DEFAULT current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `position_level_stage_requirement`
--

CREATE TABLE `position_level_stage_requirement` (
  `id` int(11) NOT NULL,
  `level_id` int(11) NOT NULL,
  `type` enum('experience','training','manual_check','other') NOT NULL,
  `name` varchar(255) NOT NULL,
  `description` text NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `position_level_task_connection`
--

CREATE TABLE `position_level_task_connection` (
  `id` int(11) NOT NULL,
  `level_id` int(11) NOT NULL,
  `task_id` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `pricelist_state`
--

CREATE TABLE `pricelist_state` (
  `shop_uid` varchar(64) NOT NULL,
  `last_version` int(11) NOT NULL DEFAULT 0
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `price_list_archive`
--

CREATE TABLE `price_list_archive` (
  `id` int(11) NOT NULL,
  `id_supplier` int(11) NOT NULL,
  `id_shop` int(11) NOT NULL,
  `generated_at` datetime DEFAULT NULL,
  `created_at` datetime NOT NULL DEFAULT current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `price_list_product_archive`
--

CREATE TABLE `price_list_product_archive` (
  `id` int(11) NOT NULL,
  `id_price_list_archive` int(11) NOT NULL,
  `supplier_sku` varchar(255) NOT NULL,
  `product_name` varchar(255) NOT NULL,
  `gross_price` decimal(10,2) NOT NULL,
  `net_price` decimal(10,2) NOT NULL,
  `pack_quantity_in_base_unit` int(11) NOT NULL,
  `currency` varchar(15) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `price_updates`
--

CREATE TABLE `price_updates` (
  `id` int(11) NOT NULL,
  `material_id` int(11) NOT NULL,
  `old_price` decimal(10,2) NOT NULL DEFAULT 0.00,
  `new_price` decimal(10,2) NOT NULL,
  `currency` char(3) NOT NULL,
  `id_unit` int(11) NOT NULL,
  `effective_from` date NOT NULL,
  `effective_to` date DEFAULT NULL,
  `created_at` timestamp NOT NULL DEFAULT current_timestamp(),
  `comment` text NOT NULL,
  `batch_id` varchar(50) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `product`
--

CREATE TABLE `product` (
  `id_brand` int(11) NOT NULL,
  `id` int(11) NOT NULL,
  `name` varchar(255) NOT NULL,
  `id_category` int(11) NOT NULL,
  `tax_val_perc` int(11) NOT NULL,
  `is_divisible` int(11) NOT NULL DEFAULT 0,
  `is_active` int(11) NOT NULL DEFAULT 1,
  `single_weight` int(11) NOT NULL,
  `is_vegetarian` int(11) NOT NULL,
  `id_recipe` int(11) DEFAULT NULL,
  `id_positioning` int(11) NOT NULL,
  `id_storage` int(11) NOT NULL,
  `is_prepared_before_sales` int(11) NOT NULL,
  `nutriscore` text NOT NULL,
  `allergene` text NOT NULL,
  `suggested_sale_price` decimal(10,2) NOT NULL DEFAULT 0.00,
  `quantity_per_label` int(11) NOT NULL DEFAULT 1 COMMENT 'eg = 4 means one label will be printed for 4 products',
  `is_piece_based` int(11) NOT NULL DEFAULT 1,
  `id_package` int(11) DEFAULT NULL,
  `shelf_life_minutes` int(10) UNSIGNED NOT NULL DEFAULT 0 COMMENT 'shelf life in minutes ',
  `label_size` enum('small','large','none') NOT NULL DEFAULT 'small',
  `storage_temperature` int(11) NOT NULL DEFAULT 0,
  `shelf_life_category` enum('SSL','MSL','LSL') NOT NULL DEFAULT 'SSL',
  `reheating_time_minutes` int(11) DEFAULT NULL,
  `reheating_temperature_celsius` int(11) DEFAULT NULL,
  `expected_margin` decimal(10,2) NOT NULL DEFAULT 0.00
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `product_alias`
--

CREATE TABLE `product_alias` (
  `id` int(11) NOT NULL,
  `id_product` int(11) NOT NULL,
  `lang_code` varchar(5) NOT NULL,
  `alias` varchar(255) NOT NULL,
  `alias_type` varchar(50) NOT NULL DEFAULT 'default',
  `create_timestamp` datetime NOT NULL DEFAULT current_timestamp(),
  `update_timestamp` datetime NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `product_availability_period`
--

CREATE TABLE `product_availability_period` (
  `id_brand` int(11) NOT NULL DEFAULT 1,
  `id` int(11) NOT NULL,
  `name` varchar(255) NOT NULL,
  `description` text NOT NULL,
  `start_date` date NOT NULL,
  `end_date` date NOT NULL,
  `is_recurring` tinyint(1) NOT NULL DEFAULT 1,
  `is_active` tinyint(1) NOT NULL DEFAULT 1,
  `from_md` smallint(6) GENERATED ALWAYS AS (month(`start_date`) * 100 + dayofmonth(`start_date`)) STORED,
  `to_md` smallint(6) GENERATED ALWAYS AS (month(`end_date`) * 100 + dayofmonth(`end_date`)) STORED,
  `created_at` timestamp NOT NULL DEFAULT current_timestamp(),
  `updated_at` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `product_availability_period_connection`
--

CREATE TABLE `product_availability_period_connection` (
  `id` int(11) NOT NULL,
  `id_product` int(11) NOT NULL,
  `id_period` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `product_availability_period_description_alias`
--

CREATE TABLE `product_availability_period_description_alias` (
  `id` int(11) NOT NULL,
  `id_product_availability_period` int(11) NOT NULL,
  `lang_code` varchar(5) NOT NULL,
  `alias` text NOT NULL,
  `alias_type` varchar(50) NOT NULL DEFAULT 'default',
  `create_timestamp` datetime NOT NULL DEFAULT current_timestamp(),
  `update_timestamp` datetime NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `product_availability_period_name_alias`
--

CREATE TABLE `product_availability_period_name_alias` (
  `id` int(11) NOT NULL,
  `id_product_availability_period` int(11) NOT NULL,
  `lang_code` varchar(5) NOT NULL,
  `alias` varchar(255) NOT NULL,
  `alias_type` varchar(50) NOT NULL DEFAULT 'default',
  `create_timestamp` datetime NOT NULL DEFAULT current_timestamp(),
  `update_timestamp` datetime NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `product_category`
--

CREATE TABLE `product_category` (
  `id` int(11) NOT NULL,
  `id_brand` int(11) NOT NULL,
  `name` varchar(255) NOT NULL,
  `is_active` int(11) NOT NULL DEFAULT 1,
  `id_production_area` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `product_category_alias`
--

CREATE TABLE `product_category_alias` (
  `id` int(11) NOT NULL,
  `id_category` int(11) NOT NULL,
  `lang_code` varchar(5) NOT NULL,
  `alias` varchar(255) NOT NULL,
  `alias_type` varchar(50) NOT NULL DEFAULT 'default',
  `create_timestamp` datetime NOT NULL DEFAULT current_timestamp(),
  `update_timestamp` datetime NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `product_category_group`
--

CREATE TABLE `product_category_group` (
  `id_brand` int(11) NOT NULL,
  `id` int(11) NOT NULL,
  `name` varchar(255) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `product_category_group_alias`
--

CREATE TABLE `product_category_group_alias` (
  `id` int(11) NOT NULL,
  `id_category_group` int(11) NOT NULL,
  `lang_code` varchar(5) NOT NULL,
  `alias` varchar(255) NOT NULL,
  `alias_type` varchar(50) NOT NULL DEFAULT 'default',
  `create_timestamp` datetime NOT NULL DEFAULT current_timestamp(),
  `update_timestamp` datetime NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `product_category_group_connection`
--

CREATE TABLE `product_category_group_connection` (
  `id_category` int(11) NOT NULL,
  `id_group` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `product_competence`
--

CREATE TABLE `product_competence` (
  `id` int(11) NOT NULL,
  `id_brand` int(11) NOT NULL,
  `name` varchar(255) NOT NULL,
  `description` text NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `product_competence_connection`
--

CREATE TABLE `product_competence_connection` (
  `id_product` int(11) NOT NULL,
  `id_competence` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `product_competence_description_alias`
--

CREATE TABLE `product_competence_description_alias` (
  `id` int(11) NOT NULL,
  `id_product_competence` int(11) NOT NULL,
  `lang_code` varchar(5) NOT NULL,
  `alias` text NOT NULL,
  `alias_type` varchar(50) NOT NULL DEFAULT 'default',
  `create_timestamp` datetime NOT NULL DEFAULT current_timestamp(),
  `update_timestamp` datetime NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `product_competence_name_alias`
--

CREATE TABLE `product_competence_name_alias` (
  `id` int(11) NOT NULL,
  `id_product_competence` int(11) NOT NULL,
  `lang_code` varchar(5) NOT NULL,
  `alias` varchar(255) NOT NULL,
  `alias_type` varchar(50) NOT NULL DEFAULT 'default',
  `create_timestamp` datetime NOT NULL DEFAULT current_timestamp(),
  `update_timestamp` datetime NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `product_movement`
--

CREATE TABLE `product_movement` (
  `id` bigint(20) NOT NULL,
  `id_shop` int(11) NOT NULL,
  `id_device` int(11) NOT NULL,
  `id_employee` int(11) NOT NULL,
  `id_product` bigint(20) NOT NULL,
  `movement_type` enum('PRODUCTION','WASTE','SALE','RETURN','ADJUSTMENT') NOT NULL,
  `quantity` decimal(10,2) NOT NULL,
  `reason` varchar(50) NOT NULL,
  `source` varchar(50) NOT NULL,
  `created_at` timestamp NULL DEFAULT current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `product_package`
--

CREATE TABLE `product_package` (
  `id_brand` int(11) NOT NULL,
  `id` int(11) NOT NULL,
  `name` varchar(255) NOT NULL,
  `description` text NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `product_package_description_alias`
--

CREATE TABLE `product_package_description_alias` (
  `id` int(11) NOT NULL,
  `id_product_package` int(11) NOT NULL,
  `lang_code` varchar(5) NOT NULL,
  `alias` text NOT NULL,
  `alias_type` varchar(50) NOT NULL DEFAULT 'default',
  `create_timestamp` datetime NOT NULL DEFAULT current_timestamp(),
  `update_timestamp` datetime NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `product_package_name_alias`
--

CREATE TABLE `product_package_name_alias` (
  `id` int(11) NOT NULL,
  `id_product_package` int(11) NOT NULL,
  `lang_code` varchar(5) NOT NULL,
  `alias` varchar(255) NOT NULL,
  `alias_type` varchar(50) NOT NULL DEFAULT 'default',
  `create_timestamp` datetime NOT NULL DEFAULT current_timestamp(),
  `update_timestamp` datetime NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `product_positioning`
--

CREATE TABLE `product_positioning` (
  `id_brand` int(11) NOT NULL,
  `id` int(11) NOT NULL,
  `name` varchar(255) NOT NULL,
  `description` text NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `product_positioning_description_alias`
--

CREATE TABLE `product_positioning_description_alias` (
  `id` int(11) NOT NULL,
  `id_product_positioning` int(11) NOT NULL,
  `lang_code` varchar(5) NOT NULL,
  `alias` text NOT NULL,
  `alias_type` varchar(50) NOT NULL DEFAULT 'default',
  `create_timestamp` datetime NOT NULL DEFAULT current_timestamp(),
  `update_timestamp` datetime NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `product_positioning_name_alias`
--

CREATE TABLE `product_positioning_name_alias` (
  `id` int(11) NOT NULL,
  `id_product_positioning` int(11) NOT NULL,
  `lang_code` varchar(5) NOT NULL,
  `alias` varchar(255) NOT NULL,
  `alias_type` varchar(50) NOT NULL DEFAULT 'default',
  `create_timestamp` datetime NOT NULL DEFAULT current_timestamp(),
  `update_timestamp` datetime NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `product_recipe`
--

CREATE TABLE `product_recipe` (
  `id_brand` int(11) NOT NULL,
  `id` int(11) NOT NULL,
  `name` varchar(255) DEFAULT NULL,
  `is_subrecipe` int(11) NOT NULL,
  `yield_quantity` decimal(10,2) NOT NULL,
  `id_unit` int(11) NOT NULL,
  `main_photo` text DEFAULT NULL,
  `photo_1` text DEFAULT NULL,
  `photo_2` text DEFAULT NULL,
  `photo_3` text DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `product_recipe_alias`
--

CREATE TABLE `product_recipe_alias` (
  `id` int(11) NOT NULL,
  `id_recipe` int(11) NOT NULL,
  `lang_code` varchar(5) NOT NULL,
  `alias` varchar(255) NOT NULL,
  `alias_type` varchar(50) NOT NULL DEFAULT 'default',
  `create_timestamp` datetime NOT NULL DEFAULT current_timestamp(),
  `update_timestamp` datetime NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `product_recipe_material_connection`
--

CREATE TABLE `product_recipe_material_connection` (
  `parent_recipe_id` int(11) NOT NULL,
  `child_recipe_id` int(11) DEFAULT NULL,
  `child_ingredient_id` int(11) DEFAULT NULL,
  `quantity` decimal(10,2) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `product_recipe_preparation_step`
--

CREATE TABLE `product_recipe_preparation_step` (
  `id` int(11) NOT NULL,
  `id_recipe` int(11) NOT NULL,
  `step_number` int(11) NOT NULL,
  `step_description` text NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `product_recipe_preparation_step_alias`
--

CREATE TABLE `product_recipe_preparation_step_alias` (
  `id` int(11) NOT NULL,
  `id_preparation_step` int(11) NOT NULL,
  `lang_code` varchar(5) NOT NULL,
  `alias` text NOT NULL,
  `alias_type` varchar(50) NOT NULL DEFAULT 'default',
  `create_timestamp` datetime NOT NULL DEFAULT current_timestamp(),
  `update_timestamp` datetime NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `product_recipe_preparation_type`
--

CREATE TABLE `product_recipe_preparation_type` (
  `id_brand` int(11) NOT NULL,
  `id` int(11) NOT NULL,
  `name` varchar(255) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `product_recipe_preparation_types_connection`
--

CREATE TABLE `product_recipe_preparation_types_connection` (
  `id_recipe` int(11) NOT NULL,
  `id_preparation_type` int(11) NOT NULL,
  `duration_second` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `product_recipe_preparation_type_alias`
--

CREATE TABLE `product_recipe_preparation_type_alias` (
  `id` int(11) NOT NULL,
  `id_preparation_type` int(11) NOT NULL,
  `lang_code` varchar(5) NOT NULL,
  `alias` varchar(255) NOT NULL,
  `alias_type` varchar(50) NOT NULL DEFAULT 'default',
  `create_timestamp` datetime NOT NULL DEFAULT current_timestamp(),
  `update_timestamp` datetime NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `product_storage`
--

CREATE TABLE `product_storage` (
  `id_brand` int(11) NOT NULL,
  `id` int(11) NOT NULL,
  `name` varchar(255) NOT NULL,
  `description` text NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `product_storage_description_alias`
--

CREATE TABLE `product_storage_description_alias` (
  `id` int(11) NOT NULL,
  `id_product_storage` int(11) NOT NULL,
  `lang_code` varchar(5) NOT NULL,
  `alias` text NOT NULL,
  `alias_type` varchar(50) NOT NULL DEFAULT 'default',
  `create_timestamp` datetime NOT NULL DEFAULT current_timestamp(),
  `update_timestamp` datetime NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `product_storage_name_alias`
--

CREATE TABLE `product_storage_name_alias` (
  `id` int(11) NOT NULL,
  `id_product_storage` int(11) NOT NULL,
  `lang_code` varchar(5) NOT NULL,
  `alias` varchar(255) NOT NULL,
  `alias_type` varchar(50) NOT NULL DEFAULT 'default',
  `create_timestamp` datetime NOT NULL DEFAULT current_timestamp(),
  `update_timestamp` datetime NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `product_subrecipe_attributes`
--

CREATE TABLE `product_subrecipe_attributes` (
  `id_recipe` int(11) NOT NULL,
  `id_category` int(11) NOT NULL,
  `id_storage` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `product_subrecipe_category`
--

CREATE TABLE `product_subrecipe_category` (
  `id_brand` int(11) NOT NULL,
  `id` int(11) NOT NULL,
  `name` varchar(255) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `product_subrecipe_category_alias`
--

CREATE TABLE `product_subrecipe_category_alias` (
  `id` int(11) NOT NULL,
  `id_product_subrecipe_category` int(11) NOT NULL,
  `lang_code` varchar(5) NOT NULL,
  `alias` varchar(255) NOT NULL,
  `alias_type` varchar(50) NOT NULL DEFAULT 'default',
  `create_timestamp` datetime NOT NULL DEFAULT current_timestamp(),
  `update_timestamp` datetime NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `promo_code`
--

CREATE TABLE `promo_code` (
  `id` int(11) NOT NULL,
  `code` varchar(64) NOT NULL,
  `discount_value` decimal(10,2) DEFAULT NULL,
  `valid_from` datetime NOT NULL,
  `valid_to` datetime NOT NULL,
  `is_active` tinyint(1) NOT NULL,
  `is_single_use` tinyint(1) NOT NULL,
  `id_admin` int(11) NOT NULL,
  `description` text NOT NULL,
  `id_discount_type` int(11) NOT NULL,
  `applies_to_all_products` tinyint(1) NOT NULL,
  `min_order_value` decimal(10,2) NOT NULL DEFAULT 0.00,
  `limit_per_product` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `promo_code_product`
--

CREATE TABLE `promo_code_product` (
  `id` int(11) NOT NULL,
  `id_promo_code` int(11) NOT NULL,
  `id_product` int(11) NOT NULL,
  `discount_value` decimal(10,0) NOT NULL,
  `id_discount_type` int(11) NOT NULL,
  `limit_per_product` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `promo_code_type`
--

CREATE TABLE `promo_code_type` (
  `id` int(11) NOT NULL,
  `code` varchar(25) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `recipe_cost`
--

CREATE TABLE `recipe_cost` (
  `id` int(11) NOT NULL,
  `id_brand` int(11) NOT NULL DEFAULT 1,
  `id_recipe` int(11) NOT NULL,
  `id_shop` int(11) DEFAULT NULL,
  `price_type` enum('suggested','custom') NOT NULL,
  `calculated_cost_net` decimal(10,2) NOT NULL,
  `calculated_cost_gross` decimal(10,2) NOT NULL,
  `calculated_at` timestamp NOT NULL DEFAULT current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `recipe_cost_archive`
--

CREATE TABLE `recipe_cost_archive` (
  `id` int(11) NOT NULL,
  `id_shop` int(11) NOT NULL,
  `id_recipe` int(11) NOT NULL,
  `cost_net` decimal(10,2) NOT NULL,
  `cost_gross` decimal(10,2) NOT NULL,
  `valid_from` date NOT NULL,
  `valid_to` date DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `report_august_2025`
--

CREATE TABLE `report_august_2025` (
  `report` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
  `period` varchar(7) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
  `id_shop` int(11) DEFAULT NULL,
  `shop_label` mediumtext DEFAULT NULL,
  `category_id` int(11) DEFAULT NULL,
  `category_name` varchar(255) DEFAULT NULL,
  `id_product` int(11) DEFAULT NULL,
  `product_name` varchar(255) DEFAULT NULL,
  `qty_sold` decimal(54,3) DEFAULT NULL,
  `sales_gross` decimal(54,2) DEFAULT NULL,
  `nb_products` bigint(20) NOT NULL DEFAULT 0,
  `rank_pos` bigint(20) UNSIGNED DEFAULT NULL,
  `pct_sales_in_cat_shop` decimal(38,2) DEFAULT NULL,
  `pct_sales_in_cat_global` decimal(38,2) DEFAULT NULL,
  `total_pct_top5_in_cat_shop` decimal(60,2) DEFAULT NULL,
  `total_pct_flop3_in_cat_shop` decimal(60,2) DEFAULT NULL,
  `total_pct_top5_in_cat_global` decimal(60,2) DEFAULT NULL,
  `total_pct_flop3_in_cat_global` decimal(60,2) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `secret_share`
--

CREATE TABLE `secret_share` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `integration_connection_id` int(11) NOT NULL,
  `share_id` varchar(36) NOT NULL,
  `token_hash` varbinary(32) NOT NULL,
  `expires_at` datetime NOT NULL,
  `used_at` datetime DEFAULT NULL,
  `created_at` datetime NOT NULL DEFAULT current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `shop_cost`
--

CREATE TABLE `shop_cost` (
  `id` int(11) NOT NULL,
  `name` varchar(255) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `shop_cost_alias`
--

CREATE TABLE `shop_cost_alias` (
  `id` int(11) NOT NULL,
  `id_shop_cost` int(11) NOT NULL,
  `lang_code` varchar(5) NOT NULL,
  `alias` varchar(255) NOT NULL,
  `alias_type` varchar(50) NOT NULL DEFAULT 'default',
  `create_timestamp` datetime NOT NULL DEFAULT current_timestamp(),
  `update_timestamp` datetime NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `shop_cost_connection`
--

CREATE TABLE `shop_cost_connection` (
  `id` int(11) NOT NULL,
  `id_shop` int(11) NOT NULL,
  `id_cost` int(11) NOT NULL,
  `date` date NOT NULL,
  `amount` decimal(10,2) NOT NULL,
  `description` text DEFAULT NULL,
  `insert_timestamp` timestamp NOT NULL DEFAULT current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `shop_material_order_outbox`
--

CREATE TABLE `shop_material_order_outbox` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `id_shop` varchar(64) NOT NULL,
  `order_key` varchar(64) NOT NULL,
  `payload_json` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL,
  `status` enum('pending','done','failed') NOT NULL DEFAULT 'pending',
  `retry_count` int(10) UNSIGNED NOT NULL DEFAULT 0,
  `created_at` datetime NOT NULL DEFAULT current_timestamp(),
  `updated_at` datetime NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `shop_material_packaging_price_list`
--

CREATE TABLE `shop_material_packaging_price_list` (
  `id` int(11) NOT NULL,
  `id_packaging` int(11) NOT NULL,
  `id_supplier` int(11) DEFAULT NULL,
  `id_shop` int(11) DEFAULT NULL,
  `pack_price_net` decimal(10,2) NOT NULL,
  `currency` varchar(3) NOT NULL,
  `valid_from` date NOT NULL,
  `valid_to` date DEFAULT NULL,
  `created_at` timestamp NOT NULL DEFAULT current_timestamp(),
  `updated_at` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `shop_material_price_list`
--

CREATE TABLE `shop_material_price_list` (
  `id` int(11) NOT NULL,
  `id_material` int(11) NOT NULL,
  `id_shop` int(11) DEFAULT NULL,
  `base_unit_price_net` decimal(21,6) NOT NULL,
  `currency` char(3) NOT NULL,
  `created_at` timestamp NOT NULL DEFAULT current_timestamp(),
  `updated_at` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `shop_material_supplier_connection`
--

CREATE TABLE `shop_material_supplier_connection` (
  `id` int(11) NOT NULL,
  `id_shop` int(11) NOT NULL,
  `id_supplier` int(11) NOT NULL,
  `lead_time_hours` int(11) NOT NULL,
  `created_at` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `shop_material_supplier_delivery_day`
--

CREATE TABLE `shop_material_supplier_delivery_day` (
  `id` int(11) NOT NULL,
  `id_supplier` int(11) NOT NULL,
  `id_shop` int(11) NOT NULL,
  `id_day` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `shop_material_supplier_integration_connection`
--

CREATE TABLE `shop_material_supplier_integration_connection` (
  `id` int(11) NOT NULL,
  `id_supplier` int(11) NOT NULL,
  `id_shop` int(11) NOT NULL,
  `shop_uid` char(26) NOT NULL,
  `franchisee_code` varchar(255) DEFAULT NULL,
  `credentials` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL CHECK (json_valid(`credentials`)),
  `status` enum('active','inactive','wrong') NOT NULL DEFAULT 'active',
  `last_sync_at` datetime DEFAULT NULL,
  `created_at` datetime NOT NULL DEFAULT current_timestamp(),
  `updated_at` datetime NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
  `activation_code` varchar(64) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `shop_product`
--

CREATE TABLE `shop_product` (
  `id` int(11) NOT NULL,
  `id_shop` int(11) NOT NULL,
  `id_product` int(11) NOT NULL,
  `portion_price` decimal(10,2) NOT NULL,
  `portion_size` decimal(10,2) NOT NULL,
  `in_stock` decimal(10,2) NOT NULL,
  `max_portion_price` decimal(10,2) NOT NULL DEFAULT 0.00
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `shop_supplier_pack_default`
--

CREATE TABLE `shop_supplier_pack_default` (
  `id` int(11) NOT NULL,
  `id_shop` int(11) NOT NULL,
  `id_material` int(11) NOT NULL,
  `id_pack` int(11) NOT NULL,
  `id_supplier` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `shop_workstation`
--

CREATE TABLE `shop_workstation` (
  `id` int(11) NOT NULL,
  `name` varchar(255) NOT NULL,
  `description` text NOT NULL,
  `created_at` timestamp NOT NULL DEFAULT current_timestamp(),
  `updated_at` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `shop_workstation_description_alias`
--

CREATE TABLE `shop_workstation_description_alias` (
  `id` int(11) NOT NULL,
  `id_workstation` int(11) NOT NULL,
  `lang_code` varchar(5) NOT NULL,
  `alias` varchar(255) NOT NULL,
  `alias_type` varchar(50) NOT NULL DEFAULT 'default',
  `create_timestamp` datetime NOT NULL DEFAULT current_timestamp(),
  `update_timestamp` datetime NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `shop_workstation_name_alias`
--

CREATE TABLE `shop_workstation_name_alias` (
  `id` int(11) NOT NULL,
  `id_workstation` int(11) NOT NULL,
  `lang_code` varchar(5) NOT NULL,
  `alias` varchar(255) NOT NULL,
  `alias_type` varchar(50) NOT NULL DEFAULT 'default',
  `create_timestamp` datetime NOT NULL DEFAULT current_timestamp(),
  `update_timestamp` datetime NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `stocktaking`
--

CREATE TABLE `stocktaking` (
  `id` int(11) NOT NULL,
  `type` enum('scanner','manual') NOT NULL,
  `id_shop` int(11) NOT NULL,
  `id_employee` int(11) NOT NULL,
  `was_manual_change` tinyint(1) NOT NULL DEFAULT 0,
  `created_at` datetime NOT NULL DEFAULT current_timestamp(),
  `updated_at` datetime NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `stocktaking_item`
--

CREATE TABLE `stocktaking_item` (
  `id` int(11) NOT NULL,
  `id_stocktaking` int(11) NOT NULL,
  `id_package` int(11) DEFAULT NULL,
  `id_material` int(11) NOT NULL,
  `package_size_in_base_unit` int(11) NOT NULL,
  `id_unit` int(11) NOT NULL,
  `pack_quantity` int(11) NOT NULL,
  `total_quantity_in_base_unit` int(11) NOT NULL,
  `raw_code` varchar(255) NOT NULL,
  `pack_price_net` decimal(10,2) NOT NULL,
  `currency` varchar(5) NOT NULL,
  `vat_rate` decimal(5,2) NOT NULL,
  `created_at` datetime NOT NULL DEFAULT current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `stocktaking_summary`
--

CREATE TABLE `stocktaking_summary` (
  `id` int(11) NOT NULL,
  `id_stockatking` int(11) NOT NULL,
  `id_material` int(11) NOT NULL,
  `previous_balance_in_base_unit` int(11) NOT NULL DEFAULT 0,
  `counted_quantity_in_base_unit` int(11) NOT NULL,
  `difference` int(11) NOT NULL,
  `avg_base_unit_price_net` decimal(22,6) NOT NULL,
  `vat_rate` decimal(5,2) NOT NULL,
  `currency` varchar(5) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `subrecipe_competence_connection`
--

CREATE TABLE `subrecipe_competence_connection` (
  `id_recipe` int(11) NOT NULL,
  `id_competence` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `supplier_catalog_product`
--

CREATE TABLE `supplier_catalog_product` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `supplier_id` int(11) NOT NULL,
  `sku` varchar(64) NOT NULL,
  `name` varchar(255) NOT NULL,
  `package_size` decimal(12,3) NOT NULL,
  `package_unit` varchar(16) NOT NULL,
  `vat_rate` decimal(10,2) NOT NULL DEFAULT 0.00,
  `is_active` tinyint(1) NOT NULL DEFAULT 1,
  `weight_grams` int(11) NOT NULL,
  `shelf_life_days` int(11) NOT NULL,
  `created_at` timestamp NOT NULL DEFAULT current_timestamp(),
  `updated_at` timestamp NULL DEFAULT NULL ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

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

--
-- Struktura tabeli dla tabeli `supplier_catalog_product_allergen`
--

CREATE TABLE `supplier_catalog_product_allergen` (
  `product_id` bigint(20) UNSIGNED NOT NULL,
  `allergen_id` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

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

--
-- Struktura tabeli dla tabeli `supplier_catalog_product_mapping`
--

CREATE TABLE `supplier_catalog_product_mapping` (
  `id` int(11) NOT NULL,
  `catalog_product_id` bigint(20) UNSIGNED NOT NULL,
  `material_id` int(11) NOT NULL,
  `created_at` timestamp NOT NULL DEFAULT current_timestamp(),
  `updated_at` timestamp NULL DEFAULT NULL ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `supplier_catalog_product_spec`
--

CREATE TABLE `supplier_catalog_product_spec` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `product_id` bigint(20) UNSIGNED NOT NULL,
  `lang_code` varchar(5) NOT NULL,
  `storage_info` text NOT NULL,
  `preparation_info` text NOT NULL,
  `composition` text NOT NULL,
  `created_at` timestamp NOT NULL DEFAULT current_timestamp(),
  `updated_at` timestamp NULL DEFAULT NULL ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `supplier_pack_connection`
--

CREATE TABLE `supplier_pack_connection` (
  `id` bigint(20) NOT NULL,
  `id_supplier` bigint(20) NOT NULL,
  `id_packaging` int(11) NOT NULL,
  `id_material` bigint(20) NOT NULL,
  `supplier_sku` varchar(80) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `supplier_product_price_list`
--

CREATE TABLE `supplier_product_price_list` (
  `id` int(11) NOT NULL,
  `shop_id` int(11) NOT NULL,
  `supplier_id` int(11) NOT NULL,
  `product_id` bigint(20) UNSIGNED NOT NULL,
  `price_net` decimal(10,2) NOT NULL,
  `valid_from` date NOT NULL,
  `created_at` datetime NOT NULL DEFAULT current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `todo_daily_close`
--

CREATE TABLE `todo_daily_close` (
  `id` int(11) NOT NULL,
  `shop_id` int(11) NOT NULL,
  `employee_id` int(11) NOT NULL,
  `day` date NOT NULL,
  `closed_at` datetime NOT NULL DEFAULT current_timestamp(),
  `closed_by_employee_id` int(11) DEFAULT NULL,
  `close_trigger` varchar(64) DEFAULT NULL,
  `generated_skipped` tinyint(1) NOT NULL DEFAULT 0
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `todo_task`
--

CREATE TABLE `todo_task` (
  `id` int(11) NOT NULL,
  `subcategory_id` int(11) NOT NULL,
  `name` varchar(255) NOT NULL,
  `description` text NOT NULL,
  `day_of_week` varchar(255) DEFAULT NULL,
  `execution_time` time DEFAULT NULL,
  `frequency` varchar(255) DEFAULT NULL,
  `is_mandatory` int(11) NOT NULL,
  `priority` int(11) NOT NULL DEFAULT 5 COMMENT 'priority 1-5 ',
  `requires_photo` tinyint(4) NOT NULL DEFAULT 0
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `todo_task_admin_role`
--

CREATE TABLE `todo_task_admin_role` (
  `id_task` int(11) NOT NULL,
  `id_role` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `todo_task_completion`
--

CREATE TABLE `todo_task_completion` (
  `id` int(11) NOT NULL,
  `task_id` int(11) NOT NULL,
  `shop_id` int(11) NOT NULL,
  `scheduled_for_date` date NOT NULL,
  `scheduled_time` time NOT NULL DEFAULT '00:00:00',
  `status` enum('DONE','SKIPPED','FAILED') NOT NULL DEFAULT 'DONE',
  `completed_at` datetime NOT NULL,
  `completed_by_employee_id` int(11) DEFAULT NULL,
  `note` text DEFAULT NULL,
  `overridden_completed_at` datetime DEFAULT NULL,
  `overridden_by_employee_id` int(11) DEFAULT NULL,
  `override_reason` varchar(255) DEFAULT NULL,
  `created_at` datetime NOT NULL DEFAULT current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `todo_task_description_alias`
--

CREATE TABLE `todo_task_description_alias` (
  `id` int(11) NOT NULL,
  `id_todo_task` int(11) NOT NULL,
  `lang_code` varchar(5) NOT NULL,
  `alias` text NOT NULL,
  `alias_type` varchar(50) NOT NULL DEFAULT 'default',
  `create_timestamp` datetime NOT NULL DEFAULT current_timestamp(),
  `update_timestamp` datetime NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `todo_task_employee_role`
--

CREATE TABLE `todo_task_employee_role` (
  `id_task` int(11) NOT NULL,
  `id_role` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `todo_task_name_alias`
--

CREATE TABLE `todo_task_name_alias` (
  `id` int(11) NOT NULL,
  `id_todo_task` int(11) NOT NULL,
  `lang_code` varchar(5) NOT NULL,
  `alias` varchar(255) NOT NULL,
  `alias_type` varchar(50) NOT NULL DEFAULT 'default',
  `create_timestamp` datetime NOT NULL DEFAULT current_timestamp(),
  `update_timestamp` datetime NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `todo_task_related_product`
--

CREATE TABLE `todo_task_related_product` (
  `id_task` int(11) NOT NULL,
  `id_product` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `todo_task_set`
--

CREATE TABLE `todo_task_set` (
  `id_brand` int(11) NOT NULL,
  `id` int(11) NOT NULL,
  `name` varchar(255) NOT NULL,
  `description` text NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `todo_task_set_description_alias`
--

CREATE TABLE `todo_task_set_description_alias` (
  `id` int(11) NOT NULL,
  `id_todo_task_set` int(11) NOT NULL,
  `lang_code` varchar(5) NOT NULL,
  `alias` text NOT NULL,
  `alias_type` varchar(50) NOT NULL DEFAULT 'default',
  `create_timestamp` datetime NOT NULL DEFAULT current_timestamp(),
  `update_timestamp` datetime NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `todo_task_set_name_alias`
--

CREATE TABLE `todo_task_set_name_alias` (
  `id` int(11) NOT NULL,
  `id_todo_task_set` int(11) NOT NULL,
  `lang_code` varchar(5) NOT NULL,
  `alias` varchar(255) NOT NULL,
  `alias_type` varchar(50) NOT NULL DEFAULT 'default',
  `create_timestamp` datetime NOT NULL DEFAULT current_timestamp(),
  `update_timestamp` datetime NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `todo_task_set_task_connection`
--

CREATE TABLE `todo_task_set_task_connection` (
  `id_set` int(11) NOT NULL,
  `id_task` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `todo_task_subtype`
--

CREATE TABLE `todo_task_subtype` (
  `id` int(11) NOT NULL,
  `name` varchar(255) NOT NULL,
  `id_type` int(11) NOT NULL,
  `includes_products` tinyint(1) NOT NULL DEFAULT 0
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `todo_task_subtype_alias`
--

CREATE TABLE `todo_task_subtype_alias` (
  `id` int(11) NOT NULL,
  `id_todo_task_subtype` int(11) NOT NULL,
  `lang_code` varchar(5) NOT NULL,
  `alias` varchar(255) NOT NULL,
  `alias_type` varchar(50) NOT NULL DEFAULT 'default',
  `create_timestamp` datetime NOT NULL DEFAULT current_timestamp(),
  `update_timestamp` datetime NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `todo_task_type`
--

CREATE TABLE `todo_task_type` (
  `id_brand` int(11) NOT NULL,
  `id` int(11) NOT NULL,
  `name` varchar(255) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `todo_task_type_alias`
--

CREATE TABLE `todo_task_type_alias` (
  `id` int(11) NOT NULL,
  `id_todo_task_type` int(11) NOT NULL,
  `lang_code` varchar(5) NOT NULL,
  `alias` varchar(255) NOT NULL,
  `alias_type` varchar(50) NOT NULL DEFAULT 'default',
  `create_timestamp` datetime NOT NULL DEFAULT current_timestamp(),
  `update_timestamp` datetime NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `training`
--

CREATE TABLE `training` (
  `id` int(11) NOT NULL,
  `name` varchar(255) NOT NULL,
  `description` text NOT NULL,
  `subcategory_id` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `training_admin_role_connection`
--

CREATE TABLE `training_admin_role_connection` (
  `id` int(11) NOT NULL,
  `training_id` int(11) NOT NULL,
  `admin_role_id` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `training_employee_role_connection`
--

CREATE TABLE `training_employee_role_connection` (
  `id` int(11) NOT NULL,
  `training_id` int(11) NOT NULL,
  `employee_role_id` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `transaction`
--

CREATE TABLE `transaction` (
  `id` int(11) NOT NULL,
  `ticket_key` bigint(20) NOT NULL,
  `id_shop` int(11) NOT NULL,
  `id_device` int(11) NOT NULL,
  `id_client` int(11) DEFAULT NULL,
  `id_client_department` int(11) DEFAULT NULL,
  `id_customer` int(11) DEFAULT NULL,
  `id_company` int(11) DEFAULT NULL,
  `id_voucher` int(11) DEFAULT NULL,
  `total_gross_amount_after_discount` decimal(10,2) NOT NULL,
  `tax_amount_after_discount` decimal(10,2) NOT NULL,
  `discount_total_value` decimal(10,2) NOT NULL,
  `id_employee` int(11) NOT NULL,
  `will_be_invoiced` tinyint(1) NOT NULL DEFAULT 0,
  `id_invoice` int(11) DEFAULT NULL,
  `deferral_payment` tinyint(1) NOT NULL,
  `id_payment_type` int(11) NOT NULL COMMENT '0 -> deferal\r\n1 -> cash\r\n2 -> card\r\n3 -> togoodtogo\r\n4 -> sodexo\r\n5 -> monizze\r\n6 -> bank transfer\r\n7 -> payonic\r\n',
  `insert_timestamp` datetime NOT NULL DEFAULT current_timestamp(),
  `remark` varchar(255) NOT NULL DEFAULT '',
  `id_serving_method` int(11) NOT NULL DEFAULT 2
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `transaction_product`
--

CREATE TABLE `transaction_product` (
  `id` int(11) NOT NULL,
  `id_transaction` int(11) NOT NULL,
  `id_product` int(11) NOT NULL,
  `product_name` varchar(255) NOT NULL,
  `unit_gross_price` decimal(10,2) NOT NULL,
  `quantity` decimal(10,3) NOT NULL,
  `weight` int(11) DEFAULT NULL,
  `item_tax_perc` int(11) NOT NULL,
  `item_discount_value` decimal(10,2) NOT NULL,
  `total_gross_value_after_discount` decimal(10,2) NOT NULL,
  `total_tax_value_after_discount` decimal(10,2) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `unit`
--

CREATE TABLE `unit` (
  `id` int(11) NOT NULL,
  `name` varchar(50) NOT NULL,
  `smaller_unit_name` varchar(50) DEFAULT NULL,
  `conversion_factor` decimal(10,0) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `user_membership`
--

CREATE TABLE `user_membership` (
  `id` int(11) NOT NULL,
  `auth_user_id` int(11) NOT NULL,
  `app` enum('OWNER','ADMIN','PANEL','EMPLOYEE','CONSULTANT') NOT NULL,
  `scope_type` enum('SHOP','NETWORK') DEFAULT NULL,
  `scope_id` int(11) DEFAULT NULL COMMENT 'id_shop, id_network',
  `is_active` int(11) NOT NULL DEFAULT 1,
  `system_role` enum('NONE','ROOT','SUPPORT') NOT NULL DEFAULT 'NONE'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `user_profile`
--

CREATE TABLE `user_profile` (
  `id` int(11) NOT NULL,
  `auth_user_id` int(11) NOT NULL,
  `first_name` varchar(255) NOT NULL,
  `last_name` varchar(255) NOT NULL,
  `display_name` varchar(255) NOT NULL,
  `lang_code` varchar(5) NOT NULL DEFAULT 'fr',
  `email` varchar(255) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `webhook_inbox`
--

CREATE TABLE `webhook_inbox` (
  `shop_uid` varchar(64) NOT NULL,
  `event_id` varchar(64) NOT NULL,
  `topic` varchar(64) NOT NULL,
  `received_at` datetime NOT NULL DEFAULT current_timestamp(),
  `processed_at` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `week_days`
--

CREATE TABLE `week_days` (
  `id` tinyint(3) UNSIGNED NOT NULL,
  `code` varchar(10) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `withdrawing_money_reason`
--

CREATE TABLE `withdrawing_money_reason` (
  `id_brand` int(11) NOT NULL,
  `id` int(11) NOT NULL,
  `content` varchar(255) NOT NULL,
  `description` text NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `withdrawing_money_reason_content_alias`
--

CREATE TABLE `withdrawing_money_reason_content_alias` (
  `id` int(11) NOT NULL,
  `id_withdrawing_money_reason` int(11) NOT NULL,
  `lang_code` varchar(5) NOT NULL,
  `alias` varchar(255) NOT NULL,
  `alias_type` varchar(50) NOT NULL DEFAULT 'default',
  `create_timestamp` datetime NOT NULL DEFAULT current_timestamp(),
  `update_timestamp` datetime NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Struktura tabeli dla tabeli `withdrawing_money_reason_description_alias`
--

CREATE TABLE `withdrawing_money_reason_description_alias` (
  `id` int(11) NOT NULL,
  `id_withdrawing_money_reason` int(11) NOT NULL,
  `lang_code` varchar(5) NOT NULL,
  `alias` text NOT NULL,
  `alias_type` varchar(50) NOT NULL DEFAULT 'default',
  `create_timestamp` datetime NOT NULL DEFAULT current_timestamp(),
  `update_timestamp` datetime NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Indeksy dla zrzutów tabel
--

--
-- Indeksy dla tabeli `admin_panel_user`
--
ALTER TABLE `admin_panel_user`
  ADD PRIMARY KEY (`id`);

--
-- Indeksy dla tabeli `admin_panel_user_permission`
--
ALTER TABLE `admin_panel_user_permission`
  ADD PRIMARY KEY (`id`);

--
-- Indeksy dla tabeli `admin_panel_user_permission_group`
--
ALTER TABLE `admin_panel_user_permission_group`
  ADD PRIMARY KEY (`id`);

--
-- Indeksy dla tabeli `admin_panel_user_permission_group_connection`
--
ALTER TABLE `admin_panel_user_permission_group_connection`
  ADD KEY `id_group` (`id_group`),
  ADD KEY `id_permission` (`id_permission`);

--
-- Indeksy dla tabeli `admin_panel_user_role`
--
ALTER TABLE `admin_panel_user_role`
  ADD PRIMARY KEY (`id`);

--
-- Indeksy dla tabeli `admin_panel_user_role_alias`
--
ALTER TABLE `admin_panel_user_role_alias`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `uq_role_lang_type` (`id_admin_panel_user_role`,`lang_code`,`alias_type`),
  ADD KEY `idx_lang_code` (`lang_code`);

--
-- Indeksy dla tabeli `allergen`
--
ALTER TABLE `allergen`
  ADD PRIMARY KEY (`id`);

--
-- Indeksy dla tabeli `auth_session`
--
ALTER TABLE `auth_session`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `uq_token_hash` (`token_hash`),
  ADD KEY `idx_user_app_active` (`auth_user_id`,`app`,`revoked_at`),
  ADD KEY `idx_membership` (`membership_id`),
  ADD KEY `fk_auth_session_replaced` (`replaced_by_id`);

--
-- Indeksy dla tabeli `auth_user`
--
ALTER TABLE `auth_user`
  ADD PRIMARY KEY (`id`);

--
-- Indeksy dla tabeli `b2b_client_company_department`
--
ALTER TABLE `b2b_client_company_department`
  ADD PRIMARY KEY (`id`);

--
-- Indeksy dla tabeli `b2b_client_interest`
--
ALTER TABLE `b2b_client_interest`
  ADD PRIMARY KEY (`id`);

--
-- Indeksy dla tabeli `b2b_client_interest_alias`
--
ALTER TABLE `b2b_client_interest_alias`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `uq_interest_lang_type` (`id_b2b_client_interest`,`lang_code`,`alias_type`),
  ADD KEY `idx_lang_code` (`lang_code`);

--
-- Indeksy dla tabeli `b2b_client_sector`
--
ALTER TABLE `b2b_client_sector`
  ADD PRIMARY KEY (`id`);

--
-- Indeksy dla tabeli `b2b_client_sector_alias`
--
ALTER TABLE `b2b_client_sector_alias`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `uq_sector_lang_type` (`id_b2b_client_sector`,`lang_code`,`alias_type`),
  ADD KEY `idx_lang_code` (`lang_code`);

--
-- Indeksy dla tabeli `b2b_client_type`
--
ALTER TABLE `b2b_client_type`
  ADD PRIMARY KEY (`id`);

--
-- Indeksy dla tabeli `b2b_client_type_alias`
--
ALTER TABLE `b2b_client_type_alias`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `uq_type_lang_type` (`id_b2b_client_type`,`lang_code`,`alias_type`),
  ADD KEY `idx_lang_code` (`lang_code`);

--
-- Indeksy dla tabeli `benchmark_competitor`
--
ALTER TABLE `benchmark_competitor`
  ADD PRIMARY KEY (`id`),
  ADD KEY `idx_bc_shop` (`shop_id`),
  ADD KEY `idx_bc_shop_active` (`shop_id`,`is_active`),
  ADD KEY `idx_bc_shop_name` (`shop_id`,`name`);

--
-- Indeksy dla tabeli `benchmark_observation`
--
ALTER TABLE `benchmark_observation`
  ADD PRIMARY KEY (`id`),
  ADD KEY `idx_bo_shop` (`shop_id`),
  ADD KEY `idx_bo_comp` (`competitor_id`),
  ADD KEY `idx_bo_comp_date` (`competitor_id`,`observed_at`);

--
-- Indeksy dla tabeli `benchmark_observation_item`
--
ALTER TABLE `benchmark_observation_item`
  ADD PRIMARY KEY (`id`),
  ADD KEY `idx_boi_obs` (`observation_id`),
  ADD KEY `idx_boi_shop` (`shop_id`),
  ADD KEY `idx_boi_comp` (`competitor_id`),
  ADD KEY `idx_boi_shop_cat` (`shop_id`,`my_category_id`),
  ADD KEY `idx_boi_obs_cat` (`observation_id`,`my_category_id`),
  ADD KEY `my_category_id` (`my_category_id`),
  ADD KEY `my_product_id` (`my_product_id`);

--
-- Indeksy dla tabeli `client`
--
ALTER TABLE `client`
  ADD PRIMARY KEY (`id`);

--
-- Indeksy dla tabeli `client_invoice`
--
ALTER TABLE `client_invoice`
  ADD PRIMARY KEY (`id`),
  ADD KEY `idx_invoice_shop_date` (`id_shop`,`invoiced_date`,`id`);

--
-- Indeksy dla tabeli `client_invoice_product`
--
ALTER TABLE `client_invoice_product`
  ADD PRIMARY KEY (`id`),
  ADD KEY `idx_prod_invoice` (`id_invoice`);

--
-- Indeksy dla tabeli `client_offer`
--
ALTER TABLE `client_offer`
  ADD PRIMARY KEY (`id`);

--
-- Indeksy dla tabeli `client_offer_product`
--
ALTER TABLE `client_offer_product`
  ADD PRIMARY KEY (`id`);

--
-- Indeksy dla tabeli `client_order`
--
ALTER TABLE `client_order`
  ADD PRIMARY KEY (`id`);

--
-- Indeksy dla tabeli `client_order_product`
--
ALTER TABLE `client_order_product`
  ADD PRIMARY KEY (`id`);

--
-- Indeksy dla tabeli `client_order_rejection_reason`
--
ALTER TABLE `client_order_rejection_reason`
  ADD PRIMARY KEY (`id`);

--
-- Indeksy dla tabeli `client_order_rejection_reason_alias`
--
ALTER TABLE `client_order_rejection_reason_alias`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `uq_reason_lang_type` (`id_client_order_rejection_reason`,`lang_code`,`alias_type`),
  ADD KEY `idx_lang_code` (`lang_code`);

--
-- Indeksy dla tabeli `competency`
--
ALTER TABLE `competency`
  ADD PRIMARY KEY (`id`),
  ADD KEY `competency_ibfk_1` (`id_subcategory`);

--
-- Indeksy dla tabeli `competency_category`
--
ALTER TABLE `competency_category`
  ADD PRIMARY KEY (`id`);

--
-- Indeksy dla tabeli `competency_knowledge_resource_connection`
--
ALTER TABLE `competency_knowledge_resource_connection`
  ADD PRIMARY KEY (`id`);

--
-- Indeksy dla tabeli `competency_operational_procedure_connection`
--
ALTER TABLE `competency_operational_procedure_connection`
  ADD PRIMARY KEY (`id`);

--
-- Indeksy dla tabeli `competency_subcategory`
--
ALTER TABLE `competency_subcategory`
  ADD PRIMARY KEY (`id`),
  ADD KEY `id_category` (`id_category`);

--
-- Indeksy dla tabeli `competency_training_connection`
--
ALTER TABLE `competency_training_connection`
  ADD PRIMARY KEY (`id`);

--
-- Indeksy dla tabeli `complaint`
--
ALTER TABLE `complaint`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `uq_complaint_key` (`complaint_key`),
  ADD KEY `idx_shop_status` (`id_shop`,`status`),
  ADD KEY `idx_export_status_shop` (`id_shop`,`id`),
  ADD KEY `idx_delivery` (`id_order`),
  ADD KEY `idx_material` (`id_material`);

--
-- Indeksy dla tabeli `complaint_attachment`
--
ALTER TABLE `complaint_attachment`
  ADD PRIMARY KEY (`id`),
  ADD KEY `idx_complaint` (`complaint_id`);

--
-- Indeksy dla tabeli `complaint_outbox`
--
ALTER TABLE `complaint_outbox`
  ADD PRIMARY KEY (`id`),
  ADD KEY `idx_complaint_outbox_status` (`export_status`),
  ADD KEY `idx_complaint_outbox_uuid` (`uuid`),
  ADD KEY `fk_complaint_outbox_complaint` (`complaint_id`);

--
-- Indeksy dla tabeli `complaint_reason`
--
ALTER TABLE `complaint_reason`
  ADD PRIMARY KEY (`code`),
  ADD UNIQUE KEY `uq_name` (`name`);

--
-- Indeksy dla tabeli `country`
--
ALTER TABLE `country`
  ADD PRIMARY KEY (`country_code`);

--
-- Indeksy dla tabeli `country_translation`
--
ALTER TABLE `country_translation`
  ADD PRIMARY KEY (`country_code`,`locale`);

--
-- Indeksy dla tabeli `course`
--
ALTER TABLE `course`
  ADD PRIMARY KEY (`id`);

--
-- Indeksy dla tabeli `course_commission`
--
ALTER TABLE `course_commission`
  ADD PRIMARY KEY (`id`);

--
-- Indeksy dla tabeli `course_commissioning_course`
--
ALTER TABLE `course_commissioning_course`
  ADD PRIMARY KEY (`id`);

--
-- Indeksy dla tabeli `course_completion_by_employee`
--
ALTER TABLE `course_completion_by_employee`
  ADD PRIMARY KEY (`id`);

--
-- Indeksy dla tabeli `course_group`
--
ALTER TABLE `course_group`
  ADD PRIMARY KEY (`id`);

--
-- Indeksy dla tabeli `course_instructor`
--
ALTER TABLE `course_instructor`
  ADD PRIMARY KEY (`id`);

--
-- Indeksy dla tabeli `course_set`
--
ALTER TABLE `course_set`
  ADD PRIMARY KEY (`id`);

--
-- Indeksy dla tabeli `course_subgroup`
--
ALTER TABLE `course_subgroup`
  ADD PRIMARY KEY (`id`);

--
-- Indeksy dla tabeli `customer_survey_question`
--
ALTER TABLE `customer_survey_question`
  ADD PRIMARY KEY (`id`);

--
-- Indeksy dla tabeli `customer_survey_question_alias`
--
ALTER TABLE `customer_survey_question_alias`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `uq_question_lang_type` (`id_customer_survey_question`,`lang_code`,`alias_type`),
  ADD KEY `idx_lang_code` (`lang_code`);

--
-- Indeksy dla tabeli `customer_survey_question_answer`
--
ALTER TABLE `customer_survey_question_answer`
  ADD PRIMARY KEY (`id`);

--
-- Indeksy dla tabeli `customer_survey_question_answer_alias`
--
ALTER TABLE `customer_survey_question_answer_alias`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `uq_answer_lang_type` (`id_answer`,`lang_code`,`alias_type`),
  ADD KEY `idx_lang_code` (`lang_code`);

--
-- Indeksy dla tabeli `daily_shift`
--
ALTER TABLE `daily_shift`
  ADD PRIMARY KEY (`id`);

--
-- Indeksy dla tabeli `demand`
--
ALTER TABLE `demand`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `uq_demand_ref` (`ref`),
  ADD KEY `idx_demand_status` (`status`),
  ADD KEY `idx_demand_type` (`type`),
  ADD KEY `idx_demand_shop_id` (`shop_id`),
  ADD KEY `idx_demand_created_by` (`created_by_user_id`),
  ADD KEY `idx_demand_created_at` (`created_at`);

--
-- Indeksy dla tabeli `demand_comment`
--
ALTER TABLE `demand_comment`
  ADD PRIMARY KEY (`id`),
  ADD KEY `idx_dc_demand_id` (`demand_id`);

--
-- Indeksy dla tabeli `demand_status_history`
--
ALTER TABLE `demand_status_history`
  ADD PRIMARY KEY (`id`),
  ADD KEY `idx_dsh_demand_id` (`demand_id`);

--
-- Indeksy dla tabeli `device_auth_session`
--
ALTER TABLE `device_auth_session`
  ADD PRIMARY KEY (`id`),
  ADD KEY `device_id` (`device_id`),
  ADD KEY `token_hash` (`token_hash`),
  ADD KEY `replaced_by_id` (`replaced_by_id`);

--
-- Indeksy dla tabeli `domain_functional_category`
--
ALTER TABLE `domain_functional_category`
  ADD PRIMARY KEY (`id`),
  ADD KEY `section_id` (`section_id`);

--
-- Indeksy dla tabeli `domain_functional_category_description_alias`
--
ALTER TABLE `domain_functional_category_description_alias`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `uq_category_lang_type` (`category_id`,`lang_code`,`alias_type`) USING BTREE,
  ADD KEY `idx_lang_code` (`lang_code`) USING BTREE;

--
-- Indeksy dla tabeli `domain_functional_category_name_alias`
--
ALTER TABLE `domain_functional_category_name_alias`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `uq_category_lang_type` (`category_id`,`lang_code`,`alias_type`) USING BTREE,
  ADD KEY `idx_lang_code` (`lang_code`) USING BTREE;

--
-- Indeksy dla tabeli `domain_functional_section`
--
ALTER TABLE `domain_functional_section`
  ADD PRIMARY KEY (`id`);

--
-- Indeksy dla tabeli `domain_functional_section_description_alias`
--
ALTER TABLE `domain_functional_section_description_alias`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `uq_section_lang_type` (`section_id`,`lang_code`,`alias_type`) USING BTREE,
  ADD KEY `idx_lang_code` (`lang_code`) USING BTREE;

--
-- Indeksy dla tabeli `domain_functional_section_name_alias`
--
ALTER TABLE `domain_functional_section_name_alias`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `uq_section_lang_type` (`section_id`,`lang_code`,`alias_type`) USING BTREE,
  ADD KEY `idx_lang_code` (`lang_code`) USING BTREE;

--
-- Indeksy dla tabeli `domain_functional_subcategory`
--
ALTER TABLE `domain_functional_subcategory`
  ADD PRIMARY KEY (`id`),
  ADD KEY `category_id` (`category_id`);

--
-- Indeksy dla tabeli `domain_functional_subcategory_description_alias`
--
ALTER TABLE `domain_functional_subcategory_description_alias`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `uq_subcategory_lang_type` (`subcategory_id`,`lang_code`,`alias_type`) USING BTREE,
  ADD KEY `idx_lang_code` (`lang_code`) USING BTREE;

--
-- Indeksy dla tabeli `domain_functional_subcategory_name_alias`
--
ALTER TABLE `domain_functional_subcategory_name_alias`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `uq_subcategory_lang_type` (`subcategory_id`,`lang_code`,`alias_type`) USING BTREE,
  ADD KEY `idx_lang_code` (`lang_code`) USING BTREE;

--
-- Indeksy dla tabeli `email_log`
--
ALTER TABLE `email_log`
  ADD PRIMARY KEY (`id`),
  ADD KEY `recipient_email` (`recipient_email`),
  ADD KEY `sent_at` (`sent_at`),
  ADD KEY `id_employee` (`id_employee`),
  ADD KEY `email_log_ibfk_2` (`id_shop`);

--
-- Indeksy dla tabeli `email_template`
--
ALTER TABLE `email_template`
  ADD PRIMARY KEY (`id`);

--
-- Indeksy dla tabeli `employee_competency_connection`
--
ALTER TABLE `employee_competency_connection`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `uq_employee_competency` (`employee_id`,`competency_id`) USING BTREE,
  ADD KEY `competency_id` (`competency_id`);

--
-- Indeksy dla tabeli `employee_position_connection`
--
ALTER TABLE `employee_position_connection`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `uq_employee_position` (`employee_id`,`position_id`) USING BTREE,
  ADD KEY `employee_id` (`employee_id`),
  ADD KEY `position_id` (`position_id`),
  ADD KEY `level_id` (`level_id`);

--
-- Indeksy dla tabeli `employee_role`
--
ALTER TABLE `employee_role`
  ADD PRIMARY KEY (`id`);

--
-- Indeksy dla tabeli `employee_workstation_connection`
--
ALTER TABLE `employee_workstation_connection`
  ADD KEY `id_employee` (`employee_id`),
  ADD KEY `id_workstation` (`workstation_id`);

--
-- Indeksy dla tabeli `external_supplier_auth`
--
ALTER TABLE `external_supplier_auth`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `uniq_external_supplier_auth_login` (`login`);

--
-- Indeksy dla tabeli `external_supplier_auth_session`
--
ALTER TABLE `external_supplier_auth_session`
  ADD PRIMARY KEY (`id`),
  ADD KEY `idx_ext_supp_sess_hash` (`token_hash`),
  ADD KEY `idx_ext_supp_sess_user` (`external_supplier_auth_id`),
  ADD KEY `idx_ext_supp_sess_replaced` (`replaced_by_id`);

--
-- Indeksy dla tabeli `file_attachment`
--
ALTER TABLE `file_attachment`
  ADD PRIMARY KEY (`id`);

--
-- Indeksy dla tabeli `flattened_recipe_for_label`
--
ALTER TABLE `flattened_recipe_for_label`
  ADD PRIMARY KEY (`id_recipe`,`lang_code`);

--
-- Indeksy dla tabeli `flattened_recipe_ingredient`
--
ALTER TABLE `flattened_recipe_ingredient`
  ADD KEY `idx_fri_id_recipe` (`id_recipe`),
  ADD KEY `idx_fri_id_material` (`id_material`);

--
-- Indeksy dla tabeli `franchisee_brand`
--
ALTER TABLE `franchisee_brand`
  ADD PRIMARY KEY (`id`);

--
-- Indeksy dla tabeli `franchisee_employee`
--
ALTER TABLE `franchisee_employee`
  ADD PRIMARY KEY (`id`),
  ADD KEY `id_role` (`id_role`);

--
-- Indeksy dla tabeli `franchisee_employee_competence`
--
ALTER TABLE `franchisee_employee_competence`
  ADD PRIMARY KEY (`id`);

--
-- Indeksy dla tabeli `franchisee_employee_competence_description_alias`
--
ALTER TABLE `franchisee_employee_competence_description_alias`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `uq_competence_desc_lang_type` (`id_competence`,`lang_code`,`alias_type`),
  ADD KEY `idx_lang_code` (`lang_code`);

--
-- Indeksy dla tabeli `franchisee_employee_competence_group`
--
ALTER TABLE `franchisee_employee_competence_group`
  ADD PRIMARY KEY (`id`);

--
-- Indeksy dla tabeli `franchisee_employee_competence_group_description_alias`
--
ALTER TABLE `franchisee_employee_competence_group_description_alias`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `uq_competence_group_desc_lang_type` (`id_competence_group`,`lang_code`,`alias_type`),
  ADD KEY `idx_lang_code` (`lang_code`);

--
-- Indeksy dla tabeli `franchisee_employee_competence_group_name_alias`
--
ALTER TABLE `franchisee_employee_competence_group_name_alias`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `uq_competence_group_name_lang_type` (`id_competence_group`,`lang_code`,`alias_type`),
  ADD KEY `idx_lang_code` (`lang_code`);

--
-- Indeksy dla tabeli `franchisee_employee_competence_name_alias`
--
ALTER TABLE `franchisee_employee_competence_name_alias`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `uq_competence_name_lang_type` (`id_competence`,`lang_code`,`alias_type`),
  ADD KEY `idx_lang_code` (`lang_code`);

--
-- Indeksy dla tabeli `franchisee_employee_competence_subgroup`
--
ALTER TABLE `franchisee_employee_competence_subgroup`
  ADD PRIMARY KEY (`id`);

--
-- Indeksy dla tabeli `franchisee_employee_competence_subgroup_description_alias`
--
ALTER TABLE `franchisee_employee_competence_subgroup_description_alias`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `uq_competence_subgroup_desc_lang_type` (`id_subgroup`,`lang_code`,`alias_type`),
  ADD KEY `idx_lang_code` (`lang_code`);

--
-- Indeksy dla tabeli `franchisee_employee_competence_subgroup_name_alias`
--
ALTER TABLE `franchisee_employee_competence_subgroup_name_alias`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `uq_competence_subgroup_name_lang_type` (`id_subgroup`,`lang_code`,`alias_type`),
  ADD KEY `idx_lang_code` (`lang_code`);

--
-- Indeksy dla tabeli `franchisee_employee_production_area`
--
ALTER TABLE `franchisee_employee_production_area`
  ADD PRIMARY KEY (`id`);

--
-- Indeksy dla tabeli `franchisee_employee_production_area_description_alias`
--
ALTER TABLE `franchisee_employee_production_area_description_alias`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `uq_prod_area_desc_lang_type` (`id_production_area`,`lang_code`,`alias_type`),
  ADD KEY `idx_lang_code` (`lang_code`);

--
-- Indeksy dla tabeli `franchisee_employee_production_area_name_alias`
--
ALTER TABLE `franchisee_employee_production_area_name_alias`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `uq_prod_area_name_lang_type` (`id_production_area`,`lang_code`,`alias_type`),
  ADD KEY `idx_lang_code` (`lang_code`);

--
-- Indeksy dla tabeli `franchisee_employee_role`
--
ALTER TABLE `franchisee_employee_role`
  ADD PRIMARY KEY (`id`);

--
-- Indeksy dla tabeli `franchisee_employee_schedule`
--
ALTER TABLE `franchisee_employee_schedule`
  ADD PRIMARY KEY (`id`);

--
-- Indeksy dla tabeli `franchisee_employee_workstation`
--
ALTER TABLE `franchisee_employee_workstation`
  ADD PRIMARY KEY (`id`);

--
-- Indeksy dla tabeli `franchisee_employee_workstation_alias`
--
ALTER TABLE `franchisee_employee_workstation_alias`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `uq_workstation_lang_type` (`id_workstation`,`lang_code`,`alias_type`),
  ADD KEY `idx_lang_code` (`lang_code`);

--
-- Indeksy dla tabeli `franchisee_shop`
--
ALTER TABLE `franchisee_shop`
  ADD PRIMARY KEY (`id`);

--
-- Indeksy dla tabeli `franchisee_shop_device`
--
ALTER TABLE `franchisee_shop_device`
  ADD PRIMARY KEY (`id`);

--
-- Indeksy dla tabeli `franchisee_system_user_role`
--
ALTER TABLE `franchisee_system_user_role`
  ADD PRIMARY KEY (`id`);

--
-- Indeksy dla tabeli `franchisee_task_type`
--
ALTER TABLE `franchisee_task_type`
  ADD PRIMARY KEY (`id`);

--
-- Indeksy dla tabeli `franchisee_task_type_alias`
--
ALTER TABLE `franchisee_task_type_alias`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `uq_task_type_lang_type` (`id_task_type`,`lang_code`,`alias_type`),
  ADD KEY `idx_lang_code` (`lang_code`);

--
-- Indeksy dla tabeli `knowledge_base_resource`
--
ALTER TABLE `knowledge_base_resource`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `uq_marketing_material_slug` (`slug`),
  ADD UNIQUE KEY `uq_marketing_material_ulid_str` (`ulid_str`),
  ADD KEY `idx_material_status_publish` (`status`,`publish_at`),
  ADD KEY `id_category` (`id_category`);
ALTER TABLE `knowledge_base_resource` ADD FULLTEXT KEY `ftx_material_text` (`title`,`summary`);

--
-- Indeksy dla tabeli `knowledge_base_resource_category`
--
ALTER TABLE `knowledge_base_resource_category`
  ADD PRIMARY KEY (`id`);

--
-- Indeksy dla tabeli `knowledge_base_resource_shop_connection`
--
ALTER TABLE `knowledge_base_resource_shop_connection`
  ADD PRIMARY KEY (`id_resource`,`id_shop`);

--
-- Indeksy dla tabeli `marketing_campaign`
--
ALTER TABLE `marketing_campaign`
  ADD PRIMARY KEY (`id`);

--
-- Indeksy dla tabeli `marketing_campaign_alias`
--
ALTER TABLE `marketing_campaign_alias`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `uq_marketing_campaign_lang_type` (`id_marketing_campaign`,`lang_code`,`alias_type`),
  ADD KEY `idx_lang_code` (`lang_code`);

--
-- Indeksy dla tabeli `marketing_material`
--
ALTER TABLE `marketing_material`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `uq_marketing_material_slug` (`slug`),
  ADD UNIQUE KEY `uq_marketing_material_ulid_str` (`ulid_str`),
  ADD KEY `idx_material_status_publish` (`status`,`publish_at`);
ALTER TABLE `marketing_material` ADD FULLTEXT KEY `ftx_material_text` (`title`,`summary`);

--
-- Indeksy dla tabeli `marketing_material_shop_connection`
--
ALTER TABLE `marketing_material_shop_connection`
  ADD PRIMARY KEY (`id_material`,`id_shop`);

--
-- Indeksy dla tabeli `marketing_material_summary_alias`
--
ALTER TABLE `marketing_material_summary_alias`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `uq_marketing_material_summary_lang_type` (`id_marketing_material`,`lang_code`,`alias_type`),
  ADD KEY `idx_lang_code` (`lang_code`);

--
-- Indeksy dla tabeli `marketing_material_title_alias`
--
ALTER TABLE `marketing_material_title_alias`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `uq_marketing_material_title_lang_type` (`id_marketing_material`,`lang_code`,`alias_type`),
  ADD KEY `idx_lang_code` (`lang_code`);

--
-- Indeksy dla tabeli `material`
--
ALTER TABLE `material`
  ADD PRIMARY KEY (`id`);

--
-- Indeksy dla tabeli `material_alias`
--
ALTER TABLE `material_alias`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `uq_material_lang` (`id_material`,`lang_code`,`alias_type`) USING BTREE;

--
-- Indeksy dla tabeli `material_category`
--
ALTER TABLE `material_category`
  ADD PRIMARY KEY (`id`);

--
-- Indeksy dla tabeli `material_category_alias`
--
ALTER TABLE `material_category_alias`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `uq_material_category_lang_type` (`id_material_category`,`lang_code`,`alias_type`),
  ADD KEY `idx_lang_code` (`lang_code`);

--
-- Indeksy dla tabeli `material_country_vat_rates_connection`
--
ALTER TABLE `material_country_vat_rates_connection`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `id_material` (`id_material`,`country_code`,`valid_from`) USING BTREE;

--
-- Indeksy dla tabeli `material_inventory`
--
ALTER TABLE `material_inventory`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `id_shop` (`id_shop`,`id_material`),
  ADD KEY `idx_mi_id_material` (`id_material`);

--
-- Indeksy dla tabeli `material_inventory_log`
--
ALTER TABLE `material_inventory_log`
  ADD PRIMARY KEY (`id`);

--
-- Indeksy dla tabeli `material_movement_reason`
--
ALTER TABLE `material_movement_reason`
  ADD UNIQUE KEY `code` (`code`);

--
-- Indeksy dla tabeli `material_order`
--
ALTER TABLE `material_order`
  ADD PRIMARY KEY (`id`);

--
-- Indeksy dla tabeli `material_order_in_transit_item`
--
ALTER TABLE `material_order_in_transit_item`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `uq_transit` (`id_order`,`supplier_sku`,`pack_size_in_base_unit`,`id_unit`),
  ADD UNIQUE KEY `uq_transit_order_sku` (`id_order`,`supplier_sku`),
  ADD KEY `idx_order` (`id_order`);

--
-- Indeksy dla tabeli `material_order_item`
--
ALTER TABLE `material_order_item`
  ADD PRIMARY KEY (`id`);

--
-- Indeksy dla tabeli `material_pack`
--
ALTER TABLE `material_pack`
  ADD PRIMARY KEY (`id`);

--
-- Indeksy dla tabeli `material_proforma_documents`
--
ALTER TABLE `material_proforma_documents`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `fk_proforma_uuid` (`proforma_uuid`);

--
-- Indeksy dla tabeli `material_proforma_download_log`
--
ALTER TABLE `material_proforma_download_log`
  ADD PRIMARY KEY (`id`),
  ADD KEY `idx_pdl_uuid_day` (`proforma_uuid`,`requested_at`);

--
-- Indeksy dla tabeli `material_proforma_download_quota`
--
ALTER TABLE `material_proforma_download_quota`
  ADD PRIMARY KEY (`proforma_uuid`,`shop_id`,`day_date`);

--
-- Indeksy dla tabeli `material_proforma_receipts`
--
ALTER TABLE `material_proforma_receipts`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `fk_idempotency_key` (`idempotency_key`),
  ADD KEY `fk_order_key` (`order_key`);

--
-- Indeksy dla tabeli `material_requisition`
--
ALTER TABLE `material_requisition`
  ADD PRIMARY KEY (`id`);

--
-- Indeksy dla tabeli `material_requisition_item`
--
ALTER TABLE `material_requisition_item`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `unique_requisition_material` (`id_requisition`,`id_material`),
  ADD KEY `idx_requisition` (`id_requisition`);

--
-- Indeksy dla tabeli `material_supplier`
--
ALTER TABLE `material_supplier`
  ADD PRIMARY KEY (`id`);

--
-- Indeksy dla tabeli `material_supplier_api_connection`
--
ALTER TABLE `material_supplier_api_connection`
  ADD PRIMARY KEY (`id`);

--
-- Indeksy dla tabeli `material_supplier_contact`
--
ALTER TABLE `material_supplier_contact`
  ADD PRIMARY KEY (`id`),
  ADD KEY `id_supplier` (`id_supplier`),
  ADD KEY `supplier_contact_ibfk_2` (`id_shop`);

--
-- Indeksy dla tabeli `material_supplier_type`
--
ALTER TABLE `material_supplier_type`
  ADD PRIMARY KEY (`id`);

--
-- Indeksy dla tabeli `network_countries`
--
ALTER TABLE `network_countries`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `iso2` (`iso2`);

--
-- Indeksy dla tabeli `network_franchise_types`
--
ALTER TABLE `network_franchise_types`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `code` (`code`);

--
-- Indeksy dla tabeli `notification`
--
ALTER TABLE `notification`
  ADD PRIMARY KEY (`id`);

--
-- Indeksy dla tabeli `notification_read_log`
--
ALTER TABLE `notification_read_log`
  ADD PRIMARY KEY (`id_notification`,`id_employee`) USING BTREE;

--
-- Indeksy dla tabeli `notification_target`
--
ALTER TABLE `notification_target`
  ADD PRIMARY KEY (`id_notification`,`id_shop`);

--
-- Indeksy dla tabeli `operational_procedure`
--
ALTER TABLE `operational_procedure`
  ADD PRIMARY KEY (`id`),
  ADD KEY `subcategory_id` (`subcategory_id`);

--
-- Indeksy dla tabeli `operational_procedure_attachment`
--
ALTER TABLE `operational_procedure_attachment`
  ADD PRIMARY KEY (`id`);

--
-- Indeksy dla tabeli `operational_procedure_attachment_label_alias`
--
ALTER TABLE `operational_procedure_attachment_label_alias`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `uq_attachment_lang_type` (`id_attachment`,`lang_code`,`alias_type`) USING BTREE,
  ADD KEY `idx_lang_code` (`lang_code`) USING BTREE;

--
-- Indeksy dla tabeli `operational_procedure_category`
--
ALTER TABLE `operational_procedure_category`
  ADD PRIMARY KEY (`id`);

--
-- Indeksy dla tabeli `operational_procedure_category_description_alias`
--
ALTER TABLE `operational_procedure_category_description_alias`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `uq_category_lang_type` (`id_category`,`lang_code`,`alias_type`) USING BTREE,
  ADD KEY `idx_lang_code` (`lang_code`) USING BTREE;

--
-- Indeksy dla tabeli `operational_procedure_category_name_alias`
--
ALTER TABLE `operational_procedure_category_name_alias`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `uq_category_lang_type` (`id_category`,`lang_code`,`alias_type`) USING BTREE,
  ADD KEY `idx_lang_code` (`lang_code`) USING BTREE;

--
-- Indeksy dla tabeli `operational_procedure_description_alias`
--
ALTER TABLE `operational_procedure_description_alias`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `uq_procedure_lang_type` (`id_procedure`,`lang_code`,`alias_type`) USING BTREE,
  ADD KEY `idx_lang_code` (`lang_code`) USING BTREE;

--
-- Indeksy dla tabeli `operational_procedure_section`
--
ALTER TABLE `operational_procedure_section`
  ADD PRIMARY KEY (`id`);

--
-- Indeksy dla tabeli `operational_procedure_section_content_alias`
--
ALTER TABLE `operational_procedure_section_content_alias`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `uq_procedure_lang_type` (`id_procedure`,`lang_code`,`alias_type`) USING BTREE,
  ADD KEY `idx_lang_code` (`lang_code`) USING BTREE;

--
-- Indeksy dla tabeli `operational_procedure_section_title`
--
ALTER TABLE `operational_procedure_section_title`
  ADD PRIMARY KEY (`id`);

--
-- Indeksy dla tabeli `operational_procedure_section_title_alias`
--
ALTER TABLE `operational_procedure_section_title_alias`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `uq_title_lang_type` (`id_title`,`lang_code`,`alias_type`) USING BTREE,
  ADD KEY `idx_lang_code` (`lang_code`);

--
-- Indeksy dla tabeli `operational_procedure_title_alias`
--
ALTER TABLE `operational_procedure_title_alias`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `uq_procedure_lang_type` (`id_procedure`,`lang_code`,`alias_type`) USING BTREE,
  ADD KEY `idx_lang_code` (`lang_code`) USING BTREE;

--
-- Indeksy dla tabeli `operational_procedure_todo_link`
--
ALTER TABLE `operational_procedure_todo_link`
  ADD PRIMARY KEY (`id`);

--
-- Indeksy dla tabeli `operational_procedure_todo_link_note_alias`
--
ALTER TABLE `operational_procedure_todo_link_note_alias`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `uq_link_lang_type` (`id_link`,`lang_code`,`alias_type`) USING BTREE,
  ADD KEY `idx_lang_code` (`lang_code`) USING BTREE;

--
-- Indeksy dla tabeli `package_material_connection`
--
ALTER TABLE `package_material_connection`
  ADD PRIMARY KEY (`id`);

--
-- Indeksy dla tabeli `payment_method`
--
ALTER TABLE `payment_method`
  ADD PRIMARY KEY (`id`);

--
-- Indeksy dla tabeli `peppol_documents`
--
ALTER TABLE `peppol_documents`
  ADD PRIMARY KEY (`id`);

--
-- Indeksy dla tabeli `peppol_error_log`
--
ALTER TABLE `peppol_error_log`
  ADD PRIMARY KEY (`id`);

--
-- Indeksy dla tabeli `peppol_participant`
--
ALTER TABLE `peppol_participant`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `uq_id_shop_identifier` (`id_shop`,`identifier`);

--
-- Indeksy dla tabeli `peppol_registration_error_log`
--
ALTER TABLE `peppol_registration_error_log`
  ADD PRIMARY KEY (`id`);

--
-- Indeksy dla tabeli `permission`
--
ALTER TABLE `permission`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `uq_permission_app_code` (`app`,`code`),
  ADD KEY `idx_permission_app_module` (`app`,`module`),
  ADD KEY `idx_permission_active` (`is_active`);

--
-- Indeksy dla tabeli `position`
--
ALTER TABLE `position`
  ADD PRIMARY KEY (`id`);

--
-- Indeksy dla tabeli `position_level`
--
ALTER TABLE `position_level`
  ADD PRIMARY KEY (`id`),
  ADD KEY `id_path` (`position_id`);

--
-- Indeksy dla tabeli `position_level_competency_connection`
--
ALTER TABLE `position_level_competency_connection`
  ADD PRIMARY KEY (`id`),
  ADD KEY `id_competency` (`competency_id`),
  ADD KEY `id_stage` (`level_id`);

--
-- Indeksy dla tabeli `position_level_permission`
--
ALTER TABLE `position_level_permission`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `uq_level_permission` (`position_level_id`,`permission_id`),
  ADD KEY `idx_plp_permission` (`permission_id`);

--
-- Indeksy dla tabeli `position_level_stage_requirement`
--
ALTER TABLE `position_level_stage_requirement`
  ADD PRIMARY KEY (`id`),
  ADD KEY `id_stage` (`level_id`);

--
-- Indeksy dla tabeli `position_level_task_connection`
--
ALTER TABLE `position_level_task_connection`
  ADD PRIMARY KEY (`id`),
  ADD KEY `level_id` (`level_id`),
  ADD KEY `position_level_task_connection_ibfk_2` (`task_id`);

--
-- Indeksy dla tabeli `pricelist_state`
--
ALTER TABLE `pricelist_state`
  ADD PRIMARY KEY (`shop_uid`);

--
-- Indeksy dla tabeli `price_list_archive`
--
ALTER TABLE `price_list_archive`
  ADD PRIMARY KEY (`id`);

--
-- Indeksy dla tabeli `price_list_product_archive`
--
ALTER TABLE `price_list_product_archive`
  ADD PRIMARY KEY (`id`);

--
-- Indeksy dla tabeli `price_updates`
--
ALTER TABLE `price_updates`
  ADD PRIMARY KEY (`id`);

--
-- Indeksy dla tabeli `product`
--
ALTER TABLE `product`
  ADD PRIMARY KEY (`id`),
  ADD KEY `idx_product_id_recipe` (`id_recipe`);

--
-- Indeksy dla tabeli `product_alias`
--
ALTER TABLE `product_alias`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `uq_product_lang` (`id_product`,`lang_code`,`alias_type`) USING BTREE;

--
-- Indeksy dla tabeli `product_availability_period`
--
ALTER TABLE `product_availability_period`
  ADD PRIMARY KEY (`id`),
  ADD KEY `idx_pap_active` (`is_active`),
  ADD KEY `idx_pap_mode_range` (`is_recurring`,`start_date`,`end_date`),
  ADD KEY `idx_pap_md` (`is_recurring`,`from_md`,`to_md`),
  ADD KEY `pap_fixed_idx` (`is_active`,`is_recurring`,`start_date`,`end_date`);

--
-- Indeksy dla tabeli `product_availability_period_connection`
--
ALTER TABLE `product_availability_period_connection`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `idx_unique_product_period` (`id_product`,`id_period`),
  ADD KEY `idx_product_period` (`id_product`,`id_period`),
  ADD KEY `idx_product` (`id_product`),
  ADD KEY `idx_period` (`id_period`);

--
-- Indeksy dla tabeli `product_availability_period_description_alias`
--
ALTER TABLE `product_availability_period_description_alias`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `uq_prod_avail_period_desc_lang_type` (`id_product_availability_period`,`lang_code`,`alias_type`),
  ADD KEY `idx_lang_code` (`lang_code`);

--
-- Indeksy dla tabeli `product_availability_period_name_alias`
--
ALTER TABLE `product_availability_period_name_alias`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `uq_prod_avail_period_name_lang_type` (`id_product_availability_period`,`lang_code`,`alias_type`),
  ADD KEY `idx_lang_code` (`lang_code`);

--
-- Indeksy dla tabeli `product_category`
--
ALTER TABLE `product_category`
  ADD PRIMARY KEY (`id`);

--
-- Indeksy dla tabeli `product_category_alias`
--
ALTER TABLE `product_category_alias`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `uq_category_lang` (`id_category`,`lang_code`,`alias_type`) USING BTREE;

--
-- Indeksy dla tabeli `product_category_group`
--
ALTER TABLE `product_category_group`
  ADD PRIMARY KEY (`id`);

--
-- Indeksy dla tabeli `product_category_group_alias`
--
ALTER TABLE `product_category_group_alias`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `uq_category_group_lang` (`id_category_group`,`lang_code`,`alias_type`) USING BTREE;

--
-- Indeksy dla tabeli `product_competence`
--
ALTER TABLE `product_competence`
  ADD PRIMARY KEY (`id`);

--
-- Indeksy dla tabeli `product_competence_description_alias`
--
ALTER TABLE `product_competence_description_alias`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `uq_product_competence_desc_lang_type` (`id_product_competence`,`lang_code`,`alias_type`),
  ADD KEY `idx_lang_code` (`lang_code`);

--
-- Indeksy dla tabeli `product_competence_name_alias`
--
ALTER TABLE `product_competence_name_alias`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `uq_product_competence_name_lang_type` (`id_product_competence`,`lang_code`,`alias_type`),
  ADD KEY `idx_lang_code` (`lang_code`);

--
-- Indeksy dla tabeli `product_movement`
--
ALTER TABLE `product_movement`
  ADD PRIMARY KEY (`id`);

--
-- Indeksy dla tabeli `product_package`
--
ALTER TABLE `product_package`
  ADD PRIMARY KEY (`id`);

--
-- Indeksy dla tabeli `product_package_description_alias`
--
ALTER TABLE `product_package_description_alias`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `uq_product_package_desc_lang_type` (`id_product_package`,`lang_code`,`alias_type`),
  ADD KEY `idx_lang_code` (`lang_code`);

--
-- Indeksy dla tabeli `product_package_name_alias`
--
ALTER TABLE `product_package_name_alias`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `uq_product_package_name_lang_type` (`id_product_package`,`lang_code`,`alias_type`),
  ADD KEY `idx_lang_code` (`lang_code`);

--
-- Indeksy dla tabeli `product_positioning`
--
ALTER TABLE `product_positioning`
  ADD PRIMARY KEY (`id`);

--
-- Indeksy dla tabeli `product_positioning_description_alias`
--
ALTER TABLE `product_positioning_description_alias`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `uq_product_positioning_desc_lang_type` (`id_product_positioning`,`lang_code`,`alias_type`),
  ADD KEY `idx_lang_code` (`lang_code`);

--
-- Indeksy dla tabeli `product_positioning_name_alias`
--
ALTER TABLE `product_positioning_name_alias`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `uq_product_positioning_name_lang_type` (`id_product_positioning`,`lang_code`,`alias_type`),
  ADD KEY `idx_lang_code` (`lang_code`);

--
-- Indeksy dla tabeli `product_recipe`
--
ALTER TABLE `product_recipe`
  ADD PRIMARY KEY (`id`);

--
-- Indeksy dla tabeli `product_recipe_alias`
--
ALTER TABLE `product_recipe_alias`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `uq_recipe_lang` (`id_recipe`,`lang_code`,`alias_type`) USING BTREE;

--
-- Indeksy dla tabeli `product_recipe_preparation_step`
--
ALTER TABLE `product_recipe_preparation_step`
  ADD PRIMARY KEY (`id`);

--
-- Indeksy dla tabeli `product_recipe_preparation_step_alias`
--
ALTER TABLE `product_recipe_preparation_step_alias`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `uq_step_lang_type` (`id_preparation_step`,`lang_code`,`alias_type`),
  ADD KEY `idx_lang_code` (`lang_code`);

--
-- Indeksy dla tabeli `product_recipe_preparation_type`
--
ALTER TABLE `product_recipe_preparation_type`
  ADD PRIMARY KEY (`id`);

--
-- Indeksy dla tabeli `product_recipe_preparation_type_alias`
--
ALTER TABLE `product_recipe_preparation_type_alias`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `uq_preparation_type_lang_type` (`id_preparation_type`,`lang_code`,`alias_type`),
  ADD KEY `idx_lang_code` (`lang_code`);

--
-- Indeksy dla tabeli `product_storage`
--
ALTER TABLE `product_storage`
  ADD PRIMARY KEY (`id`);

--
-- Indeksy dla tabeli `product_storage_description_alias`
--
ALTER TABLE `product_storage_description_alias`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `uq_product_storage_desc_lang_type` (`id_product_storage`,`lang_code`,`alias_type`),
  ADD KEY `idx_lang_code` (`lang_code`);

--
-- Indeksy dla tabeli `product_storage_name_alias`
--
ALTER TABLE `product_storage_name_alias`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `uq_product_storage_name_lang_type` (`id_product_storage`,`lang_code`,`alias_type`),
  ADD KEY `idx_lang_code` (`lang_code`);

--
-- Indeksy dla tabeli `product_subrecipe_category`
--
ALTER TABLE `product_subrecipe_category`
  ADD PRIMARY KEY (`id`);

--
-- Indeksy dla tabeli `product_subrecipe_category_alias`
--
ALTER TABLE `product_subrecipe_category_alias`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `uq_subrecipe_cat_lang_type` (`id_product_subrecipe_category`,`lang_code`,`alias_type`),
  ADD KEY `idx_lang_code` (`lang_code`);

--
-- Indeksy dla tabeli `promo_code`
--
ALTER TABLE `promo_code`
  ADD PRIMARY KEY (`id`);

--
-- Indeksy dla tabeli `promo_code_product`
--
ALTER TABLE `promo_code_product`
  ADD PRIMARY KEY (`id`);

--
-- Indeksy dla tabeli `promo_code_type`
--
ALTER TABLE `promo_code_type`
  ADD PRIMARY KEY (`id`);

--
-- Indeksy dla tabeli `recipe_cost`
--
ALTER TABLE `recipe_cost`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `id_recipe` (`id_recipe`,`id_shop`,`id_brand`) USING BTREE;

--
-- Indeksy dla tabeli `recipe_cost_archive`
--
ALTER TABLE `recipe_cost_archive`
  ADD PRIMARY KEY (`id`),
  ADD KEY `idx_rca_lookup` (`id_shop`,`id_recipe`,`valid_from`,`valid_to`);

--
-- Indeksy dla tabeli `secret_share`
--
ALTER TABLE `secret_share`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `uq_share` (`share_id`),
  ADD KEY `fk_share_conn` (`integration_connection_id`);

--
-- Indeksy dla tabeli `shop_cost`
--
ALTER TABLE `shop_cost`
  ADD PRIMARY KEY (`id`);

--
-- Indeksy dla tabeli `shop_cost_alias`
--
ALTER TABLE `shop_cost_alias`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `uq_shop_cost_lang_type` (`id_shop_cost`,`lang_code`,`alias_type`),
  ADD KEY `idx_lang_code` (`lang_code`);

--
-- Indeksy dla tabeli `shop_cost_connection`
--
ALTER TABLE `shop_cost_connection`
  ADD PRIMARY KEY (`id`);

--
-- Indeksy dla tabeli `shop_material_order_outbox`
--
ALTER TABLE `shop_material_order_outbox`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `uq_order_key` (`order_key`),
  ADD KEY `idx_shop_status` (`id_shop`,`status`) USING BTREE;

--
-- Indeksy dla tabeli `shop_material_packaging_price_list`
--
ALTER TABLE `shop_material_packaging_price_list`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `id_packaging` (`id_packaging`,`id_supplier`,`id_shop`,`valid_from`) USING BTREE;

--
-- Indeksy dla tabeli `shop_material_price_list`
--
ALTER TABLE `shop_material_price_list`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `id_material` (`id_material`,`id_shop`) USING BTREE;

--
-- Indeksy dla tabeli `shop_material_supplier_connection`
--
ALTER TABLE `shop_material_supplier_connection`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `id_shop` (`id_shop`,`id_supplier`) USING BTREE;

--
-- Indeksy dla tabeli `shop_material_supplier_delivery_day`
--
ALTER TABLE `shop_material_supplier_delivery_day`
  ADD PRIMARY KEY (`id`);

--
-- Indeksy dla tabeli `shop_material_supplier_integration_connection`
--
ALTER TABLE `shop_material_supplier_integration_connection`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `uq_supplier_shop` (`id_supplier`,`id_shop`),
  ADD UNIQUE KEY `activation_code` (`activation_code`),
  ADD KEY `idx_supplier` (`id_supplier`),
  ADD KEY `idx_shop` (`id_shop`);

--
-- Indeksy dla tabeli `shop_product`
--
ALTER TABLE `shop_product`
  ADD PRIMARY KEY (`id`);

--
-- Indeksy dla tabeli `shop_supplier_pack_default`
--
ALTER TABLE `shop_supplier_pack_default`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `id_shop` (`id_shop`,`id_material`) USING BTREE;

--
-- Indeksy dla tabeli `shop_workstation`
--
ALTER TABLE `shop_workstation`
  ADD PRIMARY KEY (`id`);

--
-- Indeksy dla tabeli `shop_workstation_description_alias`
--
ALTER TABLE `shop_workstation_description_alias`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `uq_workstation_lang_type` (`id_workstation`,`lang_code`,`alias_type`) USING BTREE,
  ADD KEY `idx_lang_code` (`lang_code`) USING BTREE;

--
-- Indeksy dla tabeli `shop_workstation_name_alias`
--
ALTER TABLE `shop_workstation_name_alias`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `uq_workstation_lang_type` (`id_workstation`,`lang_code`,`alias_type`) USING BTREE,
  ADD KEY `idx_lang_code` (`lang_code`) USING BTREE;

--
-- Indeksy dla tabeli `stocktaking`
--
ALTER TABLE `stocktaking`
  ADD PRIMARY KEY (`id`);

--
-- Indeksy dla tabeli `stocktaking_item`
--
ALTER TABLE `stocktaking_item`
  ADD PRIMARY KEY (`id`);

--
-- Indeksy dla tabeli `stocktaking_summary`
--
ALTER TABLE `stocktaking_summary`
  ADD PRIMARY KEY (`id`);

--
-- Indeksy dla tabeli `supplier_catalog_product`
--
ALTER TABLE `supplier_catalog_product`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `uq_supplier_sku` (`supplier_id`,`sku`),
  ADD KEY `idx_supplier` (`supplier_id`),
  ADD KEY `idx_active` (`supplier_id`,`is_active`);

--
-- Indeksy dla tabeli `supplier_catalog_product_allergen`
--
ALTER TABLE `supplier_catalog_product_allergen`
  ADD PRIMARY KEY (`product_id`,`allergen_id`),
  ADD KEY `idx_allergen` (`allergen_id`);

--
-- Indeksy dla tabeli `supplier_catalog_product_mapping`
--
ALTER TABLE `supplier_catalog_product_mapping`
  ADD PRIMARY KEY (`id`),
  ADD KEY `catalog_product_id` (`catalog_product_id`),
  ADD KEY `material_id` (`material_id`);

--
-- Indeksy dla tabeli `supplier_catalog_product_spec`
--
ALTER TABLE `supplier_catalog_product_spec`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `product_id` (`product_id`,`lang_code`);

--
-- Indeksy dla tabeli `supplier_pack_connection`
--
ALTER TABLE `supplier_pack_connection`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `id_supplier` (`id_supplier`,`id_material`,`id_packaging`) USING BTREE;

--
-- Indeksy dla tabeli `supplier_product_price_list`
--
ALTER TABLE `supplier_product_price_list`
  ADD PRIMARY KEY (`id`),
  ADD KEY `product_id` (`product_id`),
  ADD KEY `shop_id` (`shop_id`),
  ADD KEY `supplier_id` (`supplier_id`);

--
-- Indeksy dla tabeli `todo_daily_close`
--
ALTER TABLE `todo_daily_close`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `uniq_employee_day` (`employee_id`,`day`),
  ADD UNIQUE KEY `uniq_close` (`shop_id`,`employee_id`,`day`),
  ADD KEY `idx_shop_day` (`shop_id`,`day`);

--
-- Indeksy dla tabeli `todo_task`
--
ALTER TABLE `todo_task`
  ADD PRIMARY KEY (`id`);

--
-- Indeksy dla tabeli `todo_task_completion`
--
ALTER TABLE `todo_task_completion`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `uniq_occurrence` (`task_id`,`shop_id`,`scheduled_for_date`,`scheduled_time`),
  ADD KEY `idx_shop_day` (`shop_id`,`scheduled_for_date`),
  ADD KEY `idx_task_day` (`task_id`,`scheduled_for_date`);

--
-- Indeksy dla tabeli `todo_task_description_alias`
--
ALTER TABLE `todo_task_description_alias`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `uq_todo_task_desc_lang_type` (`id_todo_task`,`lang_code`,`alias_type`),
  ADD KEY `idx_lang_code` (`lang_code`);

--
-- Indeksy dla tabeli `todo_task_name_alias`
--
ALTER TABLE `todo_task_name_alias`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `uq_todo_task_name_lang_type` (`id_todo_task`,`lang_code`,`alias_type`),
  ADD KEY `idx_lang_code` (`lang_code`);

--
-- Indeksy dla tabeli `todo_task_set`
--
ALTER TABLE `todo_task_set`
  ADD PRIMARY KEY (`id`);

--
-- Indeksy dla tabeli `todo_task_set_description_alias`
--
ALTER TABLE `todo_task_set_description_alias`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `uq_todo_task_set_desc_lang_type` (`id_todo_task_set`,`lang_code`,`alias_type`),
  ADD KEY `idx_lang_code` (`lang_code`);

--
-- Indeksy dla tabeli `todo_task_set_name_alias`
--
ALTER TABLE `todo_task_set_name_alias`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `uq_todo_task_set_name_lang_type` (`id_todo_task_set`,`lang_code`,`alias_type`),
  ADD KEY `idx_lang_code` (`lang_code`);

--
-- Indeksy dla tabeli `todo_task_subtype`
--
ALTER TABLE `todo_task_subtype`
  ADD PRIMARY KEY (`id`);

--
-- Indeksy dla tabeli `todo_task_subtype_alias`
--
ALTER TABLE `todo_task_subtype_alias`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `uq_todo_task_subtype_lang_type` (`id_todo_task_subtype`,`lang_code`,`alias_type`),
  ADD KEY `idx_lang_code` (`lang_code`);

--
-- Indeksy dla tabeli `todo_task_type`
--
ALTER TABLE `todo_task_type`
  ADD PRIMARY KEY (`id`);

--
-- Indeksy dla tabeli `todo_task_type_alias`
--
ALTER TABLE `todo_task_type_alias`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `uq_todo_task_type_lang_type` (`id_todo_task_type`,`lang_code`,`alias_type`),
  ADD KEY `idx_lang_code` (`lang_code`);

--
-- Indeksy dla tabeli `training`
--
ALTER TABLE `training`
  ADD PRIMARY KEY (`id`),
  ADD KEY `id_subgroup` (`subcategory_id`);

--
-- Indeksy dla tabeli `training_admin_role_connection`
--
ALTER TABLE `training_admin_role_connection`
  ADD PRIMARY KEY (`id`),
  ADD KEY `training_id` (`training_id`),
  ADD KEY `admin_role_id` (`admin_role_id`);

--
-- Indeksy dla tabeli `training_employee_role_connection`
--
ALTER TABLE `training_employee_role_connection`
  ADD PRIMARY KEY (`id`),
  ADD KEY `employee_role_id` (`employee_role_id`),
  ADD KEY `training_id` (`training_id`);

--
-- Indeksy dla tabeli `transaction`
--
ALTER TABLE `transaction`
  ADD PRIMARY KEY (`id`),
  ADD KEY `idx_transaction_insert_ts` (`insert_timestamp`),
  ADD KEY `idx_transaction_id` (`id`),
  ADD KEY `idx_trans_invoice` (`id_invoice`),
  ADD KEY `idx_t_shop_ts` (`id_shop`,`insert_timestamp`);

--
-- Indeksy dla tabeli `transaction_product`
--
ALTER TABLE `transaction_product`
  ADD PRIMARY KEY (`id`),
  ADD KEY `idx_tp_id_transaction` (`id_transaction`),
  ADD KEY `idx_tp_id_product` (`id_product`),
  ADD KEY `idx_tp_trx` (`id_transaction`,`id_product`,`quantity`);

--
-- Indeksy dla tabeli `unit`
--
ALTER TABLE `unit`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `unit_name` (`name`);

--
-- Indeksy dla tabeli `user_membership`
--
ALTER TABLE `user_membership`
  ADD PRIMARY KEY (`id`),
  ADD KEY `auth_user_id` (`auth_user_id`);

--
-- Indeksy dla tabeli `user_profile`
--
ALTER TABLE `user_profile`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `ux_user_profile_auth_user` (`auth_user_id`);

--
-- Indeksy dla tabeli `webhook_inbox`
--
ALTER TABLE `webhook_inbox`
  ADD PRIMARY KEY (`shop_uid`,`event_id`);

--
-- Indeksy dla tabeli `week_days`
--
ALTER TABLE `week_days`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `code` (`code`);

--
-- Indeksy dla tabeli `withdrawing_money_reason`
--
ALTER TABLE `withdrawing_money_reason`
  ADD PRIMARY KEY (`id`);

--
-- Indeksy dla tabeli `withdrawing_money_reason_content_alias`
--
ALTER TABLE `withdrawing_money_reason_content_alias`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `uq_wmr_content_lang_type` (`id_withdrawing_money_reason`,`lang_code`,`alias_type`),
  ADD KEY `idx_lang_code` (`lang_code`);

--
-- Indeksy dla tabeli `withdrawing_money_reason_description_alias`
--
ALTER TABLE `withdrawing_money_reason_description_alias`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `uq_wmr_desc_lang_type` (`id_withdrawing_money_reason`,`lang_code`,`alias_type`),
  ADD KEY `idx_lang_code` (`lang_code`);

--
-- AUTO_INCREMENT for dumped tables
--

--
-- AUTO_INCREMENT for table `admin_panel_user`
--
ALTER TABLE `admin_panel_user`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `admin_panel_user_permission`
--
ALTER TABLE `admin_panel_user_permission`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `admin_panel_user_permission_group`
--
ALTER TABLE `admin_panel_user_permission_group`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `admin_panel_user_role`
--
ALTER TABLE `admin_panel_user_role`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `admin_panel_user_role_alias`
--
ALTER TABLE `admin_panel_user_role_alias`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `allergen`
--
ALTER TABLE `allergen`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `auth_session`
--
ALTER TABLE `auth_session`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `auth_user`
--
ALTER TABLE `auth_user`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `b2b_client_company_department`
--
ALTER TABLE `b2b_client_company_department`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `b2b_client_interest`
--
ALTER TABLE `b2b_client_interest`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `b2b_client_interest_alias`
--
ALTER TABLE `b2b_client_interest_alias`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `b2b_client_sector`
--
ALTER TABLE `b2b_client_sector`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `b2b_client_sector_alias`
--
ALTER TABLE `b2b_client_sector_alias`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `b2b_client_type`
--
ALTER TABLE `b2b_client_type`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `b2b_client_type_alias`
--
ALTER TABLE `b2b_client_type_alias`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `benchmark_competitor`
--
ALTER TABLE `benchmark_competitor`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `benchmark_observation`
--
ALTER TABLE `benchmark_observation`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `benchmark_observation_item`
--
ALTER TABLE `benchmark_observation_item`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `client`
--
ALTER TABLE `client`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `client_invoice`
--
ALTER TABLE `client_invoice`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `client_invoice_product`
--
ALTER TABLE `client_invoice_product`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `client_offer`
--
ALTER TABLE `client_offer`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `client_offer_product`
--
ALTER TABLE `client_offer_product`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `client_order`
--
ALTER TABLE `client_order`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `client_order_product`
--
ALTER TABLE `client_order_product`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `client_order_rejection_reason`
--
ALTER TABLE `client_order_rejection_reason`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `client_order_rejection_reason_alias`
--
ALTER TABLE `client_order_rejection_reason_alias`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `competency`
--
ALTER TABLE `competency`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `competency_category`
--
ALTER TABLE `competency_category`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `competency_knowledge_resource_connection`
--
ALTER TABLE `competency_knowledge_resource_connection`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `competency_operational_procedure_connection`
--
ALTER TABLE `competency_operational_procedure_connection`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `competency_subcategory`
--
ALTER TABLE `competency_subcategory`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `competency_training_connection`
--
ALTER TABLE `competency_training_connection`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `complaint`
--
ALTER TABLE `complaint`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `complaint_attachment`
--
ALTER TABLE `complaint_attachment`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `complaint_outbox`
--
ALTER TABLE `complaint_outbox`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `course`
--
ALTER TABLE `course`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `course_commission`
--
ALTER TABLE `course_commission`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `course_commissioning_course`
--
ALTER TABLE `course_commissioning_course`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `course_completion_by_employee`
--
ALTER TABLE `course_completion_by_employee`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `course_group`
--
ALTER TABLE `course_group`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `course_instructor`
--
ALTER TABLE `course_instructor`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `course_set`
--
ALTER TABLE `course_set`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `course_subgroup`
--
ALTER TABLE `course_subgroup`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `customer_survey_question`
--
ALTER TABLE `customer_survey_question`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `customer_survey_question_alias`
--
ALTER TABLE `customer_survey_question_alias`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `customer_survey_question_answer`
--
ALTER TABLE `customer_survey_question_answer`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `customer_survey_question_answer_alias`
--
ALTER TABLE `customer_survey_question_answer_alias`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `daily_shift`
--
ALTER TABLE `daily_shift`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `demand`
--
ALTER TABLE `demand`
  MODIFY `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `demand_comment`
--
ALTER TABLE `demand_comment`
  MODIFY `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `demand_status_history`
--
ALTER TABLE `demand_status_history`
  MODIFY `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `device_auth_session`
--
ALTER TABLE `device_auth_session`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `domain_functional_category`
--
ALTER TABLE `domain_functional_category`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `domain_functional_category_description_alias`
--
ALTER TABLE `domain_functional_category_description_alias`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `domain_functional_category_name_alias`
--
ALTER TABLE `domain_functional_category_name_alias`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `domain_functional_section`
--
ALTER TABLE `domain_functional_section`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `domain_functional_section_description_alias`
--
ALTER TABLE `domain_functional_section_description_alias`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `domain_functional_section_name_alias`
--
ALTER TABLE `domain_functional_section_name_alias`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `domain_functional_subcategory`
--
ALTER TABLE `domain_functional_subcategory`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `domain_functional_subcategory_description_alias`
--
ALTER TABLE `domain_functional_subcategory_description_alias`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `domain_functional_subcategory_name_alias`
--
ALTER TABLE `domain_functional_subcategory_name_alias`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `email_log`
--
ALTER TABLE `email_log`
  MODIFY `id` bigint(20) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `email_template`
--
ALTER TABLE `email_template`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `employee_competency_connection`
--
ALTER TABLE `employee_competency_connection`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `employee_position_connection`
--
ALTER TABLE `employee_position_connection`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `employee_role`
--
ALTER TABLE `employee_role`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `external_supplier_auth`
--
ALTER TABLE `external_supplier_auth`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `external_supplier_auth_session`
--
ALTER TABLE `external_supplier_auth_session`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `file_attachment`
--
ALTER TABLE `file_attachment`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `franchisee_brand`
--
ALTER TABLE `franchisee_brand`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `franchisee_employee`
--
ALTER TABLE `franchisee_employee`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `franchisee_employee_competence`
--
ALTER TABLE `franchisee_employee_competence`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `franchisee_employee_competence_description_alias`
--
ALTER TABLE `franchisee_employee_competence_description_alias`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `franchisee_employee_competence_group`
--
ALTER TABLE `franchisee_employee_competence_group`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `franchisee_employee_competence_group_description_alias`
--
ALTER TABLE `franchisee_employee_competence_group_description_alias`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `franchisee_employee_competence_group_name_alias`
--
ALTER TABLE `franchisee_employee_competence_group_name_alias`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `franchisee_employee_competence_name_alias`
--
ALTER TABLE `franchisee_employee_competence_name_alias`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `franchisee_employee_competence_subgroup`
--
ALTER TABLE `franchisee_employee_competence_subgroup`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `franchisee_employee_competence_subgroup_description_alias`
--
ALTER TABLE `franchisee_employee_competence_subgroup_description_alias`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `franchisee_employee_competence_subgroup_name_alias`
--
ALTER TABLE `franchisee_employee_competence_subgroup_name_alias`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `franchisee_employee_production_area`
--
ALTER TABLE `franchisee_employee_production_area`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `franchisee_employee_production_area_description_alias`
--
ALTER TABLE `franchisee_employee_production_area_description_alias`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `franchisee_employee_production_area_name_alias`
--
ALTER TABLE `franchisee_employee_production_area_name_alias`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `franchisee_employee_role`
--
ALTER TABLE `franchisee_employee_role`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `franchisee_employee_schedule`
--
ALTER TABLE `franchisee_employee_schedule`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `franchisee_employee_workstation`
--
ALTER TABLE `franchisee_employee_workstation`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `franchisee_employee_workstation_alias`
--
ALTER TABLE `franchisee_employee_workstation_alias`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `franchisee_shop`
--
ALTER TABLE `franchisee_shop`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `franchisee_shop_device`
--
ALTER TABLE `franchisee_shop_device`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `franchisee_system_user_role`
--
ALTER TABLE `franchisee_system_user_role`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `franchisee_task_type`
--
ALTER TABLE `franchisee_task_type`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `franchisee_task_type_alias`
--
ALTER TABLE `franchisee_task_type_alias`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `knowledge_base_resource`
--
ALTER TABLE `knowledge_base_resource`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `knowledge_base_resource_category`
--
ALTER TABLE `knowledge_base_resource_category`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `marketing_campaign`
--
ALTER TABLE `marketing_campaign`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `marketing_campaign_alias`
--
ALTER TABLE `marketing_campaign_alias`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `marketing_material`
--
ALTER TABLE `marketing_material`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `marketing_material_summary_alias`
--
ALTER TABLE `marketing_material_summary_alias`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `marketing_material_title_alias`
--
ALTER TABLE `marketing_material_title_alias`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `material`
--
ALTER TABLE `material`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `material_alias`
--
ALTER TABLE `material_alias`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `material_category`
--
ALTER TABLE `material_category`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `material_category_alias`
--
ALTER TABLE `material_category_alias`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `material_country_vat_rates_connection`
--
ALTER TABLE `material_country_vat_rates_connection`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `material_inventory`
--
ALTER TABLE `material_inventory`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `material_inventory_log`
--
ALTER TABLE `material_inventory_log`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `material_order`
--
ALTER TABLE `material_order`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `material_order_in_transit_item`
--
ALTER TABLE `material_order_in_transit_item`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `material_order_item`
--
ALTER TABLE `material_order_item`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `material_pack`
--
ALTER TABLE `material_pack`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `material_proforma_documents`
--
ALTER TABLE `material_proforma_documents`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `material_proforma_download_log`
--
ALTER TABLE `material_proforma_download_log`
  MODIFY `id` bigint(20) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `material_proforma_receipts`
--
ALTER TABLE `material_proforma_receipts`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `material_requisition`
--
ALTER TABLE `material_requisition`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `material_requisition_item`
--
ALTER TABLE `material_requisition_item`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `material_supplier`
--
ALTER TABLE `material_supplier`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `material_supplier_api_connection`
--
ALTER TABLE `material_supplier_api_connection`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `material_supplier_contact`
--
ALTER TABLE `material_supplier_contact`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `material_supplier_type`
--
ALTER TABLE `material_supplier_type`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `network_countries`
--
ALTER TABLE `network_countries`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `network_franchise_types`
--
ALTER TABLE `network_franchise_types`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `notification`
--
ALTER TABLE `notification`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `operational_procedure`
--
ALTER TABLE `operational_procedure`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `operational_procedure_attachment`
--
ALTER TABLE `operational_procedure_attachment`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `operational_procedure_attachment_label_alias`
--
ALTER TABLE `operational_procedure_attachment_label_alias`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `operational_procedure_category`
--
ALTER TABLE `operational_procedure_category`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `operational_procedure_category_description_alias`
--
ALTER TABLE `operational_procedure_category_description_alias`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `operational_procedure_category_name_alias`
--
ALTER TABLE `operational_procedure_category_name_alias`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `operational_procedure_description_alias`
--
ALTER TABLE `operational_procedure_description_alias`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `operational_procedure_section`
--
ALTER TABLE `operational_procedure_section`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `operational_procedure_section_content_alias`
--
ALTER TABLE `operational_procedure_section_content_alias`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `operational_procedure_section_title`
--
ALTER TABLE `operational_procedure_section_title`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `operational_procedure_section_title_alias`
--
ALTER TABLE `operational_procedure_section_title_alias`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `operational_procedure_title_alias`
--
ALTER TABLE `operational_procedure_title_alias`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `operational_procedure_todo_link`
--
ALTER TABLE `operational_procedure_todo_link`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `operational_procedure_todo_link_note_alias`
--
ALTER TABLE `operational_procedure_todo_link_note_alias`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `package_material_connection`
--
ALTER TABLE `package_material_connection`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `peppol_documents`
--
ALTER TABLE `peppol_documents`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `peppol_error_log`
--
ALTER TABLE `peppol_error_log`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `peppol_participant`
--
ALTER TABLE `peppol_participant`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `peppol_registration_error_log`
--
ALTER TABLE `peppol_registration_error_log`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `permission`
--
ALTER TABLE `permission`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `position`
--
ALTER TABLE `position`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `position_level`
--
ALTER TABLE `position_level`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `position_level_competency_connection`
--
ALTER TABLE `position_level_competency_connection`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `position_level_permission`
--
ALTER TABLE `position_level_permission`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `position_level_stage_requirement`
--
ALTER TABLE `position_level_stage_requirement`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `position_level_task_connection`
--
ALTER TABLE `position_level_task_connection`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `price_list_archive`
--
ALTER TABLE `price_list_archive`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `price_list_product_archive`
--
ALTER TABLE `price_list_product_archive`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `price_updates`
--
ALTER TABLE `price_updates`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `product`
--
ALTER TABLE `product`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `product_alias`
--
ALTER TABLE `product_alias`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `product_availability_period`
--
ALTER TABLE `product_availability_period`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `product_availability_period_connection`
--
ALTER TABLE `product_availability_period_connection`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `product_availability_period_description_alias`
--
ALTER TABLE `product_availability_period_description_alias`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `product_availability_period_name_alias`
--
ALTER TABLE `product_availability_period_name_alias`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `product_category`
--
ALTER TABLE `product_category`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `product_category_alias`
--
ALTER TABLE `product_category_alias`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `product_category_group`
--
ALTER TABLE `product_category_group`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `product_category_group_alias`
--
ALTER TABLE `product_category_group_alias`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `product_competence`
--
ALTER TABLE `product_competence`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `product_competence_description_alias`
--
ALTER TABLE `product_competence_description_alias`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `product_competence_name_alias`
--
ALTER TABLE `product_competence_name_alias`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `product_movement`
--
ALTER TABLE `product_movement`
  MODIFY `id` bigint(20) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `product_package`
--
ALTER TABLE `product_package`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `product_package_description_alias`
--
ALTER TABLE `product_package_description_alias`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `product_package_name_alias`
--
ALTER TABLE `product_package_name_alias`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `product_positioning`
--
ALTER TABLE `product_positioning`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `product_positioning_description_alias`
--
ALTER TABLE `product_positioning_description_alias`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `product_positioning_name_alias`
--
ALTER TABLE `product_positioning_name_alias`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `product_recipe`
--
ALTER TABLE `product_recipe`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `product_recipe_alias`
--
ALTER TABLE `product_recipe_alias`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `product_recipe_preparation_step`
--
ALTER TABLE `product_recipe_preparation_step`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `product_recipe_preparation_step_alias`
--
ALTER TABLE `product_recipe_preparation_step_alias`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `product_recipe_preparation_type`
--
ALTER TABLE `product_recipe_preparation_type`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `product_recipe_preparation_type_alias`
--
ALTER TABLE `product_recipe_preparation_type_alias`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `product_storage`
--
ALTER TABLE `product_storage`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `product_storage_description_alias`
--
ALTER TABLE `product_storage_description_alias`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `product_storage_name_alias`
--
ALTER TABLE `product_storage_name_alias`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `product_subrecipe_category`
--
ALTER TABLE `product_subrecipe_category`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `product_subrecipe_category_alias`
--
ALTER TABLE `product_subrecipe_category_alias`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `promo_code`
--
ALTER TABLE `promo_code`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `promo_code_product`
--
ALTER TABLE `promo_code_product`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `promo_code_type`
--
ALTER TABLE `promo_code_type`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `recipe_cost`
--
ALTER TABLE `recipe_cost`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `recipe_cost_archive`
--
ALTER TABLE `recipe_cost_archive`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `secret_share`
--
ALTER TABLE `secret_share`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `shop_cost`
--
ALTER TABLE `shop_cost`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `shop_cost_alias`
--
ALTER TABLE `shop_cost_alias`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `shop_cost_connection`
--
ALTER TABLE `shop_cost_connection`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `shop_material_order_outbox`
--
ALTER TABLE `shop_material_order_outbox`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `shop_material_packaging_price_list`
--
ALTER TABLE `shop_material_packaging_price_list`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `shop_material_price_list`
--
ALTER TABLE `shop_material_price_list`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `shop_material_supplier_connection`
--
ALTER TABLE `shop_material_supplier_connection`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `shop_material_supplier_delivery_day`
--
ALTER TABLE `shop_material_supplier_delivery_day`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `shop_material_supplier_integration_connection`
--
ALTER TABLE `shop_material_supplier_integration_connection`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `shop_product`
--
ALTER TABLE `shop_product`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `shop_supplier_pack_default`
--
ALTER TABLE `shop_supplier_pack_default`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `shop_workstation`
--
ALTER TABLE `shop_workstation`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `shop_workstation_description_alias`
--
ALTER TABLE `shop_workstation_description_alias`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `shop_workstation_name_alias`
--
ALTER TABLE `shop_workstation_name_alias`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `stocktaking`
--
ALTER TABLE `stocktaking`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `stocktaking_item`
--
ALTER TABLE `stocktaking_item`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `stocktaking_summary`
--
ALTER TABLE `stocktaking_summary`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `supplier_catalog_product`
--
ALTER TABLE `supplier_catalog_product`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `supplier_catalog_product_mapping`
--
ALTER TABLE `supplier_catalog_product_mapping`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `supplier_catalog_product_spec`
--
ALTER TABLE `supplier_catalog_product_spec`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `supplier_pack_connection`
--
ALTER TABLE `supplier_pack_connection`
  MODIFY `id` bigint(20) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `supplier_product_price_list`
--
ALTER TABLE `supplier_product_price_list`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `todo_daily_close`
--
ALTER TABLE `todo_daily_close`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `todo_task`
--
ALTER TABLE `todo_task`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `todo_task_completion`
--
ALTER TABLE `todo_task_completion`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `todo_task_description_alias`
--
ALTER TABLE `todo_task_description_alias`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `todo_task_name_alias`
--
ALTER TABLE `todo_task_name_alias`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `todo_task_set`
--
ALTER TABLE `todo_task_set`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `todo_task_set_description_alias`
--
ALTER TABLE `todo_task_set_description_alias`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `todo_task_set_name_alias`
--
ALTER TABLE `todo_task_set_name_alias`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `todo_task_subtype`
--
ALTER TABLE `todo_task_subtype`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `todo_task_subtype_alias`
--
ALTER TABLE `todo_task_subtype_alias`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `todo_task_type`
--
ALTER TABLE `todo_task_type`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `todo_task_type_alias`
--
ALTER TABLE `todo_task_type_alias`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `training`
--
ALTER TABLE `training`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `training_admin_role_connection`
--
ALTER TABLE `training_admin_role_connection`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `training_employee_role_connection`
--
ALTER TABLE `training_employee_role_connection`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `transaction`
--
ALTER TABLE `transaction`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `transaction_product`
--
ALTER TABLE `transaction_product`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `unit`
--
ALTER TABLE `unit`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `user_membership`
--
ALTER TABLE `user_membership`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `user_profile`
--
ALTER TABLE `user_profile`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `withdrawing_money_reason`
--
ALTER TABLE `withdrawing_money_reason`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `withdrawing_money_reason_content_alias`
--
ALTER TABLE `withdrawing_money_reason_content_alias`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `withdrawing_money_reason_description_alias`
--
ALTER TABLE `withdrawing_money_reason_description_alias`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- Constraints for dumped tables
--

--
-- Constraints for table `admin_panel_user_permission_group_connection`
--
ALTER TABLE `admin_panel_user_permission_group_connection`
  ADD CONSTRAINT `admin_panel_user_permission_group_connection_ibfk_1` FOREIGN KEY (`id_group`) REFERENCES `admin_panel_user_permission_group` (`id`),
  ADD CONSTRAINT `admin_panel_user_permission_group_connection_ibfk_2` FOREIGN KEY (`id_permission`) REFERENCES `admin_panel_user_permission` (`id`);

--
-- Constraints for table `admin_panel_user_role_alias`
--
ALTER TABLE `admin_panel_user_role_alias`
  ADD CONSTRAINT `admin_panel_user_role_alias_ibfk_1` FOREIGN KEY (`id_admin_panel_user_role`) REFERENCES `admin_panel_user_role` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;

--
-- Constraints for table `auth_session`
--
ALTER TABLE `auth_session`
  ADD CONSTRAINT `fk_auth_session_replaced` FOREIGN KEY (`replaced_by_id`) REFERENCES `auth_session` (`id`),
  ADD CONSTRAINT `fk_auth_session_user` FOREIGN KEY (`auth_user_id`) REFERENCES `auth_user` (`id`);

--
-- Constraints for table `b2b_client_interest_alias`
--
ALTER TABLE `b2b_client_interest_alias`
  ADD CONSTRAINT `b2b_client_interest_alias_ibfk_1` FOREIGN KEY (`id_b2b_client_interest`) REFERENCES `b2b_client_interest` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;

--
-- Constraints for table `b2b_client_sector_alias`
--
ALTER TABLE `b2b_client_sector_alias`
  ADD CONSTRAINT `b2b_client_sector_alias_ibfk_1` FOREIGN KEY (`id_b2b_client_sector`) REFERENCES `b2b_client_sector` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;

--
-- Constraints for table `b2b_client_type_alias`
--
ALTER TABLE `b2b_client_type_alias`
  ADD CONSTRAINT `b2b_client_type_alias_ibfk_1` FOREIGN KEY (`id_b2b_client_type`) REFERENCES `b2b_client_type` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;

--
-- Constraints for table `benchmark_observation`
--
ALTER TABLE `benchmark_observation`
  ADD CONSTRAINT `fk_bo_competitor` FOREIGN KEY (`competitor_id`) REFERENCES `benchmark_competitor` (`id`) ON DELETE CASCADE;

--
-- Constraints for table `benchmark_observation_item`
--
ALTER TABLE `benchmark_observation_item`
  ADD CONSTRAINT `benchmark_observation_item_ibfk_1` FOREIGN KEY (`my_category_id`) REFERENCES `product_category` (`id`),
  ADD CONSTRAINT `benchmark_observation_item_ibfk_2` FOREIGN KEY (`my_product_id`) REFERENCES `product` (`id`),
  ADD CONSTRAINT `fk_boi_observation` FOREIGN KEY (`observation_id`) REFERENCES `benchmark_observation` (`id`) ON DELETE CASCADE;

--
-- Constraints for table `client_order_rejection_reason_alias`
--
ALTER TABLE `client_order_rejection_reason_alias`
  ADD CONSTRAINT `client_order_rejection_reason_alias_ibfk_1` FOREIGN KEY (`id_client_order_rejection_reason`) REFERENCES `client_order_rejection_reason` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;

--
-- Constraints for table `competency`
--
ALTER TABLE `competency`
  ADD CONSTRAINT `competency_ibfk_1` FOREIGN KEY (`id_subcategory`) REFERENCES `domain_functional_subcategory` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;

--
-- Constraints for table `competency_subcategory`
--
ALTER TABLE `competency_subcategory`
  ADD CONSTRAINT `competency_subcategory_ibfk_1` FOREIGN KEY (`id_category`) REFERENCES `competency_category` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;

--
-- Constraints for table `complaint_attachment`
--
ALTER TABLE `complaint_attachment`
  ADD CONSTRAINT `fk_c_att_c` FOREIGN KEY (`complaint_id`) REFERENCES `complaint` (`id`) ON DELETE CASCADE;

--
-- Constraints for table `complaint_outbox`
--
ALTER TABLE `complaint_outbox`
  ADD CONSTRAINT `fk_complaint_outbox_complaint` FOREIGN KEY (`complaint_id`) REFERENCES `complaint` (`id`) ON DELETE CASCADE;

--
-- Constraints for table `customer_survey_question_alias`
--
ALTER TABLE `customer_survey_question_alias`
  ADD CONSTRAINT `customer_survey_question_alias_ibfk_1` FOREIGN KEY (`id_customer_survey_question`) REFERENCES `customer_survey_question` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;

--
-- Constraints for table `customer_survey_question_answer_alias`
--
ALTER TABLE `customer_survey_question_answer_alias`
  ADD CONSTRAINT `fk_csqa_alias_answer` FOREIGN KEY (`id_answer`) REFERENCES `customer_survey_question_answer` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;

--
-- Constraints for table `demand_comment`
--
ALTER TABLE `demand_comment`
  ADD CONSTRAINT `fk_dc_demand` FOREIGN KEY (`demand_id`) REFERENCES `demand` (`id`) ON DELETE CASCADE;

--
-- Constraints for table `demand_status_history`
--
ALTER TABLE `demand_status_history`
  ADD CONSTRAINT `fk_dsh_demand` FOREIGN KEY (`demand_id`) REFERENCES `demand` (`id`) ON DELETE CASCADE;

--
-- Constraints for table `device_auth_session`
--
ALTER TABLE `device_auth_session`
  ADD CONSTRAINT `device_auth_session_ibfk_1` FOREIGN KEY (`device_id`) REFERENCES `franchisee_shop_device` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  ADD CONSTRAINT `device_auth_session_ibfk_2` FOREIGN KEY (`device_id`) REFERENCES `franchisee_shop_device` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;

--
-- Constraints for table `domain_functional_category`
--
ALTER TABLE `domain_functional_category`
  ADD CONSTRAINT `domain_functional_category_ibfk_1` FOREIGN KEY (`section_id`) REFERENCES `domain_functional_section` (`id`);

--
-- Constraints for table `domain_functional_category_description_alias`
--
ALTER TABLE `domain_functional_category_description_alias`
  ADD CONSTRAINT `domain_functional_category_description_alias_ibfk_1` FOREIGN KEY (`category_id`) REFERENCES `domain_functional_category` (`id`);

--
-- Constraints for table `domain_functional_category_name_alias`
--
ALTER TABLE `domain_functional_category_name_alias`
  ADD CONSTRAINT `domain_functional_category_name_alias_ibfk_1` FOREIGN KEY (`category_id`) REFERENCES `domain_functional_category` (`id`);

--
-- Constraints for table `domain_functional_section_description_alias`
--
ALTER TABLE `domain_functional_section_description_alias`
  ADD CONSTRAINT `domain_functional_section_description_alias_ibfk_1` FOREIGN KEY (`section_id`) REFERENCES `domain_functional_section` (`id`);

--
-- Constraints for table `domain_functional_section_name_alias`
--
ALTER TABLE `domain_functional_section_name_alias`
  ADD CONSTRAINT `domain_functional_section_name_alias_ibfk_1` FOREIGN KEY (`section_id`) REFERENCES `domain_functional_section` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;

--
-- Constraints for table `domain_functional_subcategory`
--
ALTER TABLE `domain_functional_subcategory`
  ADD CONSTRAINT `domain_functional_subcategory_ibfk_1` FOREIGN KEY (`category_id`) REFERENCES `domain_functional_category` (`id`);

--
-- Constraints for table `domain_functional_subcategory_description_alias`
--
ALTER TABLE `domain_functional_subcategory_description_alias`
  ADD CONSTRAINT `domain_functional_subcategory_description_alias_ibfk_1` FOREIGN KEY (`subcategory_id`) REFERENCES `domain_functional_subcategory` (`id`);

--
-- Constraints for table `domain_functional_subcategory_name_alias`
--
ALTER TABLE `domain_functional_subcategory_name_alias`
  ADD CONSTRAINT `domain_functional_subcategory_name_alias_ibfk_1` FOREIGN KEY (`subcategory_id`) REFERENCES `domain_functional_subcategory` (`id`);

--
-- Constraints for table `email_log`
--
ALTER TABLE `email_log`
  ADD CONSTRAINT `email_log_ibfk_1` FOREIGN KEY (`id_employee`) REFERENCES `franchisee_employee` (`id`),
  ADD CONSTRAINT `email_log_ibfk_2` FOREIGN KEY (`id_shop`) REFERENCES `franchisee_shop` (`id`);

--
-- Constraints for table `employee_competency_connection`
--
ALTER TABLE `employee_competency_connection`
  ADD CONSTRAINT `employee_competency_connection_ibfk_1` FOREIGN KEY (`competency_id`) REFERENCES `competency` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  ADD CONSTRAINT `employee_competency_connection_ibfk_2` FOREIGN KEY (`employee_id`) REFERENCES `franchisee_employee` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;

--
-- Constraints for table `employee_position_connection`
--
ALTER TABLE `employee_position_connection`
  ADD CONSTRAINT `employee_position_connection_ibfk_1` FOREIGN KEY (`level_id`) REFERENCES `position_level` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;

--
-- Constraints for table `employee_workstation_connection`
--
ALTER TABLE `employee_workstation_connection`
  ADD CONSTRAINT `employee_workstation_connection_ibfk_1` FOREIGN KEY (`employee_id`) REFERENCES `franchisee_employee` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  ADD CONSTRAINT `employee_workstation_connection_ibfk_2` FOREIGN KEY (`workstation_id`) REFERENCES `shop_workstation` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;

--
-- Constraints for table `external_supplier_auth_session`
--
ALTER TABLE `external_supplier_auth_session`
  ADD CONSTRAINT `fk_ext_supp_sess_user` FOREIGN KEY (`external_supplier_auth_id`) REFERENCES `external_supplier_auth` (`id`) ON DELETE CASCADE;

--
-- Constraints for table `franchisee_employee`
--
ALTER TABLE `franchisee_employee`
  ADD CONSTRAINT `franchisee_employee_ibfk_1` FOREIGN KEY (`id_role`) REFERENCES `employee_role` (`id`);

--
-- Constraints for table `franchisee_employee_competence_description_alias`
--
ALTER TABLE `franchisee_employee_competence_description_alias`
  ADD CONSTRAINT `fk_competence_description_alias` FOREIGN KEY (`id_competence`) REFERENCES `franchisee_employee_competence` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;

--
-- Constraints for table `franchisee_employee_competence_group_description_alias`
--
ALTER TABLE `franchisee_employee_competence_group_description_alias`
  ADD CONSTRAINT `fk_competence_group_description_alias` FOREIGN KEY (`id_competence_group`) REFERENCES `franchisee_employee_competence_group` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;

--
-- Constraints for table `franchisee_employee_competence_group_name_alias`
--
ALTER TABLE `franchisee_employee_competence_group_name_alias`
  ADD CONSTRAINT `fk_competence_group_name_alias` FOREIGN KEY (`id_competence_group`) REFERENCES `franchisee_employee_competence_group` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;

--
-- Constraints for table `franchisee_employee_competence_name_alias`
--
ALTER TABLE `franchisee_employee_competence_name_alias`
  ADD CONSTRAINT `fk_competence_name_alias` FOREIGN KEY (`id_competence`) REFERENCES `franchisee_employee_competence` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;

--
-- Constraints for table `franchisee_employee_competence_subgroup_description_alias`
--
ALTER TABLE `franchisee_employee_competence_subgroup_description_alias`
  ADD CONSTRAINT `fk_competence_subgroup_description_alias` FOREIGN KEY (`id_subgroup`) REFERENCES `franchisee_employee_competence_subgroup` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;

--
-- Constraints for table `franchisee_employee_competence_subgroup_name_alias`
--
ALTER TABLE `franchisee_employee_competence_subgroup_name_alias`
  ADD CONSTRAINT `fk_competence_subgroup_name_alias` FOREIGN KEY (`id_subgroup`) REFERENCES `franchisee_employee_competence_subgroup` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;

--
-- Constraints for table `franchisee_employee_production_area_description_alias`
--
ALTER TABLE `franchisee_employee_production_area_description_alias`
  ADD CONSTRAINT `fk_prod_area_description_alias` FOREIGN KEY (`id_production_area`) REFERENCES `franchisee_employee_production_area` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;

--
-- Constraints for table `franchisee_employee_production_area_name_alias`
--
ALTER TABLE `franchisee_employee_production_area_name_alias`
  ADD CONSTRAINT `fk_prod_area_name_alias` FOREIGN KEY (`id_production_area`) REFERENCES `franchisee_employee_production_area` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;

--
-- Constraints for table `franchisee_employee_workstation_alias`
--
ALTER TABLE `franchisee_employee_workstation_alias`
  ADD CONSTRAINT `fk_workstation_alias` FOREIGN KEY (`id_workstation`) REFERENCES `franchisee_employee_workstation` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;

--
-- Constraints for table `franchisee_task_type_alias`
--
ALTER TABLE `franchisee_task_type_alias`
  ADD CONSTRAINT `fk_task_type_alias` FOREIGN KEY (`id_task_type`) REFERENCES `franchisee_task_type` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;

--
-- Constraints for table `knowledge_base_resource`
--
ALTER TABLE `knowledge_base_resource`
  ADD CONSTRAINT `knowledge_base_resource_ibfk_1` FOREIGN KEY (`id_category`) REFERENCES `knowledge_base_resource_category` (`id`);

--
-- Constraints for table `marketing_campaign_alias`
--
ALTER TABLE `marketing_campaign_alias`
  ADD CONSTRAINT `fk_marketing_campaign_alias` FOREIGN KEY (`id_marketing_campaign`) REFERENCES `marketing_campaign` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;

--
-- Constraints for table `marketing_material_shop_connection`
--
ALTER TABLE `marketing_material_shop_connection`
  ADD CONSTRAINT `fk_mmvs_material` FOREIGN KEY (`id_material`) REFERENCES `marketing_material` (`id`) ON DELETE CASCADE;

--
-- Constraints for table `marketing_material_summary_alias`
--
ALTER TABLE `marketing_material_summary_alias`
  ADD CONSTRAINT `fk_marketing_material_summary_alias` FOREIGN KEY (`id_marketing_material`) REFERENCES `marketing_material` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;

--
-- Constraints for table `marketing_material_title_alias`
--
ALTER TABLE `marketing_material_title_alias`
  ADD CONSTRAINT `fk_marketing_material_title_alias` FOREIGN KEY (`id_marketing_material`) REFERENCES `marketing_material` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;

--
-- Constraints for table `material_alias`
--
ALTER TABLE `material_alias`
  ADD CONSTRAINT `material_alias_ibfk_1` FOREIGN KEY (`id_material`) REFERENCES `material` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;

--
-- Constraints for table `material_category_alias`
--
ALTER TABLE `material_category_alias`
  ADD CONSTRAINT `fk_material_category_alias` FOREIGN KEY (`id_material_category`) REFERENCES `material_category` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;

--
-- Constraints for table `material_order_in_transit_item`
--
ALTER TABLE `material_order_in_transit_item`
  ADD CONSTRAINT `fk_transit_order` FOREIGN KEY (`id_order`) REFERENCES `material_order` (`id`);

--
-- Constraints for table `material_supplier_contact`
--
ALTER TABLE `material_supplier_contact`
  ADD CONSTRAINT `material_supplier_contact_ibfk_1` FOREIGN KEY (`id_supplier`) REFERENCES `material_supplier` (`id`) ON DELETE CASCADE,
  ADD CONSTRAINT `material_supplier_contact_ibfk_2` FOREIGN KEY (`id_shop`) REFERENCES `franchisee_shop` (`id`) ON DELETE CASCADE;

--
-- Constraints for table `notification_read_log`
--
ALTER TABLE `notification_read_log`
  ADD CONSTRAINT `notification_read_log_ibfk_1` FOREIGN KEY (`id_notification`) REFERENCES `notification` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;

--
-- Constraints for table `notification_target`
--
ALTER TABLE `notification_target`
  ADD CONSTRAINT `notification_target_ibfk_1` FOREIGN KEY (`id_notification`) REFERENCES `notification` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;

--
-- Constraints for table `operational_procedure`
--
ALTER TABLE `operational_procedure`
  ADD CONSTRAINT `operational_procedure_ibfk_1` FOREIGN KEY (`subcategory_id`) REFERENCES `domain_functional_subcategory` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;

--
-- Constraints for table `position_level`
--
ALTER TABLE `position_level`
  ADD CONSTRAINT `position_level_ibfk_1` FOREIGN KEY (`position_id`) REFERENCES `position` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;

--
-- Constraints for table `position_level_competency_connection`
--
ALTER TABLE `position_level_competency_connection`
  ADD CONSTRAINT `position_level_competency_connection_ibfk_1` FOREIGN KEY (`competency_id`) REFERENCES `competency` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  ADD CONSTRAINT `position_level_competency_connection_ibfk_2` FOREIGN KEY (`level_id`) REFERENCES `position_level` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;

--
-- Constraints for table `position_level_permission`
--
ALTER TABLE `position_level_permission`
  ADD CONSTRAINT `fk_plp_permission` FOREIGN KEY (`permission_id`) REFERENCES `permission` (`id`) ON DELETE CASCADE;

--
-- Constraints for table `position_level_stage_requirement`
--
ALTER TABLE `position_level_stage_requirement`
  ADD CONSTRAINT `position_level_stage_requirement_ibfk_1` FOREIGN KEY (`level_id`) REFERENCES `position_level` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;

--
-- Constraints for table `position_level_task_connection`
--
ALTER TABLE `position_level_task_connection`
  ADD CONSTRAINT `position_level_task_connection_ibfk_1` FOREIGN KEY (`level_id`) REFERENCES `position_level` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  ADD CONSTRAINT `position_level_task_connection_ibfk_2` FOREIGN KEY (`task_id`) REFERENCES `todo_task` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;

--
-- Constraints for table `product_alias`
--
ALTER TABLE `product_alias`
  ADD CONSTRAINT `product_alias_ibfk_1` FOREIGN KEY (`id_product`) REFERENCES `product` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;

--
-- Constraints for table `product_availability_period_description_alias`
--
ALTER TABLE `product_availability_period_description_alias`
  ADD CONSTRAINT `fk_prod_avail_period_description_alias` FOREIGN KEY (`id_product_availability_period`) REFERENCES `product_availability_period` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;

--
-- Constraints for table `product_availability_period_name_alias`
--
ALTER TABLE `product_availability_period_name_alias`
  ADD CONSTRAINT `fk_prod_avail_period_name_alias` FOREIGN KEY (`id_product_availability_period`) REFERENCES `product_availability_period` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;

--
-- Constraints for table `product_category_alias`
--
ALTER TABLE `product_category_alias`
  ADD CONSTRAINT `product_category_alias_ibfk_1` FOREIGN KEY (`id_category`) REFERENCES `product_category` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;

--
-- Constraints for table `product_category_group_alias`
--
ALTER TABLE `product_category_group_alias`
  ADD CONSTRAINT `product_category_group_alias_ibfk_1` FOREIGN KEY (`id_category_group`) REFERENCES `product_category_group` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;

--
-- Constraints for table `product_competence_description_alias`
--
ALTER TABLE `product_competence_description_alias`
  ADD CONSTRAINT `fk_product_competence_description_alias` FOREIGN KEY (`id_product_competence`) REFERENCES `product_competence` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;

--
-- Constraints for table `product_competence_name_alias`
--
ALTER TABLE `product_competence_name_alias`
  ADD CONSTRAINT `fk_product_competence_name_alias` FOREIGN KEY (`id_product_competence`) REFERENCES `product_competence` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;

--
-- Constraints for table `product_package_description_alias`
--
ALTER TABLE `product_package_description_alias`
  ADD CONSTRAINT `fk_product_package_description_alias` FOREIGN KEY (`id_product_package`) REFERENCES `product_package` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;

--
-- Constraints for table `product_package_name_alias`
--
ALTER TABLE `product_package_name_alias`
  ADD CONSTRAINT `fk_product_package_name_alias` FOREIGN KEY (`id_product_package`) REFERENCES `product_package` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;

--
-- Constraints for table `product_positioning_description_alias`
--
ALTER TABLE `product_positioning_description_alias`
  ADD CONSTRAINT `fk_product_positioning_description_alias` FOREIGN KEY (`id_product_positioning`) REFERENCES `product_positioning` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;

--
-- Constraints for table `product_positioning_name_alias`
--
ALTER TABLE `product_positioning_name_alias`
  ADD CONSTRAINT `fk_product_positioning_name_alias` FOREIGN KEY (`id_product_positioning`) REFERENCES `product_positioning` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;

--
-- Constraints for table `product_recipe_alias`
--
ALTER TABLE `product_recipe_alias`
  ADD CONSTRAINT `recipe_alias_ibfk_1` FOREIGN KEY (`id_recipe`) REFERENCES `product_recipe` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;

--
-- Constraints for table `product_recipe_preparation_step_alias`
--
ALTER TABLE `product_recipe_preparation_step_alias`
  ADD CONSTRAINT `fk_preparation_step_alias` FOREIGN KEY (`id_preparation_step`) REFERENCES `product_recipe_preparation_step` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;

--
-- Constraints for table `product_recipe_preparation_type_alias`
--
ALTER TABLE `product_recipe_preparation_type_alias`
  ADD CONSTRAINT `fk_preparation_type_alias` FOREIGN KEY (`id_preparation_type`) REFERENCES `product_recipe_preparation_type` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;

--
-- Constraints for table `product_storage_description_alias`
--
ALTER TABLE `product_storage_description_alias`
  ADD CONSTRAINT `fk_product_storage_description_alias` FOREIGN KEY (`id_product_storage`) REFERENCES `product_storage` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;

--
-- Constraints for table `product_storage_name_alias`
--
ALTER TABLE `product_storage_name_alias`
  ADD CONSTRAINT `fk_product_storage_name_alias` FOREIGN KEY (`id_product_storage`) REFERENCES `product_storage` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;

--
-- Constraints for table `product_subrecipe_category_alias`
--
ALTER TABLE `product_subrecipe_category_alias`
  ADD CONSTRAINT `fk_subrecipe_category_alias` FOREIGN KEY (`id_product_subrecipe_category`) REFERENCES `product_subrecipe_category` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;

--
-- Constraints for table `secret_share`
--
ALTER TABLE `secret_share`
  ADD CONSTRAINT `fk_share_conn` FOREIGN KEY (`integration_connection_id`) REFERENCES `shop_material_supplier_integration_connection` (`id`) ON DELETE CASCADE;

--
-- Constraints for table `shop_cost_alias`
--
ALTER TABLE `shop_cost_alias`
  ADD CONSTRAINT `fk_shop_cost_alias` FOREIGN KEY (`id_shop_cost`) REFERENCES `shop_cost` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;

--
-- Constraints for table `supplier_catalog_product`
--
ALTER TABLE `supplier_catalog_product`
  ADD CONSTRAINT `fk_scp_supplier` FOREIGN KEY (`supplier_id`) REFERENCES `material_supplier` (`id`);

--
-- Constraints for table `supplier_catalog_product_allergen`
--
ALTER TABLE `supplier_catalog_product_allergen`
  ADD CONSTRAINT `fk_scpa_allergen` FOREIGN KEY (`allergen_id`) REFERENCES `allergen` (`id`),
  ADD CONSTRAINT `fk_scpa_product` FOREIGN KEY (`product_id`) REFERENCES `supplier_catalog_product` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;

--
-- Constraints for table `supplier_catalog_product_mapping`
--
ALTER TABLE `supplier_catalog_product_mapping`
  ADD CONSTRAINT `supplier_catalog_product_mapping_ibfk_1` FOREIGN KEY (`catalog_product_id`) REFERENCES `supplier_catalog_product` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  ADD CONSTRAINT `supplier_catalog_product_mapping_ibfk_2` FOREIGN KEY (`material_id`) REFERENCES `material` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;

--
-- Constraints for table `supplier_catalog_product_spec`
--
ALTER TABLE `supplier_catalog_product_spec`
  ADD CONSTRAINT `supplier_catalog_product_spec_ibfk_1` FOREIGN KEY (`product_id`) REFERENCES `supplier_catalog_product` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;

--
-- Constraints for table `supplier_product_price_list`
--
ALTER TABLE `supplier_product_price_list`
  ADD CONSTRAINT `supplier_product_price_list_ibfk_2` FOREIGN KEY (`shop_id`) REFERENCES `franchisee_shop` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  ADD CONSTRAINT `supplier_product_price_list_ibfk_3` FOREIGN KEY (`supplier_id`) REFERENCES `material_supplier` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  ADD CONSTRAINT `supplier_product_price_list_ibfk_4` FOREIGN KEY (`product_id`) REFERENCES `supplier_catalog_product` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;

--
-- Constraints for table `todo_task_description_alias`
--
ALTER TABLE `todo_task_description_alias`
  ADD CONSTRAINT `fk_todo_task_description_alias` FOREIGN KEY (`id_todo_task`) REFERENCES `todo_task` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;

--
-- Constraints for table `todo_task_name_alias`
--
ALTER TABLE `todo_task_name_alias`
  ADD CONSTRAINT `fk_todo_task_name_alias` FOREIGN KEY (`id_todo_task`) REFERENCES `todo_task` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;

--
-- Constraints for table `todo_task_set_description_alias`
--
ALTER TABLE `todo_task_set_description_alias`
  ADD CONSTRAINT `fk_todo_task_set_description_alias` FOREIGN KEY (`id_todo_task_set`) REFERENCES `todo_task_set` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;

--
-- Constraints for table `todo_task_set_name_alias`
--
ALTER TABLE `todo_task_set_name_alias`
  ADD CONSTRAINT `fk_todo_task_set_name_alias` FOREIGN KEY (`id_todo_task_set`) REFERENCES `todo_task_set` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;

--
-- Constraints for table `todo_task_subtype_alias`
--
ALTER TABLE `todo_task_subtype_alias`
  ADD CONSTRAINT `fk_todo_task_subtype_alias` FOREIGN KEY (`id_todo_task_subtype`) REFERENCES `todo_task_subtype` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;

--
-- Constraints for table `todo_task_type_alias`
--
ALTER TABLE `todo_task_type_alias`
  ADD CONSTRAINT `fk_todo_task_type_alias` FOREIGN KEY (`id_todo_task_type`) REFERENCES `todo_task_type` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;

--
-- Constraints for table `training`
--
ALTER TABLE `training`
  ADD CONSTRAINT `training_ibfk_1` FOREIGN KEY (`subcategory_id`) REFERENCES `domain_functional_subcategory` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;

--
-- Constraints for table `training_admin_role_connection`
--
ALTER TABLE `training_admin_role_connection`
  ADD CONSTRAINT `training_admin_role_connection_ibfk_1` FOREIGN KEY (`training_id`) REFERENCES `training` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  ADD CONSTRAINT `training_admin_role_connection_ibfk_2` FOREIGN KEY (`admin_role_id`) REFERENCES `admin_panel_user_role` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;

--
-- Constraints for table `training_employee_role_connection`
--
ALTER TABLE `training_employee_role_connection`
  ADD CONSTRAINT `training_employee_role_connection_ibfk_1` FOREIGN KEY (`employee_role_id`) REFERENCES `franchisee_employee_role` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  ADD CONSTRAINT `training_employee_role_connection_ibfk_2` FOREIGN KEY (`training_id`) REFERENCES `training` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;

--
-- Constraints for table `user_membership`
--
ALTER TABLE `user_membership`
  ADD CONSTRAINT `user_membership_ibfk_1` FOREIGN KEY (`auth_user_id`) REFERENCES `auth_user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;

--
-- Constraints for table `user_profile`
--
ALTER TABLE `user_profile`
  ADD CONSTRAINT `user_profile_ibfk_1` FOREIGN KEY (`auth_user_id`) REFERENCES `auth_user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;

--
-- Constraints for table `withdrawing_money_reason_content_alias`
--
ALTER TABLE `withdrawing_money_reason_content_alias`
  ADD CONSTRAINT `fk_wmr_content_alias` FOREIGN KEY (`id_withdrawing_money_reason`) REFERENCES `withdrawing_money_reason` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;

--
-- Constraints for table `withdrawing_money_reason_description_alias`
--
ALTER TABLE `withdrawing_money_reason_description_alias`
  ADD CONSTRAINT `fk_wmr_description_alias` FOREIGN KEY (`id_withdrawing_money_reason`) REFERENCES `withdrawing_money_reason` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;
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 */;
