fuel/oil — Issue #63: Feature Request: New Magic Migration "set_unique"
Author: knudpotente
Created: 2011-11-06 22:33:11+00:00
State: open

FuelPHP already has excellent tools that help us implement data validation and integrity checks in at the Controller level - as it should be! Nevertheless, many programmers **have** to specify data integrity constraints *also* at database level. In my case, for instance, this is a work requirement that I cannot get around.

It would be wonderful if a new 'magic migration' could be added to oil's already fantastic set, that would enable me to simply call:

```
oil g migration set_unique_email_in_users
```

The format for the call, obviously, is: set_unique_*{fieldname}*_in_*{tablename}*. It seems to me that using the word 'set' is clearer than using, let's say, the word 'add', which makes it more ambiguous (makes it seem as if we're adding a field, rather than modifying an existing one).

This call would create a migration file with the following template:

```php
execute();
}

public function down()
{
//Removing UNIQUE constraint from '{fieldname}' column
\DB::query("ALTER TABLE `{tablename}` DROP INDEX `uk_{fieldname}`")->execute();
}
}
```
Thank you for your consideration, and for all your great work with oil.