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

Closed
opened 2018-09-24 15:20:57 +02:00 by NathanVaughn · 12 comments
NathanVaughn commented 2018-09-24 15:20:57 +02:00 (Migrated from github.com)

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.

**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.
Jekotia commented 2018-09-24 15:38:54 +02:00 (Migrated from github.com)

Same issue here, coming from 0.22.0.

Same issue here, coming from 0.22.0.
Jekotia commented 2018-09-24 15:57:48 +02:00 (Migrated from github.com)

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

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
ssddanbrown commented 2018-09-24 15:59:50 +02:00 (Migrated from github.com)

Thanks for reporting @NathanVaughn & @Jekotia.

Can either of you confirm MySQL versions?

Thanks for reporting @NathanVaughn & @Jekotia. Can either of you confirm MySQL versions?
ssddanbrown commented 2018-09-24 16:03:12 +02:00 (Migrated from github.com)

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.

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.
Jekotia commented 2018-09-24 16:20:45 +02:00 (Migrated from github.com)

@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
@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
ssddanbrown commented 2018-09-24 16:22:07 +02:00 (Migrated from github.com)

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

@Jekotia Thanks for confirming, Just creating a patch now.
Jekotia commented 2018-09-24 17:11:15 +02:00 (Migrated from github.com)

@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

@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
ssddanbrown commented 2018-09-24 17:15:18 +02:00 (Migrated from github.com)

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

@Jekotia Yeah, Came across that also, Just debugging it now.
ssddanbrown commented 2018-09-24 17:38:41 +02:00 (Migrated from github.com)

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

@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.
NathanVaughn commented 2018-09-24 17:48:09 +02:00 (Migrated from github.com)

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

The new release worked perfectly for me. Thanks so much @ssddanbrown.
ssddanbrown commented 2018-09-24 18:03:01 +02:00 (Migrated from github.com)

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

Awesome, Hopefully that covers everything. Will close this then.
Jekotia commented 2018-09-24 19:15:04 +02:00 (Migrated from github.com)

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

Fixed here as well. Thank you for the prompt resolution!
Sign in to join this conversation.
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
bookstack/bookstack#1027
No description provided.