php artisan migrate fails when migrating from V0.23 #827

Closed
opened 2026-02-04 22:24:26 +03:00 by OVERLORD · 12 comments
Owner

Originally created by @NathanVaughn on GitHub (Sep 24, 2018).

Originally assigned to: @ssddanbrown on GitHub.

Describe the bug
php artisan migrate fails when migrating from V0.23

Steps To Reproduce
Steps to reproduce the behavior:

  1. Have Bookstack V0.23 instance setup
  2. git pull origin release && composer install && php artisan migrate
  3. See error

Expected behavior
Migrate to complete successfully.

Screenshots
capture

Your Configuration (please complete the following information):

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

Additional context
I have had this happen on 2 different instances.

Originally created by @NathanVaughn on GitHub (Sep 24, 2018). Originally assigned to: @ssddanbrown on GitHub. **Describe the bug** `php artisan migrate` fails when migrating from V0.23 **Steps To Reproduce** Steps to reproduce the behavior: 1. Have Bookstack V0.23 instance setup 2. `git pull origin release && composer install && php artisan migrate` 4. See error **Expected behavior** Migrate to complete successfully. **Screenshots** ![capture](https://user-images.githubusercontent.com/8636459/45954310-4e26c080-bfd2-11e8-88a4-79340a73437a.JPG) **Your Configuration (please complete the following information):** - Exact BookStack Version (Found in settings): 0.23 - PHP Version: 7.2.7 - Hosting Method (Nginx/Apache/Docker): Apache **Additional context** I have had this happen on 2 different instances.
OVERLORD added the 🐛 Bug label 2026-02-04 22:24:26 +03:00
Author
Owner

@Jekotia commented on GitHub (Sep 24, 2018):

Same issue here, coming from 0.22.0.

@Jekotia commented on GitHub (Sep 24, 2018): Same issue here, coming from 0.22.0.
Author
Owner

@Jekotia commented on GitHub (Sep 24, 2018):

On subsequent attempts:

bookstack 0 24 0 migrate fail

And here's the copy-able text:

[2018-09-24 13:32:27] production.ERROR: SQLSTATE[42S01]: Base table or view already exists: 1050 Table 'bookshelves' already exists (SQL: create table bookshelves (id int unsigned not null auto_increment primary key, name varchar(200) not null, slug varchar(200) not null, description text not null, created_by int null, updated_by int null, restricted tinyint(1) not null default '0', image_id int null, created_at timestamp null, updated_at timestamp null) default character set utf8mb4 collate utf8mb4_unicode_ci) {"exception":"[object] (Illuminate\Database\QueryException(code: 42S01): SQLSTATE[42S01]: Base table or view already exists: 1050 Table 'bookshelves' already exists (SQL: create table bookshelves (id int unsigned not null auto_increment primary key, name varchar(200) not null, slug varchar(200) not null, description text not null, created_by int null, updated_by int null, restricted tinyint(1) not null default '0', image_id int null, created_at timestamp null, updated_at timestamp null) default character set utf8mb4 collate utf8mb4_unicode_ci) at /var/www/bookstack/vendor/laravel/framework/src/Illuminate/Database/Connection.php:664, Doctrine\DBAL\Driver\PDOException(code: 42S01): SQLSTATE[42S01]: Base table or view already exists: 1050 Table 'bookshelves' already exists at /var/www/bookstack/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOStatement.php:107, PDOException(code: 42S01): SQLSTATE[42S01]: Base table or view already exists: 1050 Table 'bookshelves' already exists at /var/www/bookstack/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOStatement.php:105)"} []

[Illuminate\Database\QueryException]
SQLSTATE[42S01]: Base table or view already exists: 1050 Table 'bookshelves' already exists (SQL: create table bookshelves (id int unsigned not null auto_increment primary key, name varchar(200) not null, slug varchar(200) not null, description text not null, created_by int null, updated_by int null, restricted tinyint(1) not null default '0', image_id int 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 'bookshelves' already exists

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

@Jekotia commented on GitHub (Sep 24, 2018): On subsequent attempts: ![bookstack 0 24 0 migrate fail](https://user-images.githubusercontent.com/654774/45956341-3e15dd80-bfe0-11e8-9ccb-a8547af6444d.png) And here's the copy-able text: > [2018-09-24 13:32:27] production.ERROR: SQLSTATE[42S01]: Base table or view already exists: 1050 Table 'bookshelves' already exists (SQL: create table `bookshelves` (`id` int unsigned not null auto_increment primary key, `name` varchar(200) not null, `slug` varchar(200) not null, `description` text not null, `created_by` int null, `updated_by` int null, `restricted` tinyint(1) not null default '0', `image_id` int null, `created_at` timestamp null, `updated_at` timestamp null) default character set utf8mb4 collate utf8mb4_unicode_ci) {"exception":"[object] (Illuminate\\Database\\QueryException(code: 42S01): SQLSTATE[42S01]: Base table or view already exists: 1050 Table 'bookshelves' already exists (SQL: create table `bookshelves` (`id` int unsigned not null auto_increment primary key, `name` varchar(200) not null, `slug` varchar(200) not null, `description` text not null, `created_by` int null, `updated_by` int null, `restricted` tinyint(1) not null default '0', `image_id` int null, `created_at` timestamp null, `updated_at` timestamp null) default character set utf8mb4 collate utf8mb4_unicode_ci) at /var/www/bookstack/vendor/laravel/framework/src/Illuminate/Database/Connection.php:664, Doctrine\\DBAL\\Driver\\PDOException(code: 42S01): SQLSTATE[42S01]: Base table or view already exists: 1050 Table 'bookshelves' already exists at /var/www/bookstack/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOStatement.php:107, PDOException(code: 42S01): SQLSTATE[42S01]: Base table or view already exists: 1050 Table 'bookshelves' already exists at /var/www/bookstack/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOStatement.php:105)"} [] > [Illuminate\Database\QueryException] SQLSTATE[42S01]: Base table or view already exists: 1050 Table 'bookshelves' already exists (SQL: create table `bookshelves` (`id` int unsigned not null auto_increment primary key, `name` varchar(200) not null, `slug` varchar(200) not null, `description` text not null, `created_by` int null, `updated_by` int null, `restricted` tinyint(1) not null default '0', `image_id` int 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 'bookshelves' already exists > [PDOException] > SQLSTATE[42S01]: Base table or view already exists: 1050 Table 'bookshelves' already exists
Author
Owner

@ssddanbrown commented on GitHub (Sep 24, 2018):

Thanks for reporting @NathanVaughn & @Jekotia.

Can either of you confirm MySQL versions?

@ssddanbrown commented on GitHub (Sep 24, 2018): Thanks for reporting @NathanVaughn & @Jekotia. Can either of you confirm MySQL versions?
Author
Owner

@ssddanbrown commented on GitHub (Sep 24, 2018):

And also, At any point, Have either of you been using MySQL 5.5 with BookStack?

Checking the engine used on the books table would be a big help, To see if it's InnoDB or MyISAM.

@ssddanbrown commented on GitHub (Sep 24, 2018): And also, At any point, Have either of you been using MySQL 5.5 with BookStack? Checking the engine used on the `books` table would be a big help, To see if it's InnoDB or MyISAM.
Author
Owner

@Jekotia commented on GitHub (Sep 24, 2018):

@ssddanbrown

$ mysql --version
mysql Ver 14.14 Distrib 5.7.21, for Linux (x86_64) using EditLine wrapper

According to SHOW TABLE STATUS\G all tables are InnoDB except for the following, which are MyISAM:

  • books
  • chapters
  • pages
@Jekotia commented on GitHub (Sep 24, 2018): @ssddanbrown $ mysql --version mysql Ver 14.14 Distrib 5.7.21, for Linux (x86_64) using EditLine wrapper According to `SHOW TABLE STATUS\G` all tables are InnoDB except for the following, which are MyISAM: - books - chapters - pages
Author
Owner

@ssddanbrown commented on GitHub (Sep 24, 2018):

@Jekotia Thanks for confirming, Just creating a patch now.

@ssddanbrown commented on GitHub (Sep 24, 2018): @Jekotia Thanks for confirming, Just creating a patch now.
Author
Owner

@Jekotia commented on GitHub (Sep 24, 2018):

@ssddanbrown I manually applied the above commit and this is now the result when trying to migrate

[2018-09-24 15:10:37] production.ERROR: SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'role_id' cannot be null (SQL: insert into permission_role (permission_id, role_id) values (69, )) {"exception":"[object] (Illuminate\Database\QueryException(code: 23000): SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'role_id' cannot be null (SQL: insert into permission_role (permission_id, role_id) values (69, )) at /var/www/bookstack/vendor/laravel/framework/src/Illuminate/Database/Connection.php:664, Doctrine\DBAL\Driver\PDOException(code: 23000): SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'role_id' cannot be null at /var/www/bookstack/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOStatement.php:107, PDOException(code: 23000): SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'role_id' cannot be null at /var/www/bookstack/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOStatement.php:105)"} []

[Illuminate\Database\QueryException]
SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'role_id' cannot be null (SQL: insert into permission_role (permission_id, role_id) values (69, ))

[Doctrine\DBAL\Driver\PDOException]
SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'role_id' cannot be null

[PDOException]
SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'role_id' cannot be null

@Jekotia commented on GitHub (Sep 24, 2018): @ssddanbrown I manually applied the above commit and this is now the result when trying to migrate > [2018-09-24 15:10:37] production.ERROR: SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'role_id' cannot be null (SQL: insert into `permission_role` (`permission_id`, `role_id`) values (69, )) {"exception":"[object] (Illuminate\\Database\\QueryException(code: 23000): SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'role_id' cannot be null (SQL: insert into `permission_role` (`permission_id`, `role_id`) values (69, )) at /var/www/bookstack/vendor/laravel/framework/src/Illuminate/Database/Connection.php:664, Doctrine\\DBAL\\Driver\\PDOException(code: 23000): SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'role_id' cannot be null at /var/www/bookstack/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOStatement.php:107, PDOException(code: 23000): SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'role_id' cannot be null at /var/www/bookstack/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOStatement.php:105)"} [] > [Illuminate\Database\QueryException] >SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'role_id' cannot be null (SQL: insert into `permission_role` (`permission_id`, `role_id`) values (69, )) > [Doctrine\DBAL\Driver\PDOException] > SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'role_id' cannot be null > [PDOException] > SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'role_id' cannot be null
Author
Owner

@ssddanbrown commented on GitHub (Sep 24, 2018):

@Jekotia Yeah, Came across that also, Just debugging it now.

@ssddanbrown commented on GitHub (Sep 24, 2018): @Jekotia Yeah, Came across that also, Just debugging it now.
Author
Owner

@ssddanbrown commented on GitHub (Sep 24, 2018):

@Jekotia @NathanVaughn Okay, Just pushed out a new release. Please try again. Hopefully should be covered now. Please confirm here how the upgrade want. Apologies for this issue.

@ssddanbrown commented on GitHub (Sep 24, 2018): @Jekotia @NathanVaughn Okay, Just pushed out a new release. Please try again. Hopefully should be covered now. Please confirm here how the upgrade want. Apologies for this issue.
Author
Owner

@NathanVaughn commented on GitHub (Sep 24, 2018):

The new release worked perfectly for me. Thanks so much @ssddanbrown.

@NathanVaughn commented on GitHub (Sep 24, 2018): The new release worked perfectly for me. Thanks so much @ssddanbrown.
Author
Owner

@ssddanbrown commented on GitHub (Sep 24, 2018):

Awesome, Hopefully that covers everything. Will close this then.

@ssddanbrown commented on GitHub (Sep 24, 2018): Awesome, Hopefully that covers everything. Will close this then.
Author
Owner

@Jekotia commented on GitHub (Sep 24, 2018):

Fixed here as well. Thank you for the prompt resolution!

@Jekotia commented on GitHub (Sep 24, 2018): Fixed here as well. Thank you for the prompt resolution!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/BookStack#827