SQLSTATE[42000]: Syntax error or access violation: 1091 Can't DROP 'name'; check that column/key exists (SQL: alter table roles drop name) #2155

Closed
opened 2026-02-05 03:08:22 +03:00 by OVERLORD · 5 comments
Owner

Originally created by @csjjpm on GitHub (Mar 14, 2021).

When I do 'php artisan migrate' I get this error

Migrating: 2020_08_04_111754_drop_joint_permissions_id
Migrated: 2020_08_04_111754_drop_joint_permissions_id (1.59 seconds)
Migrating: 2020_08_04_131052_remove_role_name_field

Illuminate\Database\QueryException : SQLSTATE[42000]: Syntax error or access violation: 1091 Can't DROP 'name'; check that column/key exists (SQL: alter table roles drop name)

at /usr/local/www/BookStack/vendor/laravel/framework/src/Illuminate/Database/Connection.php:669
665| // If an exception occurs when attempting to run a query, we'll format the error
666| // message to include the bindings with SQL, which will make this exception a
667| // lot more helpful to the developer instead of just the database's errors.
668| catch (Exception $e) {

669| throw new QueryException(
670| $query, $this->prepareBindings($bindings), $e
671| );
672| }
673|

Originally created by @csjjpm on GitHub (Mar 14, 2021). When I do 'php artisan migrate' I get this error Migrating: 2020_08_04_111754_drop_joint_permissions_id Migrated: 2020_08_04_111754_drop_joint_permissions_id (1.59 seconds) Migrating: 2020_08_04_131052_remove_role_name_field Illuminate\Database\QueryException : SQLSTATE[42000]: Syntax error or access violation: 1091 Can't DROP 'name'; check that column/key exists (SQL: alter table `roles` drop `name`) at /usr/local/www/BookStack/vendor/laravel/framework/src/Illuminate/Database/Connection.php:669 665| // If an exception occurs when attempting to run a query, we'll format the error 666| // message to include the bindings with SQL, which will make this exception a 667| // lot more helpful to the developer instead of just the database's errors. 668| catch (Exception $e) { > 669| throw new QueryException( 670| $query, $this->prepareBindings($bindings), $e 671| ); 672| } 673|
Author
Owner

@csjjpm commented on GitHub (Mar 16, 2021):

If I create a blank database and import my SQL backup I get this error on the webpage.
'
UnexpectedValueException
The stream or file "/usr/local/www/BookStack/storage/logs/laravel.log" could not be opened in append mode: failed to open stream: Permission denied
'
If I try the migrate command I get this error:
'

yes

Migrating: 2020_08_04_111754_drop_joint_permissions_id
Migrated: 2020_08_04_111754_drop_joint_permissions_id (2.14 seconds)
Migrating: 2020_08_04_131052_remove_role_name_field

Illuminate\Database\QueryException : SQLSTATE[42000]: Syntax error or access violation: 1091 Can't DROP 'name'; check that column/key exists (SQL: alter table roles drop name)

at /usr/local/www/BookStack/vendor/laravel/framework/src/Illuminate/Database/Connection.php:669
665| // If an exception occurs when attempting to run a query, we'll format the error
666| // message to include the bindings with SQL, which will make this exception a
667| // lot more helpful to the developer instead of just the database's errors.
668| catch (Exception $e) {

669| throw new QueryException(
'

@csjjpm commented on GitHub (Mar 16, 2021): If I create a blank database and import my SQL backup I get this error on the webpage. ' UnexpectedValueException The stream or file "/usr/local/www/BookStack/storage/logs/laravel.log" could not be opened in append mode: failed to open stream: Permission denied ' If I try the migrate command I get this error: ' > yes Migrating: 2020_08_04_111754_drop_joint_permissions_id Migrated: 2020_08_04_111754_drop_joint_permissions_id (2.14 seconds) Migrating: 2020_08_04_131052_remove_role_name_field Illuminate\Database\QueryException : SQLSTATE[42000]: Syntax error or access violation: 1091 Can't DROP 'name'; check that column/key exists (SQL: alter table `roles` drop `name`) at /usr/local/www/BookStack/vendor/laravel/framework/src/Illuminate/Database/Connection.php:669 665| // If an exception occurs when attempting to run a query, we'll format the error 666| // message to include the bindings with SQL, which will make this exception a 667| // lot more helpful to the developer instead of just the database's errors. 668| catch (Exception $e) { > 669| throw new QueryException( '
Author
Owner

@ssddanbrown commented on GitHub (Mar 17, 2021):

Hi @csjjpm,

The stream or file "/usr/local/www/BookStack/storage/logs/laravel.log" could not be opened in append mode: failed to open stream: Permission denied

This would indicate the webserver user does not have permission to write to the logs file when an error has occured. You'll need to review permissions set on the storage/, bootstap/cache and public/uploads folders.

Illuminate\Database\QueryException : SQLSTATE[42000]: Syntax error or access violation: 1091 Can't DROP 'name'; check that column/key exists (SQL: alter table roles drop name)

This would occur if you the migrations table has become out of sync with the database schema. Have you previously made manual edits to the database to get around previous errors? Or made edits to the migrations table at all?

@ssddanbrown commented on GitHub (Mar 17, 2021): Hi @csjjpm, > The stream or file "/usr/local/www/BookStack/storage/logs/laravel.log" could not be opened in append mode: failed to open stream: Permission denied This would indicate the webserver user does not have permission to write to the logs file when an error has occured. You'll need to review permissions set on the `storage/`, `bootstap/cache` and `public/uploads` folders. > Illuminate\Database\QueryException : SQLSTATE[42000]: Syntax error or access violation: 1091 Can't DROP 'name'; check that column/key exists (SQL: alter table roles drop name) This would occur if you the migrations table has become out of sync with the database schema. Have you previously made manual edits to the database to get around previous errors? Or made edits to the `migrations` table at all?
Author
Owner

@csjjpm commented on GitHub (Mar 18, 2021):

Hi,
I gave my www user full write access to those folders as per instructions.

I have not touched the database schema, I have made no manual changes.

Thanks
Paul

@csjjpm commented on GitHub (Mar 18, 2021): Hi, I gave my www user full write access to those folders as per instructions. I have not touched the database schema, I have made no manual changes. Thanks Paul
Author
Owner

@csjjpm commented on GitHub (Mar 18, 2021):

Hi,
although the folders had rwx the log file didn't. I have fixed that so the laravel.log error doesn't exist. Now I have this error after logging in.

Illuminate\Database\QueryException
SQLSTATE[42S22]: Column not found: 1054 Unknown column 'type' in 'field list' (SQL: insert into `activities` (`type`, `user_id`, `detail`, `updated_at`, `created_at`) values (auth_login, 3, (3) Paul, 2021-03-18 08:19:07, 2021-03-18 08:19:07))
@csjjpm commented on GitHub (Mar 18, 2021): Hi, although the folders had rwx the log file didn't. I have fixed that so the laravel.log error doesn't exist. Now I have this error after logging in. ``` Illuminate\Database\QueryException SQLSTATE[42S22]: Column not found: 1054 Unknown column 'type' in 'field list' (SQL: insert into `activities` (`type`, `user_id`, `detail`, `updated_at`, `created_at`) values (auth_login, 3, (3) Paul, 2021-03-18 08:19:07, 2021-03-18 08:19:07)) ```
Author
Owner

@ssddanbrown commented on GitHub (Jul 26, 2022):

Since the last comment on this issue is relatively old I'm going to close this. If the issue remains and is something you still require to be fixed please open a new issue, referencing this one.

@ssddanbrown commented on GitHub (Jul 26, 2022): Since the last comment on this issue is relatively old I'm going to close this. If the issue remains and is something you still require to be fixed please open a new issue, referencing this one.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/BookStack#2155