Skip to content

Commit 277b3d5

Browse files
Allows Table::dropColumn() & Table::dropIndex() to accept string input
Signed-off-by: Jon Stovell <jonstovell@gmail.com>
1 parent 69bdea7 commit 277b3d5

1 file changed

Lines changed: 8 additions & 6 deletions

File tree

Sources/Db/Schema/Table.php

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -361,14 +361,15 @@ public function alterColumn(Column $col, ?string $old_name = null): bool
361361
*
362362
* @see SMF\Db\DatabaseApi::remove_column
363363
*
364-
* @param Column $col The column to drop.
364+
* @param string|Column $col The column to drop. May be either an instance
365+
* of the Column class, or just the name of the column.
365366
* @return bool Whether or not the operation was successful.
366367
*/
367-
public function dropColumn(Column $col): bool
368+
public function dropColumn(string|Column $col): bool
368369
{
369370
return Db::$db->remove_column(
370371
'{db_prefix}' . $this->name,
371-
$col->name,
372+
$col instanceof Column ? $col->name : $col,
372373
);
373374
}
374375

@@ -408,14 +409,15 @@ public function addIndex(DbIndex $index, string $if_exists = 'update'): bool
408409
*
409410
* @see SMF\Db\DatabaseApi::remove_index
410411
*
411-
* @param DbIndex $index The index to drop.
412+
* @param string|DbIndex $index The index to drop. May be either an instance
413+
* of the DbIndex class, or just the name of the index.
412414
* @return bool Whether or not the operation was successful.
413415
*/
414-
public function dropIndex(DbIndex $index): bool
416+
public function dropIndex(string|DbIndex $index): bool
415417
{
416418
return Db::$db->remove_index(
417419
'{db_prefix}' . $this->name,
418-
$index->name,
420+
$col instanceof DbIndex ? $index->name : $index,
419421
);
420422
}
421423

0 commit comments

Comments
 (0)