0
votes

I can create migration. It's working fine but when I do php artisan migrate it says

[Illuminate\Database\QueryException]

SQLSTATE[42S01]: Base table or view already exists: 1050 Table 'users' already exists (SQL: create table users (id int unsigned not null auto_increment primary key, name varchar(255) not null, email varchar(255) not null, password varchar(255) not null, remember_token varchar(100) null, created_at timestamp null, updated_at timestamp null) default character set utf8 collate utf8_unicode_ci)

[PDOException]

SQLSTATE[42S01]: Base table or view already exists: 1050 Table 'users' already exists

I checked my database.php file and it's working fine and already migrated default users table too to my php my admin mysql.

3
If you've already migrated the users table, go into the users migration file and comment everything in the up function. Be sure to uncomment everything after you've migrated.aynber
but this time im not migrating user table im migrating POST table which is not working , i can create more migrations different names but when i try to migrate it gives me this error i dont know whyQazalbash
For some reason, it doesn't see that you'd already migrated that file. Maybe it's not listed in migrations, or you did a migrate:rollback that partially failed, but still removed line out of the migrations table. Commenting it temporarily helps the migrations table get up-to-date.aynber
i was see this problem before and you can check this link stackoverflow.com/questions/48270874/…M.ramadan

3 Answers

1
votes

Delete all tables form the software (phpmyadmin) and then migrate again this will migrate the new created table , this is not a proper solution but this worked here on learning level , Regards

1
votes

The simplest fix is: php artisan migrate:refresh

⚠️ You will lose all data in your tables! ⚠️

More info in the docs.

0
votes

You can use this sentence in the UsersTableSeeder to regenerate the table:

DB::table('users')->truncate();