Framework: [Bug] SQLite add column migration problem

Created on 26 Jan 2013  路  2Comments  路  Source: laravel/framework

When I run add column migration on SQLite got error

[PDOException]
SQLSTATE[HY000]: General error: 1 Cannot add a NOT NULL column with default value NULL

But I run same migration on MySql was correct

Most helpful comment

Adding a column to an existing always have to be nullable, since their values will be null for existing rows. Specifying a default value may help.

SQLite is working correctly, MySQL is just not smart enough and simply allows it. I don't know which storage engine you were using in MySQL, I believe MyISAM does indeed allow it, but the stricter InnoDB might not, just like SQLite. I would recommend using InnoDB anyway, as it is capable of constraints checking to ensure integrity of your data.

All 2 comments

Adding a column to an existing always have to be nullable, since their values will be null for existing rows. Specifying a default value may help.

SQLite is working correctly, MySQL is just not smart enough and simply allows it. I don't know which storage engine you were using in MySQL, I believe MyISAM does indeed allow it, but the stricter InnoDB might not, just like SQLite. I would recommend using InnoDB anyway, as it is capable of constraints checking to ensure integrity of your data.

THAAAAAAAAAAANKS @JoostK

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Fuzzyma picture Fuzzyma  路  3Comments

ghost picture ghost  路  3Comments

RomainSauvaire picture RomainSauvaire  路  3Comments

Anahkiasen picture Anahkiasen  路  3Comments

YannPl picture YannPl  路  3Comments