php artisan migrate fails when migrating from V0.24.3 to latest #1392

Closed
opened 2026-02-05 00:46:06 +03:00 by OVERLORD · 4 comments
Owner

Originally created by @ghost on GitHub (Oct 4, 2019).

Describe the bug
php artisan migrate fails when migrating from v0.24.3 ( see Additional context section )

Steps To Reproduce
Steps to reproduce the behavior:

  1. Go to bookstack location
  2. git pull origin release && composer install && php artisan migrate
  3. See error

Expected behavior
Migrate completes without errors

Screenshots

  [Illuminate\Database\QueryException]                                                                                                                                                      
  SQLSTATE[42S01]: Base table or view already exists: 1050 Table 'user_invites' already exists (SQL: create table `user_invites` (`id` int unsigned not null auto_increment primary key, `u  
  ser_id` int not null, `token` varchar(191) not null, `created_at` timestamp null, `updated_at` timestamp null) default character set utf8mb4 collate utf8mb4_unicode_ci)                  
                                                                                                                                                                                             

                                                                                               
  [Doctrine\DBAL\Driver\PDOException]                                                          
  SQLSTATE[42S01]: Base table or view already exists: 1050 Table 'user_invites' already exists  
                                                                                               

                                                                                               
  [PDOException]                                                                                
  SQLSTATE[42S01]: Base table or view already exists: 1050 Table 'user_invites' already exists  

Your Configuration (please complete the following information):

  • Exact BookStack Version (Found in settings): 0.24.3
  • PHP Version: 7.3.9
  • Hosting Method (Nginx/Apache/Docker): Nginx

Additional context
The error seems to be only in this case:
https://www.bookstackapp.com/docs/admin/backup-restore/
Restore-> Database section:
"If you are restoring to a new version of BookStack you will have to run php artisan migrate after restore to perform any required updates to the database."

  1. Install new version
  2. Restore database from old version
  3. Update command
Originally created by @ghost on GitHub (Oct 4, 2019). **Describe the bug** php artisan migrate fails when migrating from v0.24.3 **( see Additional context section )** **Steps To Reproduce** Steps to reproduce the behavior: 1. Go to bookstack location 2. `git pull origin release && composer install && php artisan migrate` 3. See error **Expected behavior** Migrate completes without errors **Screenshots** ``` [Illuminate\Database\QueryException] SQLSTATE[42S01]: Base table or view already exists: 1050 Table 'user_invites' already exists (SQL: create table `user_invites` (`id` int unsigned not null auto_increment primary key, `u ser_id` int not null, `token` varchar(191) not null, `created_at` timestamp null, `updated_at` timestamp null) default character set utf8mb4 collate utf8mb4_unicode_ci) [Doctrine\DBAL\Driver\PDOException] SQLSTATE[42S01]: Base table or view already exists: 1050 Table 'user_invites' already exists [PDOException] SQLSTATE[42S01]: Base table or view already exists: 1050 Table 'user_invites' already exists ``` **Your Configuration (please complete the following information):** - Exact BookStack Version (Found in settings): 0.24.3 - PHP Version: 7.3.9 - Hosting Method (Nginx/Apache/Docker): Nginx **Additional context** The error seems to be only in this case: https://www.bookstackapp.com/docs/admin/backup-restore/ Restore-> Database section: **"If you are restoring to a new version of BookStack you will have to run php artisan migrate after restore to perform any required updates to the database."** 1. Install new version 2. Restore database from old version 3. Update command
OVERLORD added the 🐕 Support📖 Docs Update labels 2026-02-05 00:46:06 +03:00
Author
Owner

@BradLugo commented on GitHub (Oct 31, 2019):

I'm experiencing the same issue, upgrading from v0.25.5. After testing multiple upgrade paths, it appears this error starts happening at v0.27.x

@BradLugo commented on GitHub (Oct 31, 2019): I'm experiencing the same issue, upgrading from v0.25.5. After testing multiple upgrade paths, it appears this error starts happening at v0.27.x
Author
Owner

@ssddanbrown commented on GitHub (Mar 13, 2020):

My apologies for not responding to this until now, Slipped through the net.

I think this could occur if you restore your database backup, for an older BookStack version, after running the migrations within an updated/fresh BookStack instance.

I've updated the docs to properly state that the database should not be migrated in this instance: https://www.bookstackapp.com/docs/admin/backup-restore/#restore

I'll close this off. If this remains to be an issue, or the above is not clear feel free to open a new issue, referencing this one.

@ssddanbrown commented on GitHub (Mar 13, 2020): My apologies for not responding to this until now, Slipped through the net. I think this could occur if you restore your database backup, for an older BookStack version, after running the migrations within an updated/fresh BookStack instance. I've updated the docs to properly state that the database should not be migrated in this instance: https://www.bookstackapp.com/docs/admin/backup-restore/#restore I'll close this off. If this remains to be an issue, or the above is not clear feel free to open a new issue, referencing this one.
Author
Owner

@KieranFJ commented on GitHub (Mar 13, 2020):

Had this same issue when upgrading a test image from v26.x to latest.

Did a little work around that might help

Ran the upgrade command as suggested.
Imported a database backup from a live image that was still on v26.3. Re-ran the migrate command again. Got the same error for user_invites and later the same for api_tokens.

As it was just a test server and those tables were empty, i just dropped the user_invites and api_token tables and then reran php artisan migrate and it all worked.

@KieranFJ commented on GitHub (Mar 13, 2020): Had this same issue when upgrading a test image from v26.x to latest. Did a little work around that might help Ran the upgrade command as suggested. Imported a database backup from a live image that was still on v26.3. Re-ran the migrate command again. Got the same error for user_invites and later the same for api_tokens. As it was just a test server and those tables were empty, i just dropped the user_invites and api_token tables and then reran php artisan migrate and it all worked.
Author
Owner

@andrewsoluis commented on GitHub (Oct 22, 2020):

Had this same issue when upgrading a test image from v26.x to latest.

Did a little work around that might help

Ran the upgrade command as suggested.
Imported a database backup from a live image that was still on v26.3. Re-ran the migrate command again. Got the same error for user_invites and later the same for api_tokens.

As it was just a test server and those tables were empty, i just dropped the user_invites and api_token tables and then reran php artisan migrate and it all worked.

This helped me out when I was stuck in a bind! Great suggestion.

@andrewsoluis commented on GitHub (Oct 22, 2020): > Had this same issue when upgrading a test image from v26.x to latest. > > Did a little work around that might help > > Ran the upgrade command as suggested. > Imported a database backup from a live image that was still on v26.3. Re-ran the migrate command again. Got the same error for user_invites and later the same for api_tokens. > > As it was just a test server and those tables were empty, i just dropped the user_invites and api_token tables and then reran php artisan migrate and it all worked. This helped me out when I was stuck in a bind! Great suggestion.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/BookStack#1392