From a1197303516d47e35d209fe5f1bd476619d947d3 Mon Sep 17 00:00:00 2001 From: boo-code Date: Sun, 6 Sep 2026 02:13:01 +0200 Subject: [PATCH] Make the Doctrine mapping describe the tables the module actually installs The three entities declare column types and indexes that differ from sql/install/*.sql, so doctrine:schema:update emits statements that fail or destroy data on a shop where the module is installed: ALTER TABLE ps_psgdpr_consent CHANGE error_message error_message VARCHAR(255) NOT NULL; ALTER TABLE ps_psgdpr_consent_lang CHANGE message message VARCHAR(255) NOT NULL; ALTER TABLE ps_psgdpr_log CHANGE id_guest id_guest INT NOT NULL, CHANGE client_name client_name VARCHAR(255) NOT NULL; DROP INDEX id_customer ON ps_psgdpr_log; DROP INDEX idx_id_customer ON ps_psgdpr_log; error_message and message are TEXT in the install SQL, so narrowing them to VARCHAR(255) fails with 'Data too long for column' on any consent text longer than 255 characters. id_guest and client_name are nullable in the install SQL. The two psgdpr_log indexes are created by the install SQL but absent from the mapping, so the schema tool treats them as unknown and drops them. Align the mapping with the shipped tables. Doctrine's text type maps to LONGTEXT unless a length is given, so length=65535 is needed to land on TEXT. --- src/Entity/PsgdprConsent.php | 2 +- src/Entity/PsgdprConsentLang.php | 2 +- src/Entity/PsgdprLog.php | 9 ++++++--- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/Entity/PsgdprConsent.php b/src/Entity/PsgdprConsent.php index 14daa4ae..1709aff1 100644 --- a/src/Entity/PsgdprConsent.php +++ b/src/Entity/PsgdprConsent.php @@ -64,7 +64,7 @@ class PsgdprConsent /** * @var string * - * @ORM\Column(name="error_message", type="string", length=255, nullable=false) + * @ORM\Column(name="error_message", type="text", length=65535, nullable=true) */ private $errorMessage = ''; diff --git a/src/Entity/PsgdprConsentLang.php b/src/Entity/PsgdprConsentLang.php index 85d5177f..08baad59 100644 --- a/src/Entity/PsgdprConsentLang.php +++ b/src/Entity/PsgdprConsentLang.php @@ -48,7 +48,7 @@ class PsgdprConsentLang /** * @var string * - * @ORM\Column(name="message", type="string", length=255, nullable=false) + * @ORM\Column(name="message", type="text", length=65535, nullable=true) */ private $message; diff --git a/src/Entity/PsgdprLog.php b/src/Entity/PsgdprLog.php index ca5f14e2..fec5e830 100644 --- a/src/Entity/PsgdprLog.php +++ b/src/Entity/PsgdprLog.php @@ -27,7 +27,10 @@ use PrestaShop\Module\Psgdpr\Service\LoggerService; /** - * @ORM\Table() + * @ORM\Table(indexes={ + * @ORM\Index(name="id_customer", columns={"id_customer"}), + * @ORM\Index(name="idx_id_customer", columns={"id_customer", "id_guest", "client_name", "id_module", "date_add", "date_upd"}) + * }) * @ORM\Entity(repositoryClass="PrestaShop\Module\Psgdpr\Repository\LoggerRepository") * @ORM\HasLifecycleCallbacks() */ @@ -52,14 +55,14 @@ class PsgdprLog /** * @var int * - * @ORM\Column(name="id_guest", type="integer", length=10, nullable=false) + * @ORM\Column(name="id_guest", type="integer", length=10, nullable=true) */ private $guestId; /** * @var string * - * @ORM\Column(name="client_name", type="string", length=255, nullable=false) + * @ORM\Column(name="client_name", type="string", length=255, nullable=true) */ private $clientData;