Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

unique value when two columns laravel migration

public function up()
{
    Schema::table('user_plans', function (Blueprint $table) {
        $table->unique(["email", "plan_id"], 'user_plan_unique');
    });
}

public function down()
{
    Schema::table('user_plans', function (Blueprint $table) {
      $table->dropUnique('user_plan_unique');
    });
}
 
PREVIOUS NEXT
Tagged: #unique #columns #laravel #migration
ADD COMMENT
Topic
Name
9+5 =