Laravel - php artisan 迁移,table 已经存在

Laravel - php artisan migrate, table already exists

我正在尝试 运行 我的两个 table 之间的新迁移但是当我 运行 php artisan migrate 它显示:

SQLSTATE[42S01]: Base table or view already exists: 1050 Table 'packings' already exists (SQL: create table packings (id bigint unsigned not null auto_increment primary key, trip_id int not null, title varchar(191) not null, is_complete tinyint(1) not null, created_at timestamp null, updated_at timestamp null) default character set utf8mb4 collate 'utf8mb4_unicode_ci')

Packings 是我上周制作的 table... 我试着 运行 php artisan migrate:rollback 它显示..

Cannot declare class AddTripsIdToEvents, because the name is already in use

这个 class 来自我几周前进行的另一个迁移。

我不知道如何在不破坏我的网站和丢失数据的情况下解决这个问题..

我认为确实迁移了,但是 fail/error 在外键或类似的东西上,所以 table 创建但迁移失败并且没有保存在迁移 table 上。您只需要在 SQL 命令或像 PHPMyAdmin 这样的数据库管理中手动删除 table packings

Cannot declare class AddTripsIdToEvents, because the name is already in use

显示上述错误是因为您有相同的迁移 class 名称。只需将一个更改为另一个名称,不要忘记也更改文件名。