gpt4 book ai didi

mysql - Laravel 默认用户迁移

转载 作者:行者123 更新时间:2023-11-29 06:25:47 26 4
gpt4 key购买 nike

我正在尝试使用 Laravel 来设置所需的数据库表。使用记录的:

php artisan make:migration create_users_table;
php artisan migrate;

但是,这会生成一个简单的三列表:

id
created_at
updated_at

身份验证(默认 Laravel 设置)需要明显的字段,例如电子邮件和密码,这意味着在尝试使用“开箱即用”身份验证时会出现错误:

SQLSTATE[42S22]: Column not found: 1054 Unknown column 'email' in 'where clause' (SQL: select count(*) as aggregate from users where email =

我在这里遗漏了一些东西,我本以为要使用预设的身份验证脚手架,Laravel 会正确设置数据库。

我应该从一开始就运行什么来做到这一点?

最佳答案

事实上,您不需要创建此迁移。默认情况下,在全新的 Laravel 安装中,您已经创建了用户迁移,因此您可以运行

php artisan migrate 

运行此迁移。

默认用户迁移为 here并且可以找到所有 3 个默认迁移 here

如果您创建自定义新迁移,那么它只包含 id 和时间戳(created_at/updated_at),因此您应该编辑此类迁移文件以放置您想要的列

关于mysql - Laravel 默认用户迁移,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59555557/

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