- check out the desired tag/branch of this repo
- scp the contents of the users directory to the target system. Sepcifically, you will need export_users.rb and everything under the exporters directory
- ssh to the 1.7 system
- $ sudo -Hu primero bash
- $ cd ~/application/
- $ RAILS_ENV=production bundle exec rails r /home/ubuntu/users/export_users.rb
(This will generate user seed files in a seed-files directory)
If you are changing a locale from v1 to v2, for example, changing locale ar to ar-IQ, then you can pass optional
flags to the export_users script to reflect the locale change on the users' locale in the exported data
The format is: $ RAILS_ENV=production bundle exec rails r /home/ubuntu/users/export_users.rb :
Example:
$ rails r ./tmp/users/export_users.rb ar:ar-IQ
This exports users, if any of those users has a locale of ar, it changes it to ar-IQ
Example 2:
$ rails r ./tmp/users/export_users.rb ar:ar-IQ:ku:ku-IQ
This exports users, changing ar to ar-IQ and ku to ku-IQ
- exit back to the ubuntu user
- $ cd /srv/primero/application
- $ sudo tar czvf seed-files.tar.gz seed-files
- $ cd
- $ sudo mv /srv/primero/application/seed-files.tar.gz .
$ tar -xzvf seed-files.tar.gz
- If you haven't already, check out the desired tag/branch of this repo
- scp the import_data.rb script to the target system.
- the seed-files directory should be at the same level as the import_users.rb script Ex: /home/ubuntu/import_users.rb /home/ubuntu/seed-files/*
- $ docker ps (to get the name of the application image)
- $ docker cp seed-files primero_application_1:/srv/primero/application/tmp/. (where primero_application_1 is the image name)
- $ docker cp import_users.rb primero_application_1:/srv/primero/application/tmp/.
- $ sudo docker exec -it primero_application_1 bash (to access the docker container)
- $ cd /srv/primero/application
- $ rails r ./tmp/import_users.rb > import_users.out
There is a many to many relationship between Users and User Groups. There is a link table user_groups_users to manage this association. If during user migration testing you delete all users and re-import, this association can get out of sync. Also, if you delete the UserGroups table and reload the configuration, this association can get out of sync. It is important that your load_configuration script updates UserGroups without first deleting them. To resolve:
- From rails console in the application container:
- Delete all rows from user_groups_users table:
$ User.connection.execute('Delete from user_groups_users')
- Delete all rows from the users table:
$ User.delete_all
- Delete all rows from user_groups_users table:
- From command line in the application container:
- Re-run the user import
Prior to running migration, generate a list of users that will have problems being migrated to v2. This report creates a .csv file for each of these issues
- users with multiple roles
- users with blank or bogus roles
- users with no location
- users with blank or bogus user_group_ids
- users with no email
- users with duplicate emails
- users that are disabled (These users aren't a problem, it will be used later when re-enabling users in v2) These .csv files can be combined into a spreadsheet to be given to the users for review
The reset_passwords.rb script is used to reset user passwords
- To reset to a randdom password and sends the reset password email $ rails r ./tmp/users/reset_passwords.rb 'true'
- To reset password to 'test123' and do not send the reset password email $ rails r ./tmp/users/reset_passwords.rb 'true'
Prior to running the migration, get a list of users that are disabled in v1 production. The list of disabled users is included in the invalid_users_report. The update_disabled.rb script is used to update the value of user.disabled to true or false After the migration has completed, this script should be run to disable all users (set user.disabled = true) Then, manually re-enable (user.disabled = false) a designated test user to be used for testing/verification When verification is complete and you are ready to go live, run this script to re-enable all users (user.disabled = false) except for those users that were already disabled in v1 production.
- To disable all users $ rails r ./tmp/users/update_disabled.rb 'true'
- To enable all users except the ones previously disabled in v1 prod (in this example, primero, primero_cp, primero_mgr_cp) $ rails r ./tmp/users/update_disabled.rb 'false' 'primero||primero_cp||primero_mgr_cp'