Skip to content

Commit

Permalink
Replace sql type TEXT by LONGTEXT for profile field when using mysql …
Browse files Browse the repository at this point in the history
…driver
  • Loading branch information
maxime masson committed Dec 21, 2022
1 parent 597eecc commit 1755c40
Showing 1 changed file with 41 additions and 19 deletions.
60 changes: 41 additions & 19 deletions src/Db/PdoRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 1755c40

Please sign in to comment.