'SET NULL', 'short_urls' => 'CASCADE', ]; /** * @param Schema $schema * @throws SchemaException */ public function up(Schema $schema): void { $visits = $schema->getTable('visits'); $foreignKeys = $visits->getForeignKeys(); // Remove all existing foreign keys and add them again with CASCADE delete foreach ($foreignKeys as $foreignKey) { $visits->removeForeignKey($foreignKey->getName()); $foreignTable = $foreignKey->getForeignTableName(); $visits->addForeignKeyConstraint( $foreignTable, $foreignKey->getLocalColumns(), $foreignKey->getForeignColumns(), [ 'onDelete' => self::ON_DELETE_MAP[$foreignTable], 'onUpdate' => 'RESTRICT', ] ); } } public function down(Schema $schema): void { // Nothing to run } }