Trying to migrate a users table. Already have 1 table at DB. It's Contacts
for contact form. Trying to migrate a users
table. Created my table with terminal $ php artisan make:migration create_users_table
Had the following code in it.
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('users', function (Blueprint $table) {
$table->id();
$table->string('name');
$table->string('email')->unique();
$table->string('username')->unique();
$table->timestamp('email_verified_at')();
$table->string('password');
$table->rememberToken();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('users');
}
};
When I tried to migrate the table terminal returns an error.
I run php artisan migrate
and it returns
Migrating: create_contacts_table
"I'm trying to migrate users
table and because of the contacts table already exist it says
table already exists : 1050 ...
"
Tried to give an argument as it said on the website but didn't work either.
I tried this
$ php artisan migrate [--path[C:\xampp\htdocs\custom\database\migrations\2022_05_03_121341_create_users_table.php]]
but it returned No arguments expected for 'migrate' command
How can I change the directory of migrate command? Or how can I solve this problem.
CodePudding user response:
so first change timestamp line and put this line:
$table->timestamp('email_verified_at')->nullable();
then in command line use:
php artisan migrate:fresh