We have an existing Drupal site that has a requirement to inherit about 10k users into, and we've been able to gather most of this data through CSV exports on the Database, and Views Export/VBO. What we have is two CSVs, one with usernames, password hashes, UIDs; the other with user field data and a UID to join/union the data during import. There are differences between the Field structure between the site data we inherited and the new site, so new data relationships will need to be established during the import, ruling out a direct port of the existing Database records.
I have no issues writing a Drush script that will import all the users with a joined CSV. What I am wondering is if its possible to import the user records, complete with the password strings within the Drupal User space. Looking at the user_save() method its not clear as if I can define the User ID, or password hash. And we have a lot of logic implemented that depends upon this
So the approach I have in my head is this:
- Use SQL IN FILE to import the baseline minimum data to establish users in Drupal's users table: Username, Password Hash, created date, changed date, etc...
- Use a second drush script to iterate through the field data, and update the user records with user_save() off UID.
Is there another approach I can use that's strictly Drush based? This assumes that the data I import will be with a Unioned CSV file. Not being able to adjust the UID probably means this isn't possible, but its worth asking.