Friday, 16 June 2017

Laravel : Database Migration ( Key Constraint )

Database Migration

What are steps to be looked from cli command "php artisan migrate:refresh --seed" . First of as we this command will drop table migration from bottom to top . However in our case, we should declare a foreign key migration table exactly at bottom of the folder. This is to ensure we can drop child key and the relation of foreign key with another table before dropping parent keys.

DropForeign ( ) need to be call under Schema::table and with a blue print object

Schema::table('courses', function (Blueprint $table) {


Schema::table('courses', function (Blueprint $table) {        

Next, after removing the relation and the key constraint of foreign key. Now we can drop the column inside the class table .

   Schema::table('courses', function (Blueprint $table) {

References :

No comments:

Post a Comment