Failed restore attempt #617

Closed
opened 2026-02-04 21:27:46 +03:00 by OVERLORD · 5 comments
Owner

Originally created by @tigattack on GitHub (Mar 29, 2018).

Hi,

Seems like an old install got corrupted (could no longer login, was told incorrect password. Password was correct as it was saved in a password manager), so I created a new server and installed BookStack.

Backed up the old one using the instructions here.
I then restored to the new server (using the instructions again) and ran sudo php artisan migrate. This resulted in a number of errors that I'm unsure how to remedy.

Result of the migrate command:

tigattack@Wiki2:/var/www/bookstack$ sudo php artisan migrate
**************************************
*     Application In Production!     *
**************************************

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



  [Illuminate\Database\QueryException]
  SQLSTATE[42S01]: Base table or view already exists: 1050 Table 'comments' already exists (SQL: create table `comments` (`id` int unsigned not null auto_increment primary key, `entity_id` int unsigned not null, `entity_
  type` varchar(191) not null, `text` longtext null, `html` longtext null, `parent_id` int unsigned null, `local_id` int unsigned null, `created_by` int unsigned not null, `updated_by` int unsigned null, `created_at` tim
  estamp null, `updated_at` timestamp null) default character set utf8mb4 collate utf8mb4_unicode_ci)

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

I then ran the command again and received a different batch of errors. A third run resulted in these different errors again, so it would appear to be consistent now.

tigattack@Wiki2:/var/www/bookstack$ sudo php artisan migrate
**************************************
*     Application In Production!     *
**************************************

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



  [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`) val
  ues (comment-create-all, Create All Comments, 2018-03-29 10:22:28, 2018-03-29 10:22:28))

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

Any help would be much appreciated!

Originally created by @tigattack on GitHub (Mar 29, 2018). Hi, Seems like an old install got corrupted (could no longer login, was told incorrect password. Password was correct as it was saved in a password manager), so I created a new server and installed BookStack. Backed up the old one using the instructions [here](https://www.bookstackapp.com/docs/admin/backup-restore/). I then restored to the new server (using the instructions again) and ran ` sudo php artisan migrate`. This resulted in a number of errors that I'm unsure how to remedy. Result of the migrate command: ```bash tigattack@Wiki2:/var/www/bookstack$ sudo php artisan migrate ************************************** * Application In Production! * ************************************** Do you really wish to run this command? (yes/no) [no]: > y [Illuminate\Database\QueryException] SQLSTATE[42S01]: Base table or view already exists: 1050 Table 'comments' already exists (SQL: create table `comments` (`id` int unsigned not null auto_increment primary key, `entity_id` int unsigned not null, `entity_ type` varchar(191) not null, `text` longtext null, `html` longtext null, `parent_id` int unsigned null, `local_id` int unsigned null, `created_by` int unsigned not null, `updated_by` int unsigned null, `created_at` tim estamp null, `updated_at` timestamp null) default character set utf8mb4 collate utf8mb4_unicode_ci) [PDOException] SQLSTATE[42S01]: Base table or view already exists: 1050 Table 'comments' already exists ``` I then ran the command again and received a different batch of errors. A third run resulted in these different errors again, so it would appear to be consistent now. ```bash tigattack@Wiki2:/var/www/bookstack$ sudo php artisan migrate ************************************** * Application In Production! * ************************************** Do you really wish to run this command? (yes/no) [no]: > y [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`) val ues (comment-create-all, Create All Comments, 2018-03-29 10:22:28, 2018-03-29 10:22:28)) [PDOException] SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'comment-create-all' for key 'permissions_name_unique' ``` Any help would be much appreciated!
OVERLORD added the 🐕 Support label 2026-02-04 21:27:46 +03:00
Author
Owner

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

Hi @tigattack,
Would you be able to list out the contents of the migrations table? (SELECT * FROM migrations;)

That way we could see what state your DB has got to.

@ssddanbrown commented on GitHub (Mar 30, 2018): Hi @tigattack, Would you be able to list out the contents of the `migrations` table? (`SELECT * FROM migrations;`) That way we could see what state your DB has got to.
Author
Owner

@tigattack commented on GitHub (Mar 30, 2018):

Yo @ssddanbrown, cheers for your help, here's the output:

mysql> select * from migrations;
+--------------------------------------------------+-------+
| migration                                        | batch |
+--------------------------------------------------+-------+
| 2014_10_12_000000_create_users_table             |     1 |
| 2014_10_12_100000_create_password_resets_table   |     1 |
| 2015_07_12_114933_create_books_table             |     1 |
| 2015_07_12_190027_create_pages_table             |     1 |
| 2015_07_13_172121_create_images_table            |     1 |
| 2015_07_27_172342_create_chapters_table          |     1 |
| 2015_08_08_200447_add_users_to_entities          |     1 |
| 2015_08_09_093534_create_page_revisions_table    |     1 |
| 2015_08_16_142133_create_activities_table        |     1 |
| 2015_08_29_105422_add_roles_and_permissions      |     1 |
| 2015_08_30_125859_create_settings_table          |     1 |
| 2015_08_31_175240_add_search_indexes             |     1 |
| 2015_09_04_165821_create_social_accounts_table   |     1 |
| 2015_09_05_164707_add_email_confirmation_table   |     1 |
| 2015_11_21_145609_create_views_table             |     1 |
| 2015_11_26_221857_add_entity_indexes             |     1 |
| 2015_12_05_145049_fulltext_weighting             |     1 |
| 2015_12_07_195238_add_image_upload_types         |     1 |
| 2015_12_09_195748_add_user_avatars               |     1 |
| 2016_01_11_210908_add_external_auth_to_users     |     1 |
| 2016_02_25_184030_add_slug_to_revisions          |     1 |
| 2016_02_27_120329_update_permissions_and_roles   |     1 |
| 2016_02_28_084200_add_entity_access_controls     |     1 |
| 2016_03_09_203143_add_page_revision_types        |     1 |
| 2016_03_13_082138_add_page_drafts                |     1 |
| 2016_03_25_123157_add_markdown_support           |     1 |
| 2016_04_09_100730_add_view_permissions_to_roles  |     1 |
| 2016_04_20_192649_create_joint_permissions_table |     1 |
| 2016_05_06_185215_create_tags_table              |     1 |
| 2016_07_07_181521_add_summary_to_page_revisions  |     1 |
| 2016_09_29_101449_remove_hidden_roles            |     1 |
| 2016_10_09_142037_create_attachments_table       |     1 |
| 2017_01_21_163556_create_cache_table             |     2 |
| 2017_01_21_163602_create_sessions_table          |     2 |
| 2017_03_19_091553_create_search_index_table      |     2 |
| 2017_04_20_185112_add_revision_counts            |     2 |
| 2017_07_02_152834_update_db_encoding_to_ut8mb4   |     3 |
+--------------------------------------------------+-------+
37 rows in set (0.01 sec)
@tigattack commented on GitHub (Mar 30, 2018): Yo @ssddanbrown, cheers for your help, here's the output: ```mysql mysql> select * from migrations; +--------------------------------------------------+-------+ | migration | batch | +--------------------------------------------------+-------+ | 2014_10_12_000000_create_users_table | 1 | | 2014_10_12_100000_create_password_resets_table | 1 | | 2015_07_12_114933_create_books_table | 1 | | 2015_07_12_190027_create_pages_table | 1 | | 2015_07_13_172121_create_images_table | 1 | | 2015_07_27_172342_create_chapters_table | 1 | | 2015_08_08_200447_add_users_to_entities | 1 | | 2015_08_09_093534_create_page_revisions_table | 1 | | 2015_08_16_142133_create_activities_table | 1 | | 2015_08_29_105422_add_roles_and_permissions | 1 | | 2015_08_30_125859_create_settings_table | 1 | | 2015_08_31_175240_add_search_indexes | 1 | | 2015_09_04_165821_create_social_accounts_table | 1 | | 2015_09_05_164707_add_email_confirmation_table | 1 | | 2015_11_21_145609_create_views_table | 1 | | 2015_11_26_221857_add_entity_indexes | 1 | | 2015_12_05_145049_fulltext_weighting | 1 | | 2015_12_07_195238_add_image_upload_types | 1 | | 2015_12_09_195748_add_user_avatars | 1 | | 2016_01_11_210908_add_external_auth_to_users | 1 | | 2016_02_25_184030_add_slug_to_revisions | 1 | | 2016_02_27_120329_update_permissions_and_roles | 1 | | 2016_02_28_084200_add_entity_access_controls | 1 | | 2016_03_09_203143_add_page_revision_types | 1 | | 2016_03_13_082138_add_page_drafts | 1 | | 2016_03_25_123157_add_markdown_support | 1 | | 2016_04_09_100730_add_view_permissions_to_roles | 1 | | 2016_04_20_192649_create_joint_permissions_table | 1 | | 2016_05_06_185215_create_tags_table | 1 | | 2016_07_07_181521_add_summary_to_page_revisions | 1 | | 2016_09_29_101449_remove_hidden_roles | 1 | | 2016_10_09_142037_create_attachments_table | 1 | | 2017_01_21_163556_create_cache_table | 2 | | 2017_01_21_163602_create_sessions_table | 2 | | 2017_03_19_091553_create_search_index_table | 2 | | 2017_04_20_185112_add_revision_counts | 2 | | 2017_07_02_152834_update_db_encoding_to_ut8mb4 | 3 | +--------------------------------------------------+-------+ 37 rows in set (0.01 sec) ```
Author
Owner

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

Thanks @tigattack,
You could try reverting the changes in that migration and try migrating again.

Backup beforehand then run the following:

DROP TABLE comments;
DELETE FROM role_permissions WHERE name like "comment-%";

Then try migrating.

Keep an eye out for any errors on first migrate run afterwards and post here if any.

@ssddanbrown commented on GitHub (Mar 30, 2018): Thanks @tigattack, You could try reverting the changes in that migration and try migrating again. Backup beforehand then run the following: ```sql DROP TABLE comments; DELETE FROM role_permissions WHERE name like "comment-%"; ``` Then try migrating. Keep an eye out for any errors on first migrate run afterwards and post here if any.
Author
Owner

@tigattack commented on GitHub (Mar 30, 2018):

Fantastic, migration was successful. Thank you very much @ssddanbrown, that sorted it.

@tigattack commented on GitHub (Mar 30, 2018): Fantastic, migration was successful. Thank you very much @ssddanbrown, that sorted it.
Author
Owner

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

@tigattack That's awesome, Glad I could help.

@ssddanbrown commented on GitHub (Mar 30, 2018): @tigattack That's awesome, Glad I could help.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/BookStack#617