简体   繁体   中英

Laravel Voyager: how to use my migration instead of Voyager

I try to set Laravel Voyager admin panel to existing project, i have already tables 'users', 'roles', 'permission', 'categories' etc. When I use php artisan voyager:install , I get an error

Illuminate\\Database\\QueryException]
SQLSTATE[42S21]: Column already exists: 1060 Duplicate column name 'avatar' (SQL: alter table users add avatar varchar(191) null after email , add role_id int null after id )

Voyager try to run his own migration and this leads to errors, how to tell Voyager to use my tables?

当您在laravel中安装voyager管理面板时,它附带了一些表,例如用户表和权限表,因此,由于数据库中有这些表,因此为什么它告诉您列已存在。

Below is what worked for me; Your migration files should be up to date.

Mine was about categories.. I had to do a seed reversal of the data on my database after installing voyager so that my data would not be lost when I drop my database..It might be a little bit challenging for big data.

Here is the link to do that https://github.com/orangehill/iseed then after that I ran php artisan migrate:fresh This will drop the database and also recreate it with the former tables structure and then execute the migrate command. Note the tables are going to be empty . And voyager is also going to work now without errors.

Then after that populate your tables again using the seeder command. Documentation here: https://laravel.com/docs/8.x/seeding

Another way to also solve this might be to revisit voyager source code and edit the variables; setting them to different values other than what you had set in your database:)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM