“Laravel 8 Fremdschlüsselwanderung” Code-Antworten

Machen Sie einen Vorzeichenschlüssel in Migrationen mit Laravel 8

$table->unsignedBigInteger('user_id');
$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
Imran Developer

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

Laravel Migration Rollback

To rollback one step:

php artisan migrate:rollback

To rollback multiple steps:

php artisan migrate:rollback --step=[x]
  
To drop all tables and reload all migrations:

php artisan migrate:fresh
Angry Albatross

Erstellen Sie fremde Key Laravel -Migration

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

    $table->foreign('user_id')->references('id')->on('users');
});
Super Starling

Laravel 8 Fremdschlüsselwanderung

use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

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

    $table->foreign('user_id')->references('id')->on('users');
});
Combative Coyote

ausländische Key Laravel -Migration

$table->foreign('column_name')->references('id')->on('table_name')->onDelete('cascade');
Super Starling

Ähnliche Antworten wie “Laravel 8 Fremdschlüsselwanderung”

Fragen ähnlich wie “Laravel 8 Fremdschlüsselwanderung”

Weitere verwandte Antworten zu “Laravel 8 Fremdschlüsselwanderung” auf PHP

Durchsuchen Sie beliebte Code-Antworten nach Sprache

Durchsuchen Sie andere Codesprachen