unit3d升级报错折腾笔记

unit3d 6.0.x版本升级报错如下

Illuminate\Database\QueryException 

  SQLSTATE[42S01]: Base table or view already exists: 1050 Table 'distributors' already exists (SQL: create table `distributors` (`id` bigint unsigned not null auto_increment primary key, `name` varchar(255) not null, `slug` varchar(255) not null, `position` int not null) default character set utf8mb4 collate 'utf8mb4_unicode_ci')

  at vendor/laravel/framework/src/Illuminate/Database/Connection.php:745
    741▕         // If an exception occurs when attempting to run a query, we'll format the error
    742▕         // message to include the bindings with SQL, which will make this exception a
    743▕         // lot more helpful to the developer instead of just the database's errors.
    744▕         catch (Exception $e) {
  ➜ 745▕             throw new QueryException(
    746▕                 $query, $this->prepareBindings($bindings), $e
    747▕             );
    748▕         }
    749▕     }

      +12 vendor frames 
  13  database/migrations/2021_07_27_185231_create_distributors_table.php:29
      Illuminate\Support\Facades\Facade::__callStatic()

      +22 vendor frames 
  36  artisan:37
      Illuminate\Foundation\Console\Kernel::handle()

主要问题在于php artisan migrate及数据库迁移存在问题

按照报错解决问题,尝试删除 regions和 distributors从迁移 /var/www/html/database/migrations.

再次报错如下:

Illuminate\Database\QueryException 

  SQLSTATE[42S21]: Column already exists: 1060 Duplicate column name 'torrent_id' (SQL: alter table `history` add `torrent_id` bigint unsigned not null after `user_id`)

  at vendor/laravel/framework/src/Illuminate/Database/Connection.php:742
    738▕         // If an exception occurs when attempting to run a query, we'll format the error
    739▕         // message to include the bindings with SQL, which will make this exception a
    740▕         // lot more helpful to the developer instead of just the database's errors.
    741▕         catch (Exception $e) {
  ➜ 742▕             throw new QueryException(
    743▕                 $query, $this->prepareBindings($bindings), $e
    744▕             );
    745▕         }
    746▕     }

      +12 vendor frames 
  13  database/migrations/2022_02_06_210013_update_history_table.php:20
      Illuminate\Support\Facades\Facade::__callStatic()

      +22 vendor frames 
  36  artisan:37
      Illuminate\Foundation\Console\Kernel::handle()

再次按照提示删除sessions,如下图文件/var/www/html/database/migrations

接下来便可以成功执行’php artisan migrate’。