From 1755c40cb3f921837d161e3a4e2323714db7e4dc Mon Sep 17 00:00:00 2001 From: maxime masson Date: Wed, 21 Dec 2022 10:01:39 -0500 Subject: [PATCH] Replace sql type TEXT by LONGTEXT for profile field when using mysql driver --- src/Db/PdoRepository.php | 60 +++++++++++++++++++++++++++------------- 1 file changed, 41 insertions(+), 19 deletions(-) diff --git a/src/Db/PdoRepository.php b/src/Db/PdoRepository.php index 7e680c7c..710dc782 100644 --- a/src/Db/PdoRepository.php +++ b/src/Db/PdoRepository.php @@ -184,25 +184,47 @@ public function getStatistics() public function initSchema(): void { - $this->pdo->exec(sprintf(' - CREATE TABLE IF NOT EXISTS %s ( - "id" CHAR(24) PRIMARY KEY, - "profile" TEXT NOT NULL, - "url" TEXT NULL, - "SERVER" TEXT NULL, - "GET" TEXT NULL, - "ENV" TEXT NULL, - "simple_url" TEXT NULL, - "request_ts" INTEGER NOT NULL, - "request_ts_micro" NUMERIC(15, 4) NOT NULL, - "request_date" DATE NOT NULL, - "main_wt" INTEGER NOT NULL, - "main_ct" INTEGER NOT NULL, - "main_cpu" INTEGER NOT NULL, - "main_mu" INTEGER NOT NULL, - "main_pmu" INTEGER NOT NULL - ) - ', $this->table)); + if ($this->driverName == 'mysql') { + $this->pdo->exec(sprintf(' + CREATE TABLE IF NOT EXISTS %s ( + "id" CHAR(24) PRIMARY KEY, + "profile" LONGTEXT NOT NULL, + "url" TEXT NULL, + "SERVER" TEXT NULL, + "GET" TEXT NULL, + "ENV" TEXT NULL, + "simple_url" TEXT NULL, + "request_ts" INTEGER NOT NULL, + "request_ts_micro" NUMERIC(15, 4) NOT NULL, + "request_date" DATE NOT NULL, + "main_wt" INTEGER NOT NULL, + "main_ct" INTEGER NOT NULL, + "main_cpu" INTEGER NOT NULL, + "main_mu" INTEGER NOT NULL, + "main_pmu" INTEGER NOT NULL + ) + ', $this->table)); + } else { + $this->pdo->exec(sprintf(' + CREATE TABLE IF NOT EXISTS %s ( + "id" CHAR(24) PRIMARY KEY, + "profile" TEXT NOT NULL, + "url" TEXT NULL, + "SERVER" TEXT NULL, + "GET" TEXT NULL, + "ENV" TEXT NULL, + "simple_url" TEXT NULL, + "request_ts" INTEGER NOT NULL, + "request_ts_micro" NUMERIC(15, 4) NOT NULL, + "request_date" DATE NOT NULL, + "main_wt" INTEGER NOT NULL, + "main_ct" INTEGER NOT NULL, + "main_cpu" INTEGER NOT NULL, + "main_mu" INTEGER NOT NULL, + "main_pmu" INTEGER NOT NULL + ) + ', $this->table)); + } $this->pdo->exec(sprintf(' CREATE TABLE IF NOT EXISTS %s ( "id" CHAR(24) PRIMARY KEY,