Or clear a specific column.

  • one
    Migrations are not a means of manipulating data, migrations are a means of manipulating data structures. Surely technically feasible, but you should not do this in migrations. - etki
  • Well, let's say the application is not yet running, but there is some kind of test data in it, but I need to reduce the length of the string. Will such a migration take place if I have lines longer than the new value? - Jonny Manowar
  • @Etki does not agree, and if you need to update the data just due to a change in structure (for example, the column type has changed). Then it is better that everything be chased and rolled back together - apelsinka223
  • @ apelsinka223 How do you change the data type without changing the column type? - etki
  • @Etki for example, add a copy of the column, translate the data with the changes, delete the first column and the renamed copy. Or if you do not need to save the data, then just delete everything - apelsinka223

2 answers 2

This is done using the statement statement .

DB::statement('truncate table users');

    Make the usual sql query inside the migration
    TRUNCATE TABLE Table or UPDATE Table SET column = NULL