diff --git a/src/Platforms/SQLitePlatform.php b/src/Platforms/SQLitePlatform.php index ccb7c46229..7d21a3c226 100644 --- a/src/Platforms/SQLitePlatform.php +++ b/src/Platforms/SQLitePlatform.php @@ -987,4 +987,9 @@ public function normalizeUnquotedIdentifier(string $identifier): string { return $identifier; } + + public function supportsPartialIndexes(): bool + { + return true; + } } diff --git a/src/Schema/SQLiteSchemaManager.php b/src/Schema/SQLiteSchemaManager.php index 5fa8bec468..0e7ede72a3 100644 --- a/src/Schema/SQLiteSchemaManager.php +++ b/src/Schema/SQLiteSchemaManager.php @@ -151,6 +151,16 @@ static function (array $a, array $b): int { $idx['primary'] = false; $idx['non_unique'] = ! $tableIndex['unique']; + if ($tableIndex['partial'] === 1) { + $idx['where'] = $this->connection->fetchOne( + <<<'SQL' + SELECT SUBSTR(sql, INSTR(sql, 'WHERE') + 6) + FROM sqlite_master WHERE type = 'index' AND name = (?) + SQL, + [$keyName], + ); + } + $indexArray = $this->connection->fetchAllAssociative('SELECT * FROM PRAGMA_INDEX_INFO (?)', [$keyName]); foreach ($indexArray as $indexColumnRow) {