Error after Upgrade to Version 20 (from 18.4) with posting Grid Image #604

Closed
opened 2026-02-04 21:23:43 +03:00 by OVERLORD · 7 comments
Owner

Originally created by @jacksonp2008 on GitHub (Mar 16, 2018).

For Bug Reports

  • BookStack Version (Found in settings, Please don't put 'latest'):20.0

  • PHP Version: PHP 7.0.22-0ubuntu0.16.04.1 (cli) ( NTS )
    Copyright (c) 1997-2017 The PHP Group
    Zend Engine v3.0.0, Copyright (c) 1998-2017 Zend Technologies
    with Zend OPcache v7.0.22-0ubuntu0.16.04.1, Copyright (c) 1999-2017, by Zend Technologies

  • MySQL Version:mysql Ver 14.14 Distrib 5.7.21, for Linux (x86_64)

Expected Behavior

When adding an image to the categories for grid view:
screen shot 2018-03-15 at 16 39 27

Current Behavior

I get the following error when I save:

screen shot 2018-03-15 at 16 39 13

Steps to Reproduce

During the upgrade I did get this error, but I don't think related.


  • Application In Production!     *
    

Do you really wish to run this command? (yes/no) [no]:

yes

[Illuminate\Database\QueryException]
SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'comment-create-all' for key 'permissions_name_unique
' (SQL: insert into role_permissions (name, display_name, created_at, updated_at) values (comment-create-all, Cre
ate All Comments, 2018-03-15 23:18:05, 2018-03-15 23:18:05))

[PDOException]
SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'comment-create-all' for key 'permissions_name_unique
'

Originally created by @jacksonp2008 on GitHub (Mar 16, 2018). ### For Bug Reports * BookStack Version *(Found in settings, Please don't put 'latest')*:20.0 * PHP Version: PHP 7.0.22-0ubuntu0.16.04.1 (cli) ( NTS ) Copyright (c) 1997-2017 The PHP Group Zend Engine v3.0.0, Copyright (c) 1998-2017 Zend Technologies with Zend OPcache v7.0.22-0ubuntu0.16.04.1, Copyright (c) 1999-2017, by Zend Technologies * MySQL Version:mysql Ver 14.14 Distrib 5.7.21, for Linux (x86_64) ##### Expected Behavior When adding an image to the categories for grid view: ![screen shot 2018-03-15 at 16 39 27](https://user-images.githubusercontent.com/1813327/37496525-3d68b0cc-2870-11e8-9a28-00772263172d.png) ##### Current Behavior I get the following error when I save: ![screen shot 2018-03-15 at 16 39 13](https://user-images.githubusercontent.com/1813327/37496575-84ac5a38-2870-11e8-8c97-c28108dd9c48.png) ##### Steps to Reproduce During the upgrade I did get this error, but I don't think related. > ************************************** > * Application In Production! * > ************************************** > > Do you really wish to run this command? (yes/no) [no]: > > yes > > [Illuminate\Database\QueryException] > SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'comment-create-all' for key 'permissions_name_unique > ' (SQL: insert into `role_permissions` (`name`, `display_name`, `created_at`, `updated_at`) values (comment-create-all, Cre > ate All Comments, 2018-03-15 23:18:05, 2018-03-15 23:18:05)) > > [PDOException] > SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'comment-create-all' for key 'permissions_name_unique > '
OVERLORD added the 🐕 Support label 2026-02-04 21:23:43 +03:00
Author
Owner

@Abijeet commented on GitHub (Mar 19, 2018):

Hi @jacksonp2008

There are two issues here, and the actual issue is hidden behind this issue that you're seeing here.

Can you please post logs from the laravel.log file present under storage/logs folder?

Also are you running the application in development mode?

The actual exception is masked by an exception thrown from here - https://github.com/filp/whoops/blob/master/src/Whoops/Handler/PrettyPageHandler.php#L413

@Abijeet commented on GitHub (Mar 19, 2018): Hi @jacksonp2008 There are two issues here, and the actual issue is hidden behind this issue that you're seeing here. Can you please post logs from the `laravel.log` file present under `storage/logs` folder? Also are you running the application in development mode? The actual exception is masked by an exception thrown from here - https://github.com/filp/whoops/blob/master/src/Whoops/Handler/PrettyPageHandler.php#L413
Author
Owner

@jacksonp2008 commented on GitHub (Mar 20, 2018):

here ya go
laravel.log

@jacksonp2008 commented on GitHub (Mar 20, 2018): here ya go [laravel.log](https://github.com/BookStackApp/BookStack/files/1827226/laravel.log)
Author
Owner

@Abijeet commented on GitHub (Mar 20, 2018):

Error seems to be that the image_id column is not present.

[2018-03-15 23:37:08] production.ERROR: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'image_id' in 'field list' (SQL: update `books` set `updated_at` = 2018-03-15 23:37:08, `updated_by` = 154, `image_id` = xxxx where `id` = 13) 

{"userId":154,"email":"spollock@forescout.com","exception":"[object] (Illuminate\\Database\\QueryException(code: 42S22): SQLSTATE[42S22]: Column not found: 1054 Unknown column 'image_id' in 'field list'

I would run the migrations again.

@Abijeet commented on GitHub (Mar 20, 2018): Error seems to be that the `image_id` column is not present. ``` [2018-03-15 23:37:08] production.ERROR: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'image_id' in 'field list' (SQL: update `books` set `updated_at` = 2018-03-15 23:37:08, `updated_by` = 154, `image_id` = xxxx where `id` = 13) {"userId":154,"email":"spollock@forescout.com","exception":"[object] (Illuminate\\Database\\QueryException(code: 42S22): SQLSTATE[42S22]: Column not found: 1054 Unknown column 'image_id' in 'field list' ``` I would run the migrations again.
Author
Owner

@jacksonp2008 commented on GitHub (Mar 20, 2018):

Same error:

root@dev-wiki:/var/www/bookstack# php artisan migrate
**************************************
*     Application In Production!     *
**************************************

 Do you really wish to run this command? (yes/no) [no]:
 > yes


                                                                                                                      
  [Illuminate\Database\QueryException]                                                                                
  SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'comment-create-all' for key 'permissions_na  
  me_unique' (SQL: insert into `role_permissions` (`name`, `display_name`, `created_at`, `updated_at`) values (comme  
  nt-create-all, Create All Comments, 2018-03-20 16:49:37, 2018-03-20 16:49:37))                                      
                                                                                                                      

                                                                                                                      
  [PDOException]                                                                                                      
  SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'comment-create-all' for key 'permissions_na  
  me_unique'                                                                                                          
                                                                                                                      

root@dev-wiki:/var/www/bookstack# 
@jacksonp2008 commented on GitHub (Mar 20, 2018): Same error: ``` root@dev-wiki:/var/www/bookstack# php artisan migrate ************************************** * Application In Production! * ************************************** Do you really wish to run this command? (yes/no) [no]: > yes [Illuminate\Database\QueryException] SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'comment-create-all' for key 'permissions_na me_unique' (SQL: insert into `role_permissions` (`name`, `display_name`, `created_at`, `updated_at`) values (comme nt-create-all, Create All Comments, 2018-03-20 16:49:37, 2018-03-20 16:49:37)) [PDOException] SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'comment-create-all' for key 'permissions_na me_unique' root@dev-wiki:/var/www/bookstack# ```
Author
Owner

@Abijeet commented on GitHub (Mar 20, 2018):

OK, so it appears that this migration ran, but was not recorded as such in the migration table.

Can you please paste the output after running the following command on the database,

-- replace bookstack with your database name
SELECT * FROM bookstack.role_permissions WHERE name LIKE 'comment-%';

It should show you something similar to the below,

screenshot from 2018-03-20 23-36-20

If yes, the migration ran properly, but a record was not created in the migration table. This causes the artisan command to think that the migration was never run.

I'd recommend creating a record in the database migration table manually with the following query,

INSERT INTO `bookstack`.`migrations`
(`migration`,`batch`)
VALUES
('2017_08_01_130541_create_comments_table', 2);

After you are done with that, try running the migrations again by php artisan migrate

@Abijeet commented on GitHub (Mar 20, 2018): OK, so it appears that [this](https://github.com/BookStackApp/BookStack/blob/master/database/migrations/2017_08_01_130541_create_comments_table.php) migration ran, but was not recorded as such in the migration table. Can you please paste the output after running the following command on the database, ``` -- replace bookstack with your database name SELECT * FROM bookstack.role_permissions WHERE name LIKE 'comment-%'; ``` It should show you something similar to the below, ![screenshot from 2018-03-20 23-36-20](https://user-images.githubusercontent.com/1685517/37673934-8b3631a0-2c97-11e8-9c3f-72a4c6fd59b2.png) If yes, the migration ran properly, but a record was not created in the migration table. This causes the artisan command to think that the migration was never run. I'd recommend creating a record in the database migration table manually with the following query, ``` INSERT INTO `bookstack`.`migrations` (`migration`,`batch`) VALUES ('2017_08_01_130541_create_comments_table', 2); ``` After you are done with that, try running the migrations again by `php artisan migrate`
Author
Owner

@jacksonp2008 commented on GitHub (Mar 21, 2018):

Indeed it does, are those dates correct?

mysql> SELECT * FROM bookstack.role_permissions WHERE name LIKE 'comment-%';
+----+--------------------+---------------------+-------------+---------------------+---------------------+
| id | name               | display_name        | description | created_at          | updated_at          |
+----+--------------------+---------------------+-------------+---------------------+---------------------+
| 60 | comment-create-all | Create All Comments | NULL        | 2017-11-30 05:27:37 | 2017-11-30 05:27:37 |
| 61 | comment-create-own | Create Own Comments | NULL        | 2017-11-30 05:27:37 | 2017-11-30 05:27:37 |
| 64 | comment-delete-all | Delete All Comments | NULL        | 2017-11-30 05:27:37 | 2017-11-30 05:27:37 |
| 65 | comment-delete-own | Delete Own Comments | NULL        | 2017-11-30 05:27:37 | 2017-11-30 05:27:37 |
| 62 | comment-update-all | Update All Comments | NULL        | 2017-11-30 05:27:37 | 2017-11-30 05:27:37 |
| 63 | comment-update-own | Update Own Comments | NULL        | 2017-11-30 05:27:37 | 2017-11-30 05:27:37 |
+----+--------------------+---------------------+-------------+---------------------+---------------------+

Also inserted the value from above and re-ran the migration:

root@dev-wiki:/var/www/bookstack# php artisan migrate
**************************************
*     Application In Production!     *
**************************************

 Do you really wish to run this command? (yes/no) [no]:
 > yes

Migrating: 2017_08_29_102650_add_cover_image_display
Migrated:  2017_08_29_102650_add_cover_image_display

Then I added an image to the grid view, and it is now working.

Thanks for the assist!

@jacksonp2008 commented on GitHub (Mar 21, 2018): Indeed it does, are those dates correct? ``` mysql> SELECT * FROM bookstack.role_permissions WHERE name LIKE 'comment-%'; +----+--------------------+---------------------+-------------+---------------------+---------------------+ | id | name | display_name | description | created_at | updated_at | +----+--------------------+---------------------+-------------+---------------------+---------------------+ | 60 | comment-create-all | Create All Comments | NULL | 2017-11-30 05:27:37 | 2017-11-30 05:27:37 | | 61 | comment-create-own | Create Own Comments | NULL | 2017-11-30 05:27:37 | 2017-11-30 05:27:37 | | 64 | comment-delete-all | Delete All Comments | NULL | 2017-11-30 05:27:37 | 2017-11-30 05:27:37 | | 65 | comment-delete-own | Delete Own Comments | NULL | 2017-11-30 05:27:37 | 2017-11-30 05:27:37 | | 62 | comment-update-all | Update All Comments | NULL | 2017-11-30 05:27:37 | 2017-11-30 05:27:37 | | 63 | comment-update-own | Update Own Comments | NULL | 2017-11-30 05:27:37 | 2017-11-30 05:27:37 | +----+--------------------+---------------------+-------------+---------------------+---------------------+ ``` Also inserted the value from above and re-ran the migration: ``` root@dev-wiki:/var/www/bookstack# php artisan migrate ************************************** * Application In Production! * ************************************** Do you really wish to run this command? (yes/no) [no]: > yes Migrating: 2017_08_29_102650_add_cover_image_display Migrated: 2017_08_29_102650_add_cover_image_display ``` Then I added an image to the grid view, and it is now working. Thanks for the assist!
Author
Owner

@ssddanbrown commented on GitHub (Mar 23, 2018):

Glad to hear you got this working, Will listen out for similar issues in case the update path broke at some point.

Thanks for your time to support on this one @Abijeet.

@ssddanbrown commented on GitHub (Mar 23, 2018): Glad to hear you got this working, Will listen out for similar issues in case the update path broke at some point. Thanks for your time to support on this one @Abijeet.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/BookStack#604