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');
});

```
Try placing "\_foreign" on the end of the column name. For example:

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

```