Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
removeForeignKey example
private
function
cleanup
(
Schema
$schema
)
: void
{
foreach
(
$schema
->
getTables
(
)
as
$table
)
{
if
(
$table
->
getComment
(
)
=== self::COMMENT
)
{
$schema
->
dropTable
(
$table
->
getName
(
)
)
;
continue
;
}
foreach
(
$table
->
getForeignKeys
(
)
as
$foreignKey
)
{
if
(
\
str_starts_with
(
$foreignKey
->
getName
(
)
, 'fk_ce_'
)
)
{
$table
->
removeForeignKey
(
$foreignKey
->
getName
(
)
)
;
}
}
foreach
(
$table
->
getColumns
(
)
as
$column
)
{
if
(
$column
->
getComment
(
)
=== self::COMMENT
)
{
$table
->
dropColumn
(
$column
->
getName
(
)
)
;
}
}
}
}
}