I find references to this in the old version 3 docs, but nothing in the current ones (might just be my poor searching). In the old docs, the way described to add a constraint was to do this:
$u = R::dispense('user');
$u->name = 'schema setting';
$u->email = 'schema setting';
$u->pwd = password_hash('schema setting', PASSWORD_DEFAULT);
$u->setMeta('buildcommand.unique', array('email'));
$id = R::store($u);
R::trash($u);
But if I look at the schema before and after I don't see UNIQUE on the email column:
sqlite3 $(git rev-parse --show-toplevel)/test.db '.schema user'
CREATE TABLE `user` ( id INTEGER PRIMARY KEY AUTOINCREMENT , `name` TEXT, `email` TEXT, `pwd` TEXT);
I also tried $u->setMeta('sys.buildcommand.unique', array('email')); but that didn't work either.
Note that this is with sqlite3 and that the table already existed, I'm just trying to add the constraint now.
Kevin