EllisLab/CodeIgniter — Issue #861: dbforge add_field shouldn't accept constraints for INT with sqlsrv
Author: colonelchlorine
Created: 2012-01-03 18:51:51+00:00
State: open

Using sqlsrv (SQL Server 2008 database), when I tried the Migration library it fails to create the "migrations" table because of line 74:

```php
$this->dbforge->add_field(array(
'version' => array('type' => 'INT', 'constraint' => 3),
));
```
which generates the SQL equivalent

```sql
CREATE TABLE IF NOT EXISTS migrations (
version INT(3) NOT NULL
)
```
SQL gives error: **Cannot specify a column width on data type int**

Removing the second parameter and leaving "'type' => 'INT'" works. Not sure if this is a problem with CodeIgniter's sqlsrv driver, or the dbforge library.

Additionally refer to github issue #XXX because SQL also gives an error *Incorrect syntax near the keyword 'IF'.* Changing line 78 to the below line fixes this error.

```php
$this->dbforge->create_table('migrations', false);
```