Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions lib/private/DB/Schema/Index.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
19 changes: 19 additions & 0 deletions lib/private/DB/Schema/Table.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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 {
Expand Down
9 changes: 9 additions & 0 deletions lib/public/DB/Schema/IIndex.php
Original file line number Diff line number Diff line change
Expand Up @@ -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<non-empty-lowercase-string> $columnNames
* @since 35.0.0
*/
public function spansColumns(array $columnNames): bool;
}
25 changes: 25 additions & 0 deletions lib/public/DB/Schema/ITable.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand All @@ -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.
*
Expand Down
Loading