skip to Main Content

I am doing a project in php Laravel. I am beginner. Accidently I have deleted a table in sql in phpmyadmin.

Now how to recreate that table from php. Not by using sql command.

2

Answers


  1. from the command line type php artisan migrate:fresh --seed however please be advised this will also delete any data in your database.

    There is no way to restore the data you have deleted

    Login or Signup to reply.
  2. If you want to create the table without data, I can give you a simple solution for your problem

    Usually, when you do the migration, the Laravel will compare the list of files between migrations table and /database/migrations folder, if a file exists on the folder and not entered on migrations table then it’ll execute the file and make the entry.

    So, find the migration file name which creates your table on migrations table and deletes that row from the database, run the command php artisan migrate

    this will create the new table

    Note: We don’t prefer this mostly, but for your problem, it’ll be simple

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search