Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Wakanda's avatar
Level 10

Modifying Enum Column

Hi Devs.

I am trying to modify an enum column and am getting the following error.

``

Migrating: 2020_10_18_175812_change_status_to_orders_table

Illuminate\Database\QueryException

SQLSTATE[HY000]: General error: 1 near "MODIFY": syntax error (SQL: ALTER TABLE orders MODIFY COLUMN status ENUM('pending', 'processing', 'shipped', 'delivered', 'decline', 'cancel',) NOT NULL DEFAULT 'pending')

at E:\Projects\Zimcart-Premium\vendor\laravel\framework\src\Illuminate\Database\Connection.php:671 667| // If an exception occurs when attempting to run a query, we'll format the error 668| // message to include the bindings with SQL, which will make this exception a 669| // lot more helpful to the developer instead of just the database's errors. 670| catch (Exception $e) {

671| throw new QueryException( 672| $query, $this->prepareBindings($bindings), $e 673| ); 674| } 675|

1 E:\Projects\Zimcart-Premium\vendor\doctrine\dbal\lib\Doctrine\DBAL\Driver\PDO\Exception.php:18 Doctrine\DBAL\Driver\PDO\Exception::("SQLSTATE[HY000]: General error: 1 near "MODIFY": syntax error")

2 E:\Projects\Zimcart-Premium\vendor\doctrine\dbal\lib\Doctrine\DBAL\Driver\PDOConnection.php:82 Doctrine\DBAL\Driver\PDO\Exception::new(Object(PDOException))

``

MY CODE

DB::statement("ALTER TABLE orders MODIFY COLUMN status ENUM('pending', 'processing', 'shipped', 'delivered', 'decline', 'cancel') NOT NULL DEFAULT 'pending'");
0 likes
7 replies
rodrigo.pedra's avatar
Level 56

Your error message have a trailing comma after the 'cancel' column.

Also I tried in PHPStorm to see which SQL statement it generates and there are some differences:

DB::statement("ALTER TABLE orders MODIFY status ENUM('pending', 'processing', 'shipped', 'delivered', 'decline', 'cancel') NOT NULL DEFAULT 'pending'");

Differences are

  • MODIFY COLUMN is just MODIFY
  • NOT NULL comes before DEFAULT

Not sure if these differences are needed, but at least you can try.

For reference, I tried this against a MySQL 8 installation

1 like
Wakanda's avatar
Level 10

@rodrigo.pedra thanks for the insight, it was a DB issue it's working now on MySQL and in testing, with SQLite, it's now working. any idea how to fix that.

rodrigo.pedra's avatar

it was a DB issue it's working now on MySQL and in testing, with SQLite, it's now working.

I don't understand, you say it is working on both DB's, what is left to be fixed?

rodrigo.pedra's avatar

Yes, as @sinnbeck pointed out SQLite does not support Enums.

If you are using specific DBMS features you should use the same DBMS engine on your code and tests.

Not the same credentials, but the same database engine.

1 like

Please or to participate in this conversation.