Problems to modify table attribute in migrations, laravel 5.5
How are you.
I know that to alter changes in existing migrations, this command can be applied.
php artisan make: migration users
But in my case, I have a table users with a field called mail, which has an attribute like UNIQUE (), how can I change this attribute, without altering the information I have in the tables?
Execute the command php artisan make:migration alter_email_on_users_table --table=users
Then a migration will be loaded with your table already set up.
Inside the table() function you may alter columns using the ->change() method at the end of your call.
Basically what you need is to specify all the characteristics of your columns as if it were a new one but just call change() at the end of the chain. Like this: $table->string('mail')->after('other_example_column')->nullable()->change()
But be careful - if the new data type does not match the old one, you might loose data. In addition, there is a module that needed to be included to laravel in order to modify columns, but it was a long time ago when I last had to enable that functionality so I forgot the details... but there was something exceptional!
Suppose I make the change in the migration, but I do not understand how to execute that migration, without deleting the data that I already have in the users table