sql server - Laravel Eloquent how to create UNIQUE constraint with duplicate NULLs -


i'm usinq laravel 5 ms sql server 2014. want create unique constraint should allow multiple null values.

here code i'm using. 'passport_no' has unique if not null.

schema::create('userprofile', function(blueprint $table){     $table->increments('userprofile_id');     $table->integer('user_id')->unsigned();     $table->string('passport_no', 50)->unique()->nullable();      $table->foreign('user_id')->references('id')->on('users')             ->onupdate('cascade')->ondelete('cascade'); }); 

you can use unique index , in filter set condition

passport_no not null 

in way can solve problem


Comments

Popular posts from this blog

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -

ubuntu - Selenium Node Not Connecting to Hub, Not Opening Port -