mirror of
https://github.com/10h30/Test-Laravel-Migrations.git
synced 2026-06-05 15:07:54 +09:00
Complete Task 1
This commit is contained in:
@@ -18,3 +18,4 @@ yarn-error.log
|
||||
/.fleet
|
||||
/.idea
|
||||
/.vscode
|
||||
_ide_helper.php
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
"laravel/tinker": "^2.8"
|
||||
},
|
||||
"require-dev": {
|
||||
"barryvdh/laravel-ide-helper": "^3.1",
|
||||
"fakerphp/faker": "^1.9.1",
|
||||
"laravel/pint": "^1.0",
|
||||
"laravel/sail": "^1.18",
|
||||
|
||||
Generated
+1964
-1155
File diff suppressed because it is too large
Load Diff
@@ -1,5 +1,6 @@
|
||||
<?php
|
||||
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
@@ -15,8 +16,9 @@ class CreateTasksTable extends Migration
|
||||
{
|
||||
Schema::create('tasks', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->bigInteger('user_id');
|
||||
$table->foreign('user_id')->references('id')->on('users');
|
||||
/* $table->bigInteger('user_id');
|
||||
$table->foreign('user_id')->references('id')->on('users'); */
|
||||
$table->foreignIdFor(User::class)->constrained()->onUpdate('cascade')->onDelete('cascade');
|
||||
$table->string('name');
|
||||
$table->timestamps();
|
||||
});
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
<?php
|
||||
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
@@ -15,10 +16,8 @@ class CreateCommentsTable extends Migration
|
||||
{
|
||||
Schema::create('comments', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->unsignedInteger('user_id');
|
||||
$table->foreign('user_id')->references('id')->on('users');
|
||||
$table->unsignedInteger('comment_id');
|
||||
$table->foreign('comment_id')->references('id')->on('comments');
|
||||
/* $table->foreignId('user_id')->constrained()->onUpdate('cascade')->onDelete('cascade'); */
|
||||
$table->foreignIdFor(User::class)->constrained()->onUpdate('cascade')->onDelete('cascade');
|
||||
$table->string('comment_text');
|
||||
$table->timestamps();
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user