File tree Expand file tree Collapse file tree 2 files changed +81
-0
lines changed
Expand file tree Collapse file tree 2 files changed +81
-0
lines changed Original file line number Diff line number Diff line change 1+ <?php
2+
3+ use Illuminate \Database \Migrations \Migration ;
4+ use Illuminate \Database \Schema \Blueprint ;
5+ use Illuminate \Support \Facades \Schema ;
6+
7+ class Posts extends Migration
8+ {
9+ /**
10+ * Run the migrations.
11+ *
12+ * @return void
13+ */
14+ public function up ()
15+ {
16+ Schema::create ('posts ' , function (Blueprint $ table ) {
17+ $ table ->id ();
18+ $ table ->unsignedBigInteger ('user_id ' );
19+ $ table ->foreign ('user_id ' )
20+ ->references ('id ' )->on ('users ' )
21+ ->onDelete ('cascade ' );
22+ $ table ->string ('title ' )->unique ();
23+ $ table ->text ('body ' );
24+ $ table ->text ('metaDescription ' );
25+ $ table ->string ('metaTitle ' );
26+ $ table ->string ('slug ' )->unique ();
27+ $ table ->boolean ('active ' );
28+ $ table ->timestamps ();
29+ });
30+ }
31+
32+ /**
33+ * Reverse the migrations.
34+ *
35+ * @return void
36+ */
37+ public function down ()
38+ {
39+ Schema::drop ('posts ' );
40+ }
41+ }
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ use Illuminate \Database \Migrations \Migration ;
4+ use Illuminate \Database \Schema \Blueprint ;
5+ use Illuminate \Support \Facades \Schema ;
6+
7+ class Comments extends Migration
8+ {
9+ /**
10+ * Run the migrations.
11+ *
12+ * @return void
13+ */
14+ public function up ()
15+ {
16+ Schema::create ('comments ' , function (Blueprint $ table ) {
17+ $ table ->id ();
18+ $ table ->unsignedBigInteger ('post_id ' );
19+ $ table ->unsignedBigInteger ('user_id ' );
20+ $ table ->foreign ('post_id ' )
21+ ->references ('id ' )->on ('posts ' )
22+ ->onDelete ('cascade ' );
23+ $ table ->foreign ('user_id ' )
24+ ->references ('id ' )->on ('users ' )
25+ ->onDelete ('cascade ' );
26+ $ table ->text ('comment ' );
27+ $ table ->timestamps ();
28+ });
29+ }
30+
31+ /**
32+ * Reverse the migrations.
33+ *
34+ * @return void
35+ */
36+ public function down ()
37+ {
38+ Schema::drop ('comments ' );
39+ }
40+ }
You can’t perform that action at this time.
0 commit comments