diff --git a/lib/private/DB/Schema/Index.php b/lib/private/DB/Schema/Index.php index 82c9538b6681c..c75eec21df4ef 100644 --- a/lib/private/DB/Schema/Index.php +++ b/lib/private/DB/Schema/Index.php @@ -60,6 +60,11 @@ public function hasColumnAtPosition(string $name, int $position = 0): bool { return $this->index->hasColumnAtPosition($name, $position); } + #[\Override] + public function spansColumns(array $columnNames): bool { + return $this->index->spansColumns($columnNames); + } + /** * Forwards any method not declared on IIndex to the wrapped Doctrine * DBAL index, e.g. mutators like `addFlag()` or `removeFlag()` that are diff --git a/lib/private/DB/Schema/Table.php b/lib/private/DB/Schema/Table.php index d8b99cfa5ce65..dc07a71f0bdf4 100644 --- a/lib/private/DB/Schema/Table.php +++ b/lib/private/DB/Schema/Table.php @@ -83,6 +83,20 @@ public function addUniqueConstraint( return $this; } + #[\Override] + public function hasUniqueConstraint(string $name): bool { + return $this->table->hasUniqueConstraint($name); + } + + #[\Override] + public function removeUniqueConstraint(string $name): void { + try { + $this->table->removeUniqueConstraint($name); + } catch (DBALSchemaException $e) { + throw new SchemaException($e->getMessage(), $e->getCode(), $e); + } + } + #[\Override] public function dropPrimaryKey(): self { try { @@ -101,6 +115,11 @@ public function getPrimaryKey(): ?IIndex { return $primaryKey !== null ? new Index($primaryKey) : null; } + #[\Override] + public function hasPrimaryKey(): bool { + return $this->table->hasPrimaryKey(); + } + #[\Override] public function dropIndex(string $name): self { try { diff --git a/lib/public/DB/Schema/IIndex.php b/lib/public/DB/Schema/IIndex.php index af2ca8309ef28..a850116458a01 100644 --- a/lib/public/DB/Schema/IIndex.php +++ b/lib/public/DB/Schema/IIndex.php @@ -62,4 +62,13 @@ public function isSimpleIndex(): bool; * @since 35.0.0 */ public function hasColumnAtPosition(string $name, int $position = 0): bool; + + /** + * Returns whether the given column names exactly match the columns this index spans, + * regardless of order. + * + * @param list $columnNames + * @since 35.0.0 + */ + public function spansColumns(array $columnNames): bool; } diff --git a/lib/public/DB/Schema/ITable.php b/lib/public/DB/Schema/ITable.php index 35311b0269062..4745d65fd49fa 100644 --- a/lib/public/DB/Schema/ITable.php +++ b/lib/public/DB/Schema/ITable.php @@ -62,6 +62,24 @@ public function addUniqueConstraint( array $options = [], ): self; + /** + * Returns whether this table has a unique constraint with the given name. + * + * @param non-empty-string $name The unique constraint name. + * @since 35.0.0 + */ + public function hasUniqueConstraint(string $name): bool; + + /** + * Removes the unique constraint with the given name. + * + * @param non-empty-string $name The unique constraint name. + * + * @throws SchemaException If the unique constraint does not exist. + * @since 35.0.0 + */ + public function removeUniqueConstraint(string $name): void; + /** * Drops the primary key from this table. * @@ -77,6 +95,13 @@ public function dropPrimaryKey(): self; */ public function getPrimaryKey(): ?IIndex; + /** + * Returns whether this table has a primary key. + * + * @since 35.0.0 + */ + public function hasPrimaryKey(): bool; + /** * Drops an index from this table. *