Hy there,
I entered some fields in migration file and then migrated it to phpmyadmin, but lateron I added some more fields in it but I have already entered data in the table. If I drop that table from phpmyadmin, it doesn’t migrate using
php artisan migrate
if I wipe the whole database, I lose the whole data.
php artisan db:wipe
So I just want to get that added fields in my table without lossing my entered data.
Thanks in Advance,
Junaid Ali
If I drop that table from phpmyadmin, it doesn’t migrate using
php artisan migrate
if I wipe the whole database, I lose the whole data.
php artisan db:wipe
So I just want to get that added fields in my table without lossing my entered data.
2
Answers
go to your database and open the table "migrations" then you search and delete the migration from your database and run migrates again.
If this doesn’t work run this command
php artisan migrate:fresh
it will delete all your database and then automatically run migrations.If this doesn’t work then check in your .env if the database set is the same.
If none of this works do as @Maksim said.
If you just wanted to add a new field to a exiting migration, you can just
Generate a new Migration file then run a php artisan migrate, so that you don’t have to problem about losing you existing data in your database.
ex.
//your existing table
//to add new field (vote)
then run php artisan migrate to add vote field to your users table
you can also refer to the laravel documentation for much detailed explanation about generating migrations
https://laravel.com/docs/8.x/migrations