“Lassen Sie den Fremdschlüssel Laravel fallen” Code-Antworten

Larael Drop Foreign Key

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

Laravel Fremdschlüssel

Schema::table('posts', function (Blueprint $table) {
    $table->unsignedBigInteger('user_id');

    $table->foreign('user_id')->references('id')->on('users');
});
OR
Schema::table('posts', function (Blueprint $table) {
    $table->foreignId('user_id')->constrained();
});
Courageous Cod

Deaktivieren Sie den ausländischen Schlüssel 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();
    }
    //...
}
Better Booby

Entfernen Sie die Einschränkung des Fremdschlüssels 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');
});
Shadowtampa

Tischabfall Fremdes Php Laravel

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

     $table->dropColumn('user_id');
   });
 }
Wide-eyed Wolf

Lassen Sie den Fremdschlüssel Laravel fallen

Schema::table('admins', function (Blueprint $table) {    $table->dropForeign('admins_post_id_foreign');    $table->dropColumn('post_id');});
Arrogant Ant

Ähnliche Antworten wie “Lassen Sie den Fremdschlüssel Laravel fallen”

Fragen ähnlich wie “Lassen Sie den Fremdschlüssel Laravel fallen”

Weitere verwandte Antworten zu “Lassen Sie den Fremdschlüssel Laravel fallen” auf PHP

Durchsuchen Sie beliebte Code-Antworten nach Sprache

Durchsuchen Sie andere Codesprachen