Skip to content

Instantly share code, notes, and snippets.

@anacampesan
Last active October 5, 2017 13:34
Show Gist options
  • Save anacampesan/47b3af3f1fa3de6c5cbfbeffd16da990 to your computer and use it in GitHub Desktop.
Save anacampesan/47b3af3f1fa3de6c5cbfbeffd16da990 to your computer and use it in GitHub Desktop.
Add unique - Migration
<?php
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class AddConstraintMyTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('myTable', function (Blueprint $table) {
$table->unique('link');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('myTable', function (Blueprint $table) {
$table->dropUnique('offers_link_unique');
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment