Make column invalid in Laravel migration

I am writing a transition to create specific columns in a nullable table right now. For the down function, of course I want to make these columns not nullable . I looked at the schematic layout designer , but couldn't see a way to do this.

Any help would be appreciated.

+62
sql php laravel database-migration
Dec 23
source share
3 answers

Prior to Laravel 5, there was no native Laravel way to modify an existing table column using a schema builder. You will need to use raw requests.

However, with Laravel 5 you can use:

 $table->...->nullable(false)->change(); 
+92
Dec 24
source share

As in Laravel 5, you can undo this initially - just pass false as an argument to nullable ().

eg.

 $table -> string('foo') -> nullable(false) -> change(); 
+27
Jan 11 '16 at 18:18
source share

the information below is for SQL
First use the code below

 UPDATE [Table] SET [Column]=0 WHERE [Column] IS NULL 

how to run this code

 ALTER TABLE [Table] MODIFY [Column] INTEGER NOT NULL 
-3
Dec 23 '12 at 19:23
source share



All Articles