0

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.

4
  • 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. Commented Mar 6, 2017 at 19:43
  • 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 why Commented Mar 6, 2017 at 19:50
  • 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. Commented Mar 6, 2017 at 19:52
  • i was see this problem before and you can check this link stackoverflow.com/questions/48270874/… Commented Jan 20, 2018 at 21:40

3 Answers 3

1

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

Sign up to request clarification or add additional context in comments.

Comments

1

The simplest fix is: php artisan migrate:refresh

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

More info in the docs.

Comments

0

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

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

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.