Skip to content

Instantly share code, notes, and snippets.

@jasonwbarnett
Created June 20, 2014 17:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jasonwbarnett/1f15bd7035f59907b097 to your computer and use it in GitHub Desktop.
Save jasonwbarnett/1f15bd7035f59907b097 to your computer and use it in GitHub Desktop.
This was used to convert component default assignee values if the user has example.com in their address
#!/bin/bash
components=$(mysql -BNe 'select * from bugs.components;' | tr '\t' '|')
AMY_ID=277
IFS=$'\n'
for x in $components;do
component_id=$(echo ${x} | awk -F\| '{print $1}')
default_assignee_id=$(echo ${x} | awk -F\| '{print $4}')
default_assignee_email=$(mysql -BNe "select login_name from bugs.profiles where userid = '${default_assignee_id}';")
example_email=$(echo ${default_assignee_email} | egrep -o 'example\.com')
[[ -n ${example_email} ]] && example_email=true || example_email=false
if [[ ${example_email} == "true" ]];then
echo "Updated component id ${component_id} initialowner from ${default_assignee_id} to ${AMY_ID}"
mysql -e "UPDATE bugs.components SET initialowner = '${AMY_ID}' WHERE id='${component_id}';"
fi
#mysql -e "UPDATE bugs.components SET initialqacontact = NULL WHERE id='${component_id}';"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment