1Schema::table('tableName', function($table)
2{
3 $table->string('column-name')->unique(); //notice the parenthesis I added
4});
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<?php
2
3use Illuminate\Database\Migrations\Migration;
4use Illuminate\Database\Schema\Blueprint;
5use Illuminate\Support\Facades\Schema;
6use Illuminate\Support\Facades\DB;
7
8class Products extends Migration
9{
10 /**
11 * Run the migrations.
12 *
13 * @return void
14 */
15 public function up()
16 {
17 Schema::create('products', function (Blueprint $table) {
18 $table->id();
19 $table->string('product_name')->index('product_name');
20 $table->string('product_sku')->index('product_sku');
21 });
22 }
23
24 /**
25 * Reverse the migrations.
26 *
27 * @return void
28 */
29 public function down()
30 {
31 Schema::dropIfExists('products');
32 }
33}