Erstellen Sie Einzigartige Feld in Codeigniter DBForge Migration

Wie kann ich machen das financial_year Feld als unique mit Codeigniter Dbforge migration?

function up() {

    $this->dbforge->add_field(array(
        'id'    =>  array(
            'type'              =>  'INT',
            'constraint'        =>  11,
            'unsigned'          =>  TRUE,
            'auto_increment'    =>  TRUE
        ),
        'financial_year'    =>  array(
            'type'              =>  'VARCHAR',
            'constraint'        =>  20
        ),
        'start_date'    =>  array(
            'type'              =>  'DATE'
        ),
        'end_date'  =>  array(
            'type'              =>  'DATE'
        ),
        'status'    =>  array(
            'type'              =>  "ENUM",
            'constraint'        =>  "'Active','Inactive'",
            'default'           =>  "Active"
        ),
        'created_on'    =>  array(
            'type'              =>  'TIMESTAMP'
        )
    ));

    $this->dbforge->add_key('id', TRUE); //add `id` as primary key

    $this->dbforge->create_table('financial_year'); //create table schema
}

InformationsquelleAutor devo | 2014-01-12

Schreibe einen Kommentar