EllisLab/CodeIgniter — Issue #714: migration bug with default null value?
Author: mikedfunk
Created: 2011-11-27 22:42:00+00:00
State: open

I am trying to implement migrations but it always chokes at the same point. Setting `'null' => TRUE` just produces the word `NULL` rather than `DEFAULT NULL`, which produces an SQL error. In more detail:

The [CI 2.1.0 documentation](http://codeigniter.com/user_guide/libraries/migration.html) says to set up fields like this:

```php
'blog_description' => array(
'type' => 'TEXT',
'null' => TRUE,
),
```

however when I do that and run a migration, I get a MySQL error:

```
A Database Error Occurred
Error Number: 1064

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'NULL,
```

So I looked this up, and everywhere it says that in MySQL for null defaults the proper syntax is `DEFAULT NULL`, including on [mysql.com](http://dev.mysql.com/doc/refman/5.0/en/data-type-defaults.html):

> If the column can take NULL as a value, the column is defined with an explicit DEFAULT NULL clause.

but the codeigniter produced SQL is this:

```
`first_name` VARCHAR NULL,
```

**Where's the keyword `DEFAULT`?**