Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in SQL by (20.3k points)

I'm writing a migration to make certain columns in a table nullable right now. For the down function, I, of course, want to make those columns not nullable again. I looked through the schema builder docs, but couldn't see a way to do this.

Any help would be appreciated.

1 Answer

0 votes
by (40.7k points)

There was no Laravel native way of altering an existing table column using the schema builder prior to Laravel 5. You need to use raw queries.

However, if you are using Laravel 5 use the below code:

$table->...->nullable(false)->change();

Related questions

0 votes
2 answers
0 votes
1 answer
0 votes
1 answer
asked Dec 19, 2020 in SQL by Appu (6.1k points)
0 votes
3 answers
0 votes
2 answers

1.2k questions

2.7k answers

501 comments

693 users

Browse Categories

...