Skip to content

Commit c44ef83

Browse files
authored
Merge pull request #63176 from nextcloud/carl/type-dbal2
feat(api): Add more methods from DBAL
2 parents 58b1f48 + 7c6a692 commit c44ef83

4 files changed

Lines changed: 58 additions & 0 deletions

File tree

lib/private/DB/Schema/Index.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,11 @@ public function hasColumnAtPosition(string $name, int $position = 0): bool {
6060
return $this->index->hasColumnAtPosition($name, $position);
6161
}
6262

63+
#[\Override]
64+
public function spansColumns(array $columnNames): bool {
65+
return $this->index->spansColumns($columnNames);
66+
}
67+
6368
/**
6469
* Forwards any method not declared on IIndex to the wrapped Doctrine
6570
* DBAL index, e.g. mutators like `addFlag()` or `removeFlag()` that are

lib/private/DB/Schema/Table.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,20 @@ public function addUniqueConstraint(
8383
return $this;
8484
}
8585

86+
#[\Override]
87+
public function hasUniqueConstraint(string $name): bool {
88+
return $this->table->hasUniqueConstraint($name);
89+
}
90+
91+
#[\Override]
92+
public function removeUniqueConstraint(string $name): void {
93+
try {
94+
$this->table->removeUniqueConstraint($name);
95+
} catch (DBALSchemaException $e) {
96+
throw new SchemaException($e->getMessage(), $e->getCode(), $e);
97+
}
98+
}
99+
86100
#[\Override]
87101
public function dropPrimaryKey(): self {
88102
try {
@@ -101,6 +115,11 @@ public function getPrimaryKey(): ?IIndex {
101115
return $primaryKey !== null ? new Index($primaryKey) : null;
102116
}
103117

118+
#[\Override]
119+
public function hasPrimaryKey(): bool {
120+
return $this->table->hasPrimaryKey();
121+
}
122+
104123
#[\Override]
105124
public function dropIndex(string $name): self {
106125
try {

lib/public/DB/Schema/IIndex.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,4 +62,13 @@ public function isSimpleIndex(): bool;
6262
* @since 35.0.0
6363
*/
6464
public function hasColumnAtPosition(string $name, int $position = 0): bool;
65+
66+
/**
67+
* Returns whether the given column names exactly match the columns this index spans,
68+
* regardless of order.
69+
*
70+
* @param list<non-empty-lowercase-string> $columnNames
71+
* @since 35.0.0
72+
*/
73+
public function spansColumns(array $columnNames): bool;
6574
}

lib/public/DB/Schema/ITable.php

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,24 @@ public function addUniqueConstraint(
6262
array $options = [],
6363
): self;
6464

65+
/**
66+
* Returns whether this table has a unique constraint with the given name.
67+
*
68+
* @param non-empty-string $name The unique constraint name.
69+
* @since 35.0.0
70+
*/
71+
public function hasUniqueConstraint(string $name): bool;
72+
73+
/**
74+
* Removes the unique constraint with the given name.
75+
*
76+
* @param non-empty-string $name The unique constraint name.
77+
*
78+
* @throws SchemaException If the unique constraint does not exist.
79+
* @since 35.0.0
80+
*/
81+
public function removeUniqueConstraint(string $name): void;
82+
6583
/**
6684
* Drops the primary key from this table.
6785
*
@@ -77,6 +95,13 @@ public function dropPrimaryKey(): self;
7795
*/
7896
public function getPrimaryKey(): ?IIndex;
7997

98+
/**
99+
* Returns whether this table has a primary key.
100+
*
101+
* @since 35.0.0
102+
*/
103+
public function hasPrimaryKey(): bool;
104+
80105
/**
81106
* Drops an index from this table.
82107
*

0 commit comments

Comments
 (0)