1Schema::table('posts', function (Blueprint $table) {
2 $table->dropForeign(['category_id']);
3});
1Schema::table('posts', function (Blueprint $table) {
2 $table->unsignedBigInteger('user_id');
3
4 $table->foreign('user_id')->references('id')->on('users');
5});
6OR
7Schema::table('posts', function (Blueprint $table) {
8 $table->foreignId('user_id')->constrained();
9});
1 Class RemoveCommentViewCount extends Migration
2 {
3 public function up()
4 {
5 Schema::table('articles', function($table) {
6 $table->dropColumn('comment_count');
7 $table->dropColumn('view_count');
8 });
9 }
10
11 public function down()
12 {
13 Schema::table('articles', function($table) {
14 $table->integer('comment_count');
15 $table->integer('view_count');
16 });
17 }
18 }