For every modification on existing (already migrated tables) you will have to make a new migration with modifications only. If you have "users" table migration 2014_10_12_000000_create_users_table
like:
Schema::create('users', function (Blueprint $table) {
$table->bigIncrements('id');
$table->string('name');
$table->string('email')->unique();
$table->string('password');
$table->rememberToken();
$table->timestamps();
});
and you need to split "name" column, will have to php artisan make:migration alter_table_users --table="users"
and add what you want to change:
Schema::table('users', function (Blueprint $table) {
$table->renameColumn('name', 'first_name'); // rename column
$table->string('last_name'); // add new column });
Reverse
public function down()
{
Schema::table('users', function (Blueprint $table) {
$table->renameColumn('first_name', 'name');
$table->dropColumn('last_name');
});
}
Nou you can use php artisan migrate
Documentation: https://laravel.com/docs/6.x/migrations#modifying-columns
php artisan migrate:refresh
– Baxiemigrate:refresh
will delete all table and then run migration again. – Artificephp artisan migrate:rollback
for last created migration file. – Artificephp artisan migrate:rollback
will not drop all the tables? – Artherrollback
andreset
aside, if you want to change a migration that has already been run, the rule of thumb is "don't". Create a new migration that changes the table (add/drop/change column, etc) and runphp artisan migrate
again. Migrations are meant to be a "moving forward" type of thing so you don't have to run rollbacks and risk dataloss. – Gratian