laravel - 由于我没有制作用户表,无法进行迁移
问题描述
我正在尝试为我的方案迁移一个新表,当我运行 php artisan migrate 时,出现以下错误:
Migrating: 2014_10_12_000000_create_users_table
Illuminate\Database\QueryException : SQLSTATE[42S01]: Base table or view already exists: 1050 Table 'users' already exists (SQL: create table `users` (`id` bigint unsigned not null auto_increment primary key, `name` varchar(191) not null, `email` varchar(191) not null, `email_verified_at` timestamp null, `password` varchar(191) not null, `remember_token` varchar(100) null, `created_at` timestamp null, `updated_at` timestamp null) default character set utf8mb4 collate 'utf8mb4_unicode_ci')
我没有创建该迁移,它是由 php artisan make:auth 自动提供的,据我所知,它已经运行,因为 users 表已启动并正在运行,所以我不知道如何解决它。任何帮助将不胜感激
解决方案
尝试运行 php artisan migrate:reset 如果它不起作用并且给你一个错误登录到你的 phpmyadmin 页面并手动删除它。
但在再次运行 php artisan migrate 之前,请确保此代码位于 create_users_table 迁移文件的底部:
@return void
public function down()
{
Schema::dropIfExists('users');
}
所以当你运行 php artisan migrate:refresh 时,它会删除当前表并重新创建它
推荐阅读
- javascript - 我正在尝试使用“Rick and Morty”REST API 在我的屏幕上呈现名称,但没有任何文字呈现,而且我的状态没有更新
- vue.js - 在 vue 中使用 url-loader 获取特定目录中的图像
- pandas - 熊猫每行获得上下栅栏
- variables - 在 Azure Pipeline 任务失败中设置变量
- java - 在 weblogic 12c 中编译 JSP 失败。类方法未定义
- android - AndroidX 迁移 - androidx.legacy:legacy-support-v4 或 androidx.appcompat:appcompat
- react-native - 使用带有样式组件的 react i18next
- c# - 如何在 Xamarin 中使用 GraphQL 将数据存储在 Apollo 缓存中?
- android - 停止从 BroadcastReceiver 启动的 Android 媒体播放器循环
- android - 如何在现有的 React Native App 中集成原生 ios 相机 SDK?