diff --git a/database/migrations/task1/2021_11_08_091231_create_tasks_table.php b/database/migrations/task1/2021_11_08_091231_create_tasks_table.php index 08bf628f..50068a62 100644 --- a/database/migrations/task1/2021_11_08_091231_create_tasks_table.php +++ b/database/migrations/task1/2021_11_08_091231_create_tasks_table.php @@ -11,17 +11,23 @@ class CreateTasksTable extends Migration * * @return void */ - public function up() + public function up() { - Schema::create('tasks', function (Blueprint $table) { - $table->id(); - $table->bigInteger('user_id'); - $table->foreign('user_id')->references('id')->on('users'); - $table->string('name'); - $table->timestamps(); - }); + if (!Schema::hasTable('tasks')) { + Schema::create('tasks', function (Blueprint $table) { + $table->id(); + $table->bigInteger('user_id'); + $table->string('name'); + $table->timestamps(); + });} + else { + Schema::create('tasks', function (Blueprint $table) { + $table->foreignId('user_id'); + }); + } } + /** * Reverse the migrations. *