Search
 
SCRIPT & CODE EXAMPLE
 

PHP

disable foreign key laravel

//...
class ClearOldOauthRelations extends Migration
{
    public function up()
    {
        Schema::disableForeignKeyConstraints();
        // drop foreign keys
        Schema::table('oauth_access_tokens', function (BluePrint $table) {
            $table->dropForeign('oauth_access_tokens_session_id_foreign');
        });
        //...
        Schema::enableForeignKeyConstraints();
    }
    //...
}
Comment

larael drop foreign key

Schema::table('posts', function (Blueprint $table) {
	$table->dropForeign(['category_id']);
});
Comment

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

table drop foreign php laravel

 public function down()
 {
   Schema::table('tarefas', function (Blueprint $table) {
     $table->dropForeign('tarefas_user_id_foreign');

     $table->dropColumn('user_id');
   });
 }
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 drop foreign key

// Primary table name, from Schema::table(<table>)
// Primary column, from $table->foreign(<column>)
$table->dropForeign('<table>_<column>_foreign');
Comment

laravel drop foreign column

// Searched, laravel drop foreign column
Schema::table('users', function (Blueprint $table) {
    $table->dropColumn(['votes', 'avatar', 'location']);
});
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

delete all rows in table laravel foreign key

DB::statement("SET foreign_key_checks=0");
Model::truncate();
DB::statement("SET foreign_key_checks=1");
Comment

PREVIOUS NEXT
Code Example
Php :: $this- attribute laravel 
Php :: lumen file upload 
Php :: eloquent get only some columns 
Php :: wp php get_the_category posts loop 
Php :: php mac address 
Php :: php check if value exists in multidimensional array 
Php :: change key with the value php 
Php :: laravel validation exact string length 
Php :: hide error in php 
Php :: check variable type in php 
Php :: cloudflare ip country 
Php :: cakephp 2.x join 
Php :: how to run specific migration in laravel 
Php :: difference entre deux date php 
Php :: how to define function in php 
Php :: upload file in php 
Php :: php date + 30 days 
Php :: php append element to array 
Php :: php import script 
Php :: how to print in php 
Php :: do while php 
Php :: how to set cookie expire time in php 
Php :: remove seconds from time php 
Php :: create seeder in laravel 
Php :: php upload file 
Php :: how to get plugin directory path in wordpress 
Php :: drop all tables laravel 
Php :: php redirect seconds 
Php :: eloquent update row response 
Php :: php do while loop 
ADD CONTENT
Topic
Content
Source link
Name
9+9 =