From d18377e2f3d5506775e78d9b5557162f710c65b5 Mon Sep 17 00:00:00 2001 From: Marvin Borner Date: Sun, 26 Aug 2018 16:49:47 +0200 Subject: Added foreign keys --- .../2018_08_22_102141_create_posts_table.php | 41 ++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 database/migrations/2018_08_22_102141_create_posts_table.php (limited to 'database/migrations/2018_08_22_102141_create_posts_table.php') diff --git a/database/migrations/2018_08_22_102141_create_posts_table.php b/database/migrations/2018_08_22_102141_create_posts_table.php new file mode 100644 index 0000000..6154ca8 --- /dev/null +++ b/database/migrations/2018_08_22_102141_create_posts_table.php @@ -0,0 +1,41 @@ +increments('id'); + $table->integer('post_types_id')->unsigned(); + $table->integer('user_id')->unsigned(); + $table->timestamps(); + + $table->foreign('user_id') + ->references('id') + ->on('users'); + + $table->foreign('post_types_id') + ->references('id') + ->on('post_types'); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::drop('posts'); + } +} -- cgit v1.2.3