Merge pull request #63176 from nextcloud/carl/type-dbal2

feat(api): Add more methods from DBAL
pull/63182/head
Carl Schwan 1 week ago committed by GitHub
commit c44ef83708
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 5
      lib/private/DB/Schema/Index.php
  2. 19
      lib/private/DB/Schema/Table.php
  3. 9
      lib/public/DB/Schema/IIndex.php
  4. 25
      lib/public/DB/Schema/ITable.php

@ -60,6 +60,11 @@ class Index implements IIndex {
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

@ -83,6 +83,20 @@ class Table implements ITable {
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 @@ class Table implements ITable {
return $primaryKey !== null ? new Index($primaryKey) : null;
}
#[\Override]
public function hasPrimaryKey(): bool {
return $this->table->hasPrimaryKey();
}
#[\Override]
public function dropIndex(string $name): self {
try {

@ -62,4 +62,13 @@ interface IIndex {
* @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;
}

@ -62,6 +62,24 @@ interface ITable {
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 @@ interface ITable {
*/
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.
*

Loading…
Cancel
Save