If your second migration for the users table looks like this:
Schema::create('users', function (Blueprint $table) {
$table->increments('id');
$table->string('name', 25);
// more migrations ...
});
it will try to create the users
table again. Note the second migration has Schema::
create. You are looking to do something more like alter the table:
Schema::table('users', function (Blueprint $table) {
$table->string('name', 50)->change();
});
If you are looking to completely overwrite (this will delete all data in the table) your prior migration with a new table you could do something as follows:
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateUsersTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::dropIfExists('users');
Schema::create('users', function (Blueprint $table) {
$table->increments('id');
$table->string('name', 50);
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('users');
}
}
However, if you are doing this you are most likely misunderstanding how migrations work. The purpose is to be able to alter columns in your database without having to completely destroy the table.
migrations
table in your DB. It should create that table and use it to track which migrations have already been run. - jfadich