I'll keep it short, I need to assign/add multiple users to the same project in Mantis (over 100+).
To create these accounts in bulk, I installed a plugin on the EC2 instance running Mantis (with the database installed directly on the same EC2) that allows importing a .csv
list of users. That worked fine without any issues.
Now, I need to add all these users to the same project, and I was wondering if there's a way to do this in bulk.
While searching around, I only found that you can add multiple users by selecting them from the user list with CTRL
, but they still need to be selected one by one.
I was thinking of creating an .sql
script to run on the MySQL database to handle this directly, but I’m not even sure if that would work; plus, I’d prefer something slightly less "risky" or prone to errors.
Can anyone help? Thanks!
I'll keep it short, I need to assign/add multiple users to the same project in Mantis (over 100+).
To create these accounts in bulk, I installed a plugin on the EC2 instance running Mantis (with the database installed directly on the same EC2) that allows importing a .csv
list of users. That worked fine without any issues.
Now, I need to add all these users to the same project, and I was wondering if there's a way to do this in bulk.
While searching around, I only found that you can add multiple users by selecting them from the user list with CTRL
, but they still need to be selected one by one.
I was thinking of creating an .sql
script to run on the MySQL database to handle this directly, but I’m not even sure if that would work; plus, I’d prefer something slightly less "risky" or prone to errors.
Can anyone help? Thanks!
Share Improve this question asked Feb 11 at 12:06 samsepiolsamsepiol 336 bronze badges1 Answer
Reset to default 0Ok, so in the end, I found this solution.
I don’t know if it’s the best, but it was the only one that came to mind and worked on the first try without causing too many issues.
- I connected to the machine and created a .csv file, copying the list of usernames into a column.
- Then, I connected to the database and noted down the necessary details for the script:
- The table containing the list of projects (and their respective IDs).
- The table containing the list of users (and their respective IDs).
- The name of the table that associates users with projects.
- Using awk, I generated the script with the info taken from the DB:
awk '{print "INSERT INTO mantis-proj-userlist-table (project_id, user_id, access_level) SELECT project-id, id, 55 FROM users-table WHERE username = \x27" $1 "\x27;"}' user_list_file.csv > bulk_assign_project.sql
- 55 in the command represents the Developer access level.
- Checking the generated file, it should contain the rows for each user, something like this:
INSERT INTO user-project-association-table (project_id, user_id, access_level)
SELECT project-number, id, 55 FROM users-table WHERE username = 'actual-user-name';
- Then I ran the script with:
mysql -u mantis_username -p database_name < bulk_assign_project.sql
- Finally, I connected to the DB to verify that the addition was successful using a simple
SELECT
filtering by the project ID.
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745213103a4616960.html
评论列表(0条)