martinbean's avatar

Issue with migrations

I seem to have an issue with the DatabaseMigrations trait, and a migration that adds a column to an existing table.

I run PHPUnit against an on-disk SQLite database. I have one migration that creates a table (channels), and then a subsequent migration that adds a couple of columns to this table (one called description). But it seems when I run phpunit, Laravel has issue with the down() method of the latter migration that removes the column. I get this exception message:

PDOException: SQLSTATE[HY000]: General error: 1 no such column: description

I’ve testing this with a brand new Laravel project and get the same behaviour.

Has any one else come across this? If so, how can I fix it?

0 likes
2 replies
tykus's avatar
tykus
Best Answer
Level 104

There is a note in the docs about this specifically for SQLite:

Note: Before dropping columns from a SQLite database, you will need to add the doctrine/dbal dependency to your composer.json file and run the composer update command in your terminal to install the library. Note: Dropping or modifying multiple columns within a single migration while using a SQLite database is not supported.

https://laravel.com/docs/master/migrations#dropping-columns

martinbean's avatar

@tykus_ikus I had the doctrine/dbal dependency installed, but looks like I’ve fallen foul of trying to drop more than one column in a single migration (I’m trying to drop two). Looks like I’ll need to split these migrations to add/remove the columns independently. Thanks!

1 like

Please or to participate in this conversation.