Search
 
SCRIPT & CODE EXAMPLE
 

PHP

laravel migration remove constraint

// There are two ways to handle this:

// 1.	You can simply pass the column name wrapped in an array
//		and let laravel sort out the rest:
Schema::table('users', function (Blueprint $table) {
  $table->dropUnique(['email']);
  // $table->dropIndex(['email']); --> this pattern also works for other constraints/indexes like this
});

// 2.	You can remember the way laravel formats index names ([TABLE_NAME]_[COLUMN_NAME]_unique),
// 		and pass that as a string:
Schema::table('users', function (Blueprint $table) {
	$table->dropUnique('users_email_unique');
});
Comment

remove foreign key constraint laravel

Schema::table('table_name', function (Blueprint $table) {
    $table->dropForeign(['foreign_key']);
    $table->dropColumn('column_key');
});

PS: usually foreign_key = column_key

ex: 

Schema::table('despatch_discrepancies', function (Blueprint $table) {
    $table->dropForeign(['pick_detail_id']);
    $table->dropColumn('pick_detail_id');
});
Comment

laravel remove foreign key

$table->dropForeign('posts_user_id_foreign');
Comment

laravel migration drop foreign keys

$table->dropIndex(['state']); // Drops index 'geo_state_index'
Comment

laravel migration drop foreign keys

$table->dropPrimary('users_id_primary');
Comment

PREVIOUS NEXT
Code Example
Php :: how to count no of words in a string in php without using string functions 
Php :: overwrite file php 
Php :: password hashing in laravel 
Php :: php change date format from d/m/y to y-m-d 
Php :: sha256 php 
Php :: laravel get url without domain in blade 
Php :: php sort array by key 
Php :: downgrade php version vagrant 
Php :: laravel create model with migration 
Php :: php code to display current date and time in different formats 
Php :: wordpress wp_enqueue_script footer 
Php :: laravel return data from model to another controller 
Php :: php generate random string 
Php :: php force download csv 
Php :: convert object to array in php 
Php :: Laravel seed timestamps columns 
Php :: create wordpress user programatically 
Php :: how to get the current year in php 
Php :: php trim string to length 
Php :: php cookie never expire 
Php :: try catch in laravel 
Php :: format time laravel 
Php :: Session store not set on request. 
Php :: laravel get db connection info 
Php :: wp get category by id 
Php :: eloquent model sort by ascending order 
Php :: a facade root has not been set phpunit 
Php :: PHP strtotime() Function 
Php :: wordpress truncate text 
Php :: php shutdown function 
ADD CONTENT
Topic
Content
Source link
Name
1+1 =