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
|
/.fleet
|
||||||
/.idea
|
/.idea
|
||||||
/.vscode
|
/.vscode
|
||||||
|
_ide_helper.php
|
||||||
|
|||||||
@@ -12,6 +12,7 @@
|
|||||||
"laravel/tinker": "^2.8"
|
"laravel/tinker": "^2.8"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
|
"barryvdh/laravel-ide-helper": "^3.1",
|
||||||
"fakerphp/faker": "^1.9.1",
|
"fakerphp/faker": "^1.9.1",
|
||||||
"laravel/pint": "^1.0",
|
"laravel/pint": "^1.0",
|
||||||
"laravel/sail": "^1.18",
|
"laravel/sail": "^1.18",
|
||||||
|
|||||||
Generated
+1963
-1154
File diff suppressed because it is too large
Load Diff
@@ -1,5 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use App\Models\User;
|
||||||
use Illuminate\Database\Migrations\Migration;
|
use Illuminate\Database\Migrations\Migration;
|
||||||
use Illuminate\Database\Schema\Blueprint;
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
use Illuminate\Support\Facades\Schema;
|
use Illuminate\Support\Facades\Schema;
|
||||||
@@ -15,8 +16,9 @@ class CreateTasksTable extends Migration
|
|||||||
{
|
{
|
||||||
Schema::create('tasks', function (Blueprint $table) {
|
Schema::create('tasks', function (Blueprint $table) {
|
||||||
$table->id();
|
$table->id();
|
||||||
$table->bigInteger('user_id');
|
/* $table->bigInteger('user_id');
|
||||||
$table->foreign('user_id')->references('id')->on('users');
|
$table->foreign('user_id')->references('id')->on('users'); */
|
||||||
|
$table->foreignIdFor(User::class)->constrained()->onUpdate('cascade')->onDelete('cascade');
|
||||||
$table->string('name');
|
$table->string('name');
|
||||||
$table->timestamps();
|
$table->timestamps();
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use App\Models\User;
|
||||||
use Illuminate\Database\Migrations\Migration;
|
use Illuminate\Database\Migrations\Migration;
|
||||||
use Illuminate\Database\Schema\Blueprint;
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
use Illuminate\Support\Facades\Schema;
|
use Illuminate\Support\Facades\Schema;
|
||||||
@@ -15,10 +16,8 @@ class CreateCommentsTable extends Migration
|
|||||||
{
|
{
|
||||||
Schema::create('comments', function (Blueprint $table) {
|
Schema::create('comments', function (Blueprint $table) {
|
||||||
$table->id();
|
$table->id();
|
||||||
$table->unsignedInteger('user_id');
|
/* $table->foreignId('user_id')->constrained()->onUpdate('cascade')->onDelete('cascade'); */
|
||||||
$table->foreign('user_id')->references('id')->on('users');
|
$table->foreignIdFor(User::class)->constrained()->onUpdate('cascade')->onDelete('cascade');
|
||||||
$table->unsignedInteger('comment_id');
|
|
||||||
$table->foreign('comment_id')->references('id')->on('comments');
|
|
||||||
$table->string('comment_text');
|
$table->string('comment_text');
|
||||||
$table->timestamps();
|
$table->timestamps();
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user