Question: My foreign key relates to its **own table**. This was to produce **posts with hierarchy**.

Now when I try and drop the column in the database, it gives me this error:

```
1553 - Cannot drop index 'post_field_properties_parent_id_index': needed in a foreign key constraint

```

This is the code:

```
public function down()
{
        Schema::table( "post_field_properties", function( $table )
        {
            $table->dropForeign('parent_id');
            $table->dropColumn('parent_id');
        } );
}

```

The only way I seem to be able to do it, is to goto phpmyadmin and remove the foreign key itself. and then drop the column.

Answer: 
I'm using Laravel 8, and turns out there's `dropConstrainedForeignId` that we can use for this. So instead of this one provided in another answer:

```php
Schema::table( "post_field_properties", function( $table )
{
    $table->dropForeign('post_field_properties_parent_id_foreign');
    $table->dropColumn('parent_id');
});

```

You can write:

```php
Schema::table( "post_field_properties", function( $table )
{
    $table->dropConstrainedForeignId('parent_id');
});

```
You may pass an array of foreign keys inside the `dropForeign()` function, so Laravel will automatically concatenate the table name at the begining of the key name and 'foreign' at the end of it.

So please, try something like this code bellow in your down() function.

```
 Schema::table('contribution', function(Blueprint $table){
     $table->dropForeign(['copyright_id']);
     $table->dropColumn('copyright_id');
 });

```