Replies: 2 comments 1 reply
-
As you mentioned PostgreSQL, you may use the following: DB::statement("CREATE TYPE orders_status_enum_type AS ENUM ('sent', 'failed')");
Schema::create('orders', function (Blueprint $table) {
// ...
$table->rawColumn('status', 'orders_status_enum_type');
// ...
}); |
Beta Was this translation helpful? Give feedback.
0 replies
-
I just added an enum field for MySQL and it used the native type just fine. Are you trying it on an engine that doesn't support Enum? |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
When using
->enum()
to create a database enum column with postgres driver, laravel creates a varchar columns with constraints.Native Enum types can be helpful for type safety when querying, example:
Concider this enum:
Concider this query:
My questions are:
Beta Was this translation helpful? Give feedback.
All reactions