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: 
Here’s how to do it:

1. Log in to your database and lookup the name of the foreign key relationship. If you use phpmyadmin, go to the table, click the “Structure” tab, click the link “Relation View”

**Important Note:**
to see “Relation View” make sure your tables “Storage Engine” is `InnoDB` if not review this [Q&A](https://stackoverflow.com/questions/11358849/laravel-innodb/56497957#56497957)

and wait a few seconds for it to load. Search for the field “Constraint name”. In my example this is: “contribution\_copyright\_id\_foreign”

2. Go to the Laravel migration script (or create one). The trick is to first drop the foreign key relationship and then drop the column.

public function down()

{

```
     Schema::table('contribution', function(Blueprint $table){

         $table->dropForeign('contribution_copyright_id_foreign');

         $table->dropColumn('copyright_id');

     });

```

If you want to remove a table where a foreign key is present, you also first have to drop the foreign key relationship.

copied from [here](http://developed.be/2015/01/29/laravel-migrations-drop-foreign-key-column/)

Hope it help someone
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');
        });
}

```