Skip to content

Commit f242784

Browse files
create index if not exist to prevent duplicate error (#180)
Signed-off-by: Sergio Acevedo <SergioAcevedo05@Protonmail.com> Co-authored-by: Lukas Kämmerling <lukas.kaemmerling@hetzner-cloud.de>
1 parent 5fed794 commit f242784

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/Prometheus/Storage/PDO.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -641,7 +641,7 @@ protected function createTables(): void
641641
`time` {$timestamp_type} NOT NULL
642642
);
643643
SQL;
644-
$sqlIndex = "CREATE INDEX `name` ON `{$this->prefix}_summaries`(`name`);";
644+
$sqlIndex = "CREATE INDEX IF NOT EXISTS `name` ON `{$this->prefix}_summaries`(`name`);";
645645
break;
646646

647647
case 'mysql':
@@ -667,7 +667,7 @@ protected function createTables(): void
667667
"time" {$timestamp_type} NOT NULL
668668
);
669669
SQL;
670-
$sqlIndex = "CREATE INDEX \"name\" ON \"{$this->prefix}_summaries\" (\"name\");";
670+
$sqlIndex = "CREATE INDEX IF NOT EXISTS \"name\" ON \"{$this->prefix}_summaries\" (\"name\");";
671671
break;
672672
}
673673

0 commit comments

Comments
 (0)