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
Post a Comment