1public function up()
2{
3 Schema::table('table', function($table) {
4 $table->dropColumn('column_name');
5 });
6}
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});
1Schema::table('tableName', function($table)
2{
3 $table->string('column-name')->unique(); //notice the parenthesis I added
4});
1public function down()
2{
3 Schema::table('users', function (Blueprint $table) {
4 $table->dropSoftDeletes();
5 });
6}
1// To drop a column, use the dropColumn method on the schema builder.
2// Before dropping columns from a SQLite database, you will need to add
3// the doctrine/dbal dependency to your composer.json file and run the
4// composer update command in your terminal to install the library:
5
6Schema::table('users', function (Blueprint $table) {
7 $table->dropColumn('votes');
8});
1 Schema::table('articles', function($table) {
2 $table->dropColumn('comment_count');
3 $table->dropColumn('view_count');
4 });