BookStack: [Support Request]: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'bookstackapp.mfa_values' doesn't exist
Attempted Debugging
- I have read the debugging page
Searched GitHub Issues
- I have searched GitHub for the issue.
Describe the Scenario
After installing Bookstack I’m open http://localhost:6875/ and get a blank page. I’m enable APP_DEBUG=true and get
Illuminate\Database\QueryException
SQLSTATE[42S02]: Base table or view not found: 1146 Table 'bookstackapp.mfa_values' doesn't exist (SQL: select exists(select * from `mfa_values` where `mfa_values`.`user_id` = 1 and `mfa_values`.`user_id` is not null) as `exists`)
Next, I go to container and run php artisan migrate:status and get
+------+---------------------------------------------------+-------+
| Ran? | Migration | Batch |
+------+---------------------------------------------------+-------+
| Yes | 2014_10_12_000000_create_users_table | 1 |
| Yes | 2014_10_12_100000_create_password_resets_table | 1 |
| Yes | 2015_07_12_114933_create_books_table | 1 |
| Yes | 2015_07_12_190027_create_pages_table | 1 |
| Yes | 2015_07_13_172121_create_images_table | 1 |
| Yes | 2015_07_27_172342_create_chapters_table | 1 |
| Yes | 2015_08_08_200447_add_users_to_entities | 1 |
| Yes | 2015_08_09_093534_create_page_revisions_table | 1 |
| Yes | 2015_08_16_142133_create_activities_table | 1 |
| Yes | 2015_08_29_105422_add_roles_and_permissions | 1 |
| Yes | 2015_08_30_125859_create_settings_table | 1 |
| Yes | 2015_08_31_175240_add_search_indexes | 1 |
| Yes | 2015_09_04_165821_create_social_accounts_table | 1 |
| Yes | 2015_09_05_164707_add_email_confirmation_table | 1 |
| Yes | 2015_11_21_145609_create_views_table | 1 |
| Yes | 2015_11_26_221857_add_entity_indexes | 1 |
| Yes | 2015_12_05_145049_fulltext_weighting | 1 |
| Yes | 2015_12_07_195238_add_image_upload_types | 1 |
| Yes | 2015_12_09_195748_add_user_avatars | 1 |
| Yes | 2016_01_11_210908_add_external_auth_to_users | 1 |
| Yes | 2016_02_25_184030_add_slug_to_revisions | 1 |
| Yes | 2016_02_27_120329_update_permissions_and_roles | 1 |
| Yes | 2016_02_28_084200_add_entity_access_controls | 1 |
| Yes | 2016_03_09_203143_add_page_revision_types | 1 |
| Yes | 2016_03_13_082138_add_page_drafts | 1 |
| Yes | 2016_03_25_123157_add_markdown_support | 1 |
| Yes | 2016_04_09_100730_add_view_permissions_to_roles | 1 |
| Yes | 2016_04_20_192649_create_joint_permissions_table | 1 |
| Yes | 2016_05_06_185215_create_tags_table | 1 |
| Yes | 2016_07_07_181521_add_summary_to_page_revisions | 1 |
| Yes | 2016_09_29_101449_remove_hidden_roles | 1 |
| Yes | 2016_10_09_142037_create_attachments_table | 1 |
| Yes | 2017_01_21_163556_create_cache_table | 1 |
| Yes | 2017_01_21_163602_create_sessions_table | 1 |
| Yes | 2017_03_19_091553_create_search_index_table | 1 |
| Yes | 2017_04_20_185112_add_revision_counts | 1 |
| Yes | 2017_07_02_152834_update_db_encoding_to_ut8mb4 | 1 |
| Yes | 2017_08_01_130541_create_comments_table | 1 |
| Yes | 2017_08_29_102650_add_cover_image_display | 1 |
| Yes | 2018_07_15_173514_add_role_external_auth_id | 1 |
| Yes | 2018_08_04_115700_create_bookshelves_table | 1 |
| No | 2019_07_07_112515_add_template_support | |
| No | 2019_08_17_140214_add_user_invites_table | |
| No | 2019_12_29_120917_add_api_auth | |
| No | 2020_08_04_111754_drop_joint_permissions_id | |
| No | 2020_08_04_131052_remove_role_name_field | |
| No | 2020_09_19_094251_add_activity_indexes | |
| No | 2020_09_27_210059_add_entity_soft_deletes | |
| No | 2020_09_27_210528_create_deletions_table | |
| No | 2020_11_07_232321_simplify_activities_table | |
| No | 2020_12_30_173528_add_owned_by_field_to_entities | |
| No | 2021_01_30_225441_add_settings_type_column | |
| No | 2021_03_08_215138_add_user_slug | |
| No | 2021_05_15_173110_create_favourites_table | |
| No | 2021_06_30_173111_create_mfa_values_table | |
| No | 2021_07_03_085038_add_mfa_enforced_to_roles_table | |
| No | 2021_08_28_161743_add_export_role_permission | |
| No | 2021_09_26_044614_add_activities_ip_column | |
+------+---------------------------------------------------+-------+
Next I try to run php artisan migrate get
Illuminate\Database\QueryException
SQLSTATE[HY000] [2002] Connection refused (SQL: alter table `pages` add index `pages_template_index`(`template`))
at vendor/laravel/framework/src/Illuminate/Database/Connection.php:703
699▕ // If an exception occurs when attempting to run a query, we'll format the error
700▕ // message to include the bindings with SQL, which will make this exception a
701▕ // lot more helpful to the developer instead of just the database's errors.
702▕ catch (Exception $e) {
➜ 703▕ throw new QueryException(
704▕ $query, $this->prepareBindings($bindings), $e
705▕ );
706▕ }
707▕ }
+18 vendor frames
19 database/migrations/2019_07_07_112515_add_template_support.php:20
Illuminate\Support\Facades\Facade::__callStatic()
+21 vendor frames
41 artisan:37
Illuminate\Foundation\Console\Kernel::handle()
After run php artisan migrate again get
Migrating: 2019_07_07_112515_add_template_support
Illuminate\Database\QueryException
SQLSTATE[42S21]: Column already exists: 1060 Duplicate column name 'template' (SQL: alter table `pages` add `template` tinyint(1) not null default '0')
at vendor/laravel/framework/src/Illuminate/Database/Connection.php:703
699▕ // If an exception occurs when attempting to run a query, we'll format the error
700▕ // message to include the bindings with SQL, which will make this exception a
701▕ // lot more helpful to the developer instead of just the database's errors.
702▕ catch (Exception $e) {
➜ 703▕ throw new QueryException(
704▕ $query, $this->prepareBindings($bindings), $e
705▕ );
706▕ }
707▕ }
+9 vendor frames
10 database/migrations/2019_07_07_112515_add_template_support.php:20
Illuminate\Support\Facades\Facade::__callStatic()
+21 vendor frames
32 artisan:37
Illuminate\Foundation\Console\Kernel::handle()
Please help. Thanx.
Exact BookStack Version
v21.11.3
Log Content
laravel.log error.log error.log
PHP Version
7.4.26
Hosting Environment
Docker on Windows. Bookstack is installed with LinuxServer.io Docker image.
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 20 (8 by maintainers)
For anyone that’s trying to test BookStack with Docker and is unable to make it work, this could be of help. I just launched a fresh instance of Docker Bookstack and found a similar issue. In my case, I wasn’t able to login to the application, so I decided to run
php artisan migrateto fix the database schema, however the following error appeared:To solve it, I accessed the DB instance, opened MySQL and ran the following query to remove the column that already existed:
It seems as well that Laravel actually caches the config file, so I had to clean it as well because after removing the duplicated column and re-running the migration, I got another error:
I fixed it clearing the cache of the configuration files with:
php artisan config:clearFinally run the migration:
php artisan migrateIt should succeed now. I was able to access Bookstack using the default credentials
admin@admin.comandpassword.Gotcha, makes sense I must fall into that category. I’m running into all the issues above from a clean install.
edit: Yeah, I was able to get it working using the workaround in the linked thread above. Thanks for all your hard work.
Not sure if it’s only a Windows issue. The problem occurs even on WSL2, where Docker is running within the WSL instance, rather than directly on Windows.
I see… obviously it’s a windows issue. We would host it properly on Linux anyway. Sorry to bother and thank you.
@ssddanbrown
This is also a clean install from docker on Debian 11.2.0 amd64
This may be an issue with the way the linuxserver bookstack image is handling the install. Will go look there when I get a chance and open a ticket in whichever repository is causing the issue when i find out
and
ALTER TABLE pages DROP COLUMN template;working. Thank you! I wonder why this happened on a clean bookstack installation. There may be an error in the container image…