Bookstack: php artisan migrate fails when migrating from V0.23

Created on 24 Sep 2018  路  12Comments  路  Source: BookStackApp/BookStack

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.

Bug

All 12 comments

Same issue here, coming from 0.22.0.

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

Thanks for reporting @NathanVaughn & @Jekotia.

Can either of you confirm MySQL versions?

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

$ 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 Thanks for confirming, Just creating a patch now.

@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 Yeah, Came across that also, Just debugging it now.

@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.

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

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

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

Was this page helpful?
0 / 5 - 0 ratings

Related issues

gab-cass picture gab-cass  路  3Comments

mackcoding picture mackcoding  路  3Comments

hhk7734 picture hhk7734  路  3Comments

ensemblebd picture ensemblebd  路  3Comments

Abijeet picture Abijeet  路  3Comments