“Hapus kendala kunci asing Laravel” Kode Jawaban

Larael Drop Key Asing

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

Nonaktifkan Laravel Kunci Asing

//...
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

Hapus kendala kunci asing 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

Laravel Migrasi menjatuhkan kunci asing

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

Laravel Migrasi menjatuhkan kunci asing

$table->dropPrimary('users_id_primary');
Open Octopus

Jatuhkan kunci Laravel Kunci Asing

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

Jawaban yang mirip dengan “Hapus kendala kunci asing Laravel”

Pertanyaan yang mirip dengan “Hapus kendala kunci asing Laravel”

Lebih banyak jawaban terkait untuk “Hapus kendala kunci asing Laravel” di PHP

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya