简体   繁体   中英

Laravel Forge: Base table or view already exists: 1050 Table already exists

I've gotten this error before but this time it's a bit different.

When I push an update to forge, Laravel Forge says it failed to deploy, but it deployed just fine. It just doesn't make any changes to the database structure due to this error:

[Doctrine\\DBAL\\Driver\\PDOException]
SQLSTATE[42S01]: Base table or view already exists: 1050 Table 'job_posts' already exists

When I run php artisan migrate:status , the job_posts table is the only one that shows as not ran, even though it clearly already has been ran.

Also dropping the existing table or anything that would delete existing records are out of the question as this change was made a few weeks back and users have already started using it.

Is there any way to solve this without removing existing records?

in your Migration you can simply use

if (!Schema::hasTable('job_posts')) {
  // your migrations
}

If it is false then run the migrations.

This way your records will not be deleted.

Hope this helps

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM