title: Create Unique field in Codeigniter DBForge Migration
body: <p>How can I make the <code>financial_year</code> field as unique using <code>Codeigniter Dbforge</code> migration?</p>
  
  <pre><code>function up() {
  
      $this-&gt;dbforge-&gt;add_field(array(
          'id'    =&gt;  array(
              'type'              =&gt;  'INT',
              'constraint'        =&gt;  11,
              'unsigned'          =&gt;  TRUE,
              'auto_increment'    =&gt;  TRUE
          ),
          'financial_year'    =&gt;  array(
              'type'              =&gt;  'VARCHAR',
              'constraint'        =&gt;  20
          ),
          'start_date'    =&gt;  array(
              'type'              =&gt;  'DATE'
          ),
          'end_date'  =&gt;  array(
              'type'              =&gt;  'DATE'
          ),
          'status'    =&gt;  array(
              'type'              =&gt;  "ENUM",
              'constraint'        =&gt;  "'Active','Inactive'",
              'default'           =&gt;  "Active"
          ),
          'created_on'    =&gt;  array(
              'type'              =&gt;  'TIMESTAMP'
          )
      ));
  
      $this-&gt;dbforge-&gt;add_key('id', TRUE); // add `id` as primary key
  
      $this-&gt;dbforge-&gt;create_table('financial_year'); // create table schema
  }
  </code></pre>