Skip to content
Advertisement

Laravel Migration – Adding Check Constraints In Table

I want to create a table in Laravel Migration like this-

JavaScript

What I have done is-

JavaScript

But I can’t create this-

JavaScript

Can anyone please tell, how to implement this CHECK constraints in Laravel Migration ?

Advertisement

Answer

Adding constraints is not supported by the Blueprint class (at least as of Laravel 5.3), however it is possible to add constraints to your tables directly from your migrations, by using database statements.

In your migration file,

JavaScript
User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement