Geethu
Geethu

Reputation: 390

Deleted migration files getting executed : Laravel application

I hace deleted some migration files. but when i execute php artisan migrate command, error in the old migration file is showing.

[Illuminate\Database\QueryException]
SQLSTATE[HY000]: General error: 1215 Cannot add foreign key constraint (SQL : alter table cushbu_notifications add constraint cushbu_notifications_art_id_foreign foreign key (art_id) references cushbu_arts (id) on de lete cascade)

Now i don't have migration file for cushbu_notifications, instead i created a new migration file for cushbu_user_notifications.I deleted the cushbu_notifications table from database, also the corresponding entry from migrations table.

Upvotes: 2

Views: 2819

Answers (3)

Prasanna J
Prasanna J

Reputation: 49

Deleting migration files manually will not remove them from the Laravel cache. You can remove them by executing this.

php artisan optimize

Upvotes: 1

Gaurav Rai
Gaurav Rai

Reputation: 928

After manually deleting migration files, clear cache by below command, and then migrate

php artisan cache:clear

then

php artisan migrate

Upvotes: 5

Vishal Varshney
Vishal Varshney

Reputation: 905

remove the entry from the migration table. and also remove references if that used in another migrations file.

Upvotes: 1

Related Questions