title: how to make a varchar nullable and unique together in mysql (laravel)
body: <p>Can i make a MySQL column nullable and unique together. I have a table that store users Email_id if user wants to provide else it will be (null). I read in some other questions that i can make a unique field with default NULL. but i get this error when creating table </p>
  
  <pre><code>#1067 - Invalid default value for 'email' (i make it only for test purpose)
  </code></pre>
  
  <p>the main table is generated with larave schema builder class </p>
  
  <pre><code>$table-&gt;text('email')-&gt;nullable()-&gt;unique(); (no default added)
  </code></pre>
  
  <p>in DB</p>
  
  <pre><code>+--------------+------------------+------+-----+---------+----------------+
  | Field        | Type             | Null | Key | Default | Extra          |
  +--------------+------------------+------+-----+---------+----------------+ 
  | email_id     | varchar(200)     | YES  | UNI | NULL    |                |
  </code></pre>
  
  <p>now error is </p>
  
  <pre><code>Duplicate entry '' for key 'users_email_id_unique' (when inserting email with empty string) 
  </code></pre>
  
  <p>Now question is how to handle a varchar field which is unique and nullable together.</p>