laravel migration add unique column
Schema::table('tableName', function($table)
{
$table->string('column-name')->unique(); //notice the parenthesis I added
});
laravel migration add unique column
Schema::table('tableName', function($table)
{
$table->string('column-name')->unique(); //notice the parenthesis I added
});
laravel drop column
// To drop a column, use the dropColumn method on the schema builder.
// Before dropping columns from a SQLite database, you will need to add
// the doctrine/dbal dependency to your composer.json file and run the
// composer update command in your terminal to install the library:
Schema::table('users', function (Blueprint $table) {
$table->dropColumn('votes');
});
laravel migration index
$table->index(['account_id', 'created_at']);
add index in Laravel migration
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
use Illuminate\Support\Facades\DB;
class Products extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('products', function (Blueprint $table) {
$table->id();
$table->string('product_name')->index('product_name');
$table->string('product_sku')->index('product_sku');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('products');
}
}
laravel migration
$table->string('name', 100);
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us