CodeIgniter Forums
dbforge add field "unique" to disallow duplicate inserts. - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: dbforge add field "unique" to disallow duplicate inserts. (/showthread.php?tid=56940)



dbforge add field "unique" to disallow duplicate inserts. - El Forum - 02-01-2013

[eluser]Unknown[/eluser]
Using mysql it's pretty easy to specify a column as UNIQUE e.g. UNIQUE (column).

How can I do it with dbforge and not fallback to using raw db commands? Am using migration to setup the schema.

Code:
//EMAIL
           "email" => array(
                'type' => 'VARCHAR',
                'constraint' => 45,
                'null' => false
            ),

thanks,
James Tan


dbforge add field "unique" to disallow duplicate inserts. - El Forum - 02-01-2013

[eluser]Harold Villacorte[/eluser]
It looks like the latest version on Github processes a unique index. I have not tested it out. If you decide to try it out I would be interested in knowing how it worked for you.