PHP artisan migrate does not create migration table - Hack The Tech - Latest News related to Computer and Technology

logo

Get Daily Latest News related to Computer and Technology and hack the world.

Wednesday, November 15, 2023

demo-image

PHP artisan migrate does not create migration table

I have setup my laravel project, configured mysql username and password and created the database. I have migrations and seeder set up. However, when I run php artisan migrate, I am met with the following error.

 INFO  Preparing database.  

  Creating migration table ............................................................................................................... 38ms DONE

   INFO  Loading stored database schemas.  

  database/schema/mysql-schema.sql ...................................................................................................... 115ms DONE


In Connection.php line 801:
                                                                                                                                                                                                        
  SQLSTATE[42S02]: Base table or view not found: 1146 Table 'db_name.migrations' doesn't exist (Connection: mysql, SQL: select `migration` from `migrations` order by `batch` asc, `migration` asc)  
                                                                                                                                                                                                        

In Connection.php line 416:
                                                                                                   
  SQLSTATE[42S02]: Base table or view not found: 1146 Table 'db_name.migrations' doesn't exist  

I have tried creating the migrations table in MySQL using

USE db_name; CREATE TABLE migrations (     id INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,     migration VARCHAR(255) NOT NULL,     batch INT NOT NULL ) ENGINE=InnoDB;

which it then returns Query OK, 0 rows affected (0.01 sec). However, when I run migrations using php artisan migrate, I am met with the same error mentioned above, and when I look in the database, the migrations table is no longer present.

What could be the problem and how can I go about solving it?



source https://stackoverflow.com/questions/77480213/php-artisan-migrate-does-not-create-migration-table

No comments:

Post a Comment