gpt4 book ai didi

php - laravel php artisan migrate 不会创建新表

转载 作者:搜寻专家 更新时间:2023-10-31 20:41:07 25 4
gpt4 key购买 nike

我创建了用户迁移,然后创建了表。这是命令:

php artisan migration:make create_users_table --table=users --create

然后我更新了我想要的字段的架构,并运行了这个命令:

php artisan migration

它可以工作并创建了包含所有字段的表。

然后我再次键入以下命令为评论表创建一个新表的架构"

php artisan migration:make create_comments_table --table=comments --create

它奏效了。

我更新了表的实际模式,但是当我命令 php artisan migrate 时它抛出一个错误:

Base table or view already exists. table 'users' ....

为什么?因为我正在创建评论表,它与用户表有什么关系。

最佳答案

为避免出现问题,请尝试创建这样的表

php artisan migrate:make create_users_table --table=users --create=users

php artisan migrate:make create_comments_table --table=comments --create=comments

注意每个 cli 命令的 --create 中的参数。

关于php - laravel php artisan migrate 不会创建新表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21350615/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com