php - issue with dropping foreign key -



php - issue with dropping foreign key -

my foreign key relates own table. produce posts hierarchy.

now when seek , drop column in database, gives me error:

1553 - cannot drop index 'post_field_properties_parent_id_index': needed in foreign key constraint

this code:

public function down() { schema::table( "post_field_properties", function( $table ) { $table->dropforeign('parent_id'); $table->dropcolumn('parent_id'); } ); }

the way seem able it, goto phpmyadmin , remove foreign key itself. , drop column.

just figured out own project. when dropping foreign key, need concatenate table name , columns in constraint suffix name "_foreign"

http://laravel.com/docs/5.1/migrations#foreign-key-constraints

public function down() { schema::table( "post_field_properties", function( $table ) { $table->dropforeign('post_field_properties_parent_id_foreign'); $table->dropcolumn('parent_id'); }); }

php mysql laravel artisan

Comments

Popular posts from this blog

formatting - SAS SQL Datepart function returning odd values -

c++ - Apple Mach-O Linker Error(Duplicate Symbols For Architecture armv7) -

php - Yii 2: Unable to find a class into the extension 'yii2-admin' -