Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
92 changes: 92 additions & 0 deletions upgrade/sql/9.1.0.sql
Original file line number Diff line number Diff line change
Expand Up @@ -128,3 +128,95 @@ INSERT INTO `PREFIX_hook` (`id_hook`, `name`, `title`, `description`, `position`
(NULL, 'actionOverrideShippingFreePrice', 'Override price that determines free shipping', 'Allows modules to override the free shipping price and return their custom value, for example to specify it by zone or other criteria.', '1'),
(NULL, 'actionOverrideShippingFreeWeight', 'Override weight that determines free shipping', 'Allows modules to override the free shipping weight and return their custom value, for example to specify it by zone or other criteria.', '1')
ON DUPLICATE KEY UPDATE `title` = VALUES(`title`), `description` = VALUES(`description`);

/* Insert B2B foundation */
/* https://github.com/PrestaShop/PrestaShop/pull/40632 */
CREATE TABLE `PREFIX_business_entity`
(
`id_business_entity` INT UNSIGNED AUTO_INCREMENT NOT NULL,
`enterprise_id` VARCHAR(255) NOT NULL,
`external_ref` VARCHAR(255) DEFAULT NULL,
`name` VARCHAR(255) NOT NULL,
`legal_name` VARCHAR(255) DEFAULT NULL,
`flag_delivery_authorized` TINYINT(1) NOT NULL DEFAULT 0,
`status` ENUM ('pending','active','inactive','rejected') NOT NULL DEFAULT 'pending',
`created_at` DATETIME NOT NULL,
`updated_at` DATETIME NOT NULL,
INDEX `business_entity_enterprise_id_idx` (`enterprise_id`),
INDEX `business_entity_external_ref_idx` (`external_ref`),
PRIMARY KEY (`id_business_entity`)
) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `PREFIX_customer_b2b`
(
`id_customer_b2b` INT UNSIGNED AUTO_INCREMENT NOT NULL,
`id_customer` INT UNSIGNED NOT NULL,
`status` ENUM ('pending','active','refused') NOT NULL DEFAULT 'pending',
`external_ref` VARCHAR(255) DEFAULT NULL,
`created_at` DATETIME NOT NULL,
`updated_at` DATETIME NOT NULL,
UNIQUE INDEX `uniq_customer_b2b_customer` (`id_customer`),
PRIMARY KEY (`id_customer_b2b`)
) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `PREFIX_business_entity_customer_b2b`
(
`id_business_entity_customer_b2b` INT UNSIGNED AUTO_INCREMENT NOT NULL,
`id_business_entity` INT UNSIGNED NOT NULL,
`id_customer_b2b` INT UNSIGNED NOT NULL,
`id_role_b2b` INT UNSIGNED NOT NULL,
`is_default` TINYINT(1) NOT NULL DEFAULT 0,
`created_at` DATETIME NOT NULL,
UNIQUE INDEX `uniq_be_customer` (`id_business_entity`, `id_customer_b2b`),
INDEX `business_entity_customer_b2b_be_idx` (`id_business_entity`),
INDEX `business_entity_customer_b2b_customer_idx` (`id_customer_b2b`),
INDEX `business_entity_customer_b2b_role_idx` (`id_role_b2b`),
PRIMARY KEY (`id_business_entity_customer_b2b`)
) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `PREFIX_business_entity_identifier`
(
`id_identifier` INT UNSIGNED AUTO_INCREMENT NOT NULL,
`id_business_entity` INT UNSIGNED NOT NULL,
`id_business_identifier` INT UNSIGNED NOT NULL,
`value` VARCHAR(255) NOT NULL,
UNIQUE INDEX `uniq_business_entity_identifier` (`id_business_entity`, `id_business_identifier`),
INDEX `business_entity_identifier_id_business_entity_idx` (`id_business_entity`),
INDEX `business_entity_identifier_id_business_identifier_idx` (`id_business_identifier`),
INDEX `business_entity_identifier_value_idx` (`value`),
PRIMARY KEY (`id_identifier`)
) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `PREFIX_business_identifier`
(
`id_business_identifier` INT UNSIGNED AUTO_INCREMENT NOT NULL,
`unremovable` TINYINT(1) NOT NULL DEFAULT 0,
`deleted` TINYINT(1) NOT NULL DEFAULT 0,
PRIMARY KEY (`id_business_identifier`)
) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `PREFIX_business_entity_address`
(
`id_business_entity` INT UNSIGNED NOT NULL,
`id_address` INT UNSIGNED NOT NULL,
`address_type` ENUM ('both','invoice','delivery') NOT NULL DEFAULT 'both',
PRIMARY KEY (`id_business_entity`, `id_address`),
INDEX `business_entity_address_address_idx` (`id_address`)
) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `PREFIX_b2b_role`
(
`id_role` INT UNSIGNED AUTO_INCREMENT NOT NULL,
`role` VARCHAR(64) NOT NULL,
UNIQUE INDEX `uniq_b2b_role` (`role`),
PRIMARY KEY (`id_role`)
) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `PREFIX_b2b_role_authorization_role`
(
`id_role` INT UNSIGNED NOT NULL,
`id_authorization_role` INT UNSIGNED NOT NULL,
PRIMARY KEY (`id_role`, `id_authorization_role`),
INDEX `b2b_role_authorization_role_role_idx` (`id_role`),
INDEX `b2b_role_authorization_role_auth_role_idx` (`id_authorization_role`)
) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;