This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.
Hello everyone, I'm attempting to install the RainLab.User plugin in an October installation running on AWS with an SQL Server database. When I install I get the following error message:
Update failed
"SQLSTATE[42S01]: [Microsoft][ODBC Driver 17 for SQL Server][SQL Server]There is already an object named 'user_group' in the database. (SQL: alter table "users_groups" add constraint "user_group" primary key ("user_id", "user_group_id"))" on line 664 of /var/www/orders.springcreekgardens.net/public/vendor/laravel/framework/src/Illuminate/Database/Connection.php
I've searched for solutions about this and any similar issues I'm finding are a few years old. Does anyone have any current info for running OctoberCMS with an SQL Server database? Can this issue be resolved and if so, how?
Thanks for any help.
The most likely explanation is that there was already a "users_groups" table with its "user_group" primary key (constraint in SQL Server parlance) present when you tried to install the RainLab.User plugin.
Try running a php artisan plugin:refresh RainLab.User
from the application root.
(hopefully the "down()" migration method will cleanup the database before trying to reinstall the plugin)
Last updated
Thanks @mjauvin I just tried that and unfortunately it didn't work.
After attempting that refresh I ran php artisan plugin:remove RainLab.User
and confirmed that all of the user(s) tables were removed.
Then I tried:
- Installing through the Admin plugin installer, same error.
- Repeated process of uninstalling via command line.
- Confirmed no table users_groups existed.
- Attempted install via command line with
php artisan plugin:install RainLab.User
and am getting the same error with a little more information.
In Connection.php line 664:
SQLSTATE[42S01]: [Microsoft][ODBC Driver 17 for SQL Server][SQL Server]There is already an object named 'user_group' in the data base. (SQL: alter table "users_groups" add constraint "user_group" primary key ("user_id", "user_group_id"))
In PDOStatement.php line 107:
SQLSTATE[42S01]: [Microsoft][ODBC Driver 17 for SQL Server][SQL Server]There is already an object named 'user_group' in the data base.
In PDOStatement.php line 105:
SQLSTATE[42S01]: [Microsoft][ODBC Driver 17 for SQL Server][SQL Server]There is already an object named 'user_group' in the data base.
I also noticed that after this error is encountered there are a few tables that the plugin install has created:
- rainlab_user_mail_blockers
- user_throttle
- users
But no users_groups table. The closest thing is backend_users_groups though I don't see why that table would cause a problem.
Yeah, it's a strange error that really doesn't make any sense.
Thank you for your attempt to help, I hope someone out there knows of a solution. I really need one so I can get this project moving.
Looks like the problem might be that the backend_users_groups table and the RainLab.User users_groups tables both have a combined primary key with the same name of user_groups https://github.com/octobercms/october/blob/develop/modules/backend/database/migrations/2013_10_01_000003_Db_Backend_Users_Groups.php#L14 https://github.com/rainlab/user-plugin/blob/master/updates/create_user_groups_table.php#L26.
My guess is that it's only a problem in SQL Server because it might be storing those combined primary key names in a global context rather than scoped per table as a more sane database engine might do.
My recommendation would be rename user_group
to rainlab_user_group
here https://github.com/rainlab/user-plugin/blob/master/updates/create_user_groups_table.php#L26.
1-7 of 7