Last active
October 5, 2017 13:34
-
-
Save anacampesan/47b3af3f1fa3de6c5cbfbeffd16da990 to your computer and use it in GitHub Desktop.
Add unique - Migration
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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