diff options
Diffstat (limited to 'Year_3/TSDWL/LARAVEL/iBook/database/migrations/2022_01_23_083714_add_author_of_a_book.php')
-rw-r--r-- | Year_3/TSDWL/LARAVEL/iBook/database/migrations/2022_01_23_083714_add_author_of_a_book.php | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/Year_3/TSDWL/LARAVEL/iBook/database/migrations/2022_01_23_083714_add_author_of_a_book.php b/Year_3/TSDWL/LARAVEL/iBook/database/migrations/2022_01_23_083714_add_author_of_a_book.php new file mode 100644 index 0000000..befd862 --- /dev/null +++ b/Year_3/TSDWL/LARAVEL/iBook/database/migrations/2022_01_23_083714_add_author_of_a_book.php @@ -0,0 +1,33 @@ +<?php + +use Illuminate\Database\Migrations\Migration; +use Illuminate\Database\Schema\Blueprint; +use Illuminate\Support\Facades\Schema; + +class AddAuthorOfABook extends Migration +{ + /** + * Run the migrations. + * + * @return void + */ + public function up() + { + Schema::table( + 'books', function (Blueprint $table) { + $table->bigInteger('author_id')->unsigned()->nullable(); + $table->foreign('author_id')->references('id')->on('authors')->onUpdate('cascade')->onDelete('set null'); + } + ); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + // + } +} |