After encountering some issues with the migrate module, I decided to rewrite it all from scratch with this module. So far everything goes smooth, however there are some customizations that I am not sure how to accomplish:
I want to do some additional joins within the User migration class, in order to only import users with a certain role. How would I go from there? Is it possible to directly modify the $query object?
The joins I want to accomplish are (this snippet originates from the original migrate code):
$query->join(SOURCE_DATABASE .'.users_roles', 'ur', 'u.uid = ur.uid');
$query->join(SOURCE_DATABASE .'.role', 'r', 'ur.rid = r.rid');
$query->orderBy('u.uid', 'ASC');
Comments
Comment #1
mixhael commentedI tried the following without luck:
Creating a new Class that extends from Drupal6UserMigration:
and reflect that in the .module file:
Nothing changes, drush ms still says all of my users are awaiting migration
Comment #2
mixhael commentedAlso tried the following without luck (meaning `drush ms` still states that all my users are awaiting migration):
Comment #3
mixhael commentedexcuse me, forgot to clear cache. The above works for me :)
Comment #4
mikeryanYou're moving too fast for me;)... Actually, since all the migrate_d2d classes use a query() method to define their queries, the clean way to modify the query is:
Comment #5
mixhael commentedWell, you are still responding quite fast :)
Nevertheless, in both cases it doesn't work. When running `drush mi User`, it gives me the following:
215 is the total amount of users that is in the database.
With the code I wrote myself `drush ms` tells me with the modified query that there are 20 waiting to be migrated....
With the modifications I made according to your recommendation it tells me there are still 215:
Still in both cases `drush mi User` tells me:
Comment #6
mixhael commentedThis is what my class looks like btw:
Comment #7
mixhael commentedI think the basic problem must be somewhere else. Even when trying to do a basic mapping `drush mi User` gives me the following:
Any clue why this might be the case?
Still, the question arises that when I add this:
to my class that `drush ms` keeps on saying that 215 users are awaiting migration, instead of 20... It seems the query has still not been modified
Comment #8
mixhael commentedforgot to set it to active
Comment #9
mixhael commentedGetting towards the root-problem, but still not see what is exactly going wrong. When I click on the User migration in Migrate UI, it tells me the destination of the User Migration is the 'Profile node'
On the 'Destination' tab:
The relevant code in my .module file looks as follows:
And the relevant code in node.inc:
Comment #10
mikeryanOK, one thing that's going to cause trouble is joining to users_roles. It's essential for a migration source query to return one row per item (user, node, etc.) to import, and by doing an inner join to users_roles you'll get X rows per user, where X is the number of rows in users_roles for each user. You're not adding any fields from those tables, or conditions on those tables, so I don't see what you're trying to accomplish here.
Another issue is that you're deriving ProfileMigration from DrupalUser6Migration... but it looks like you have a separate issue open for that.
Comment #11
mixhael commentedI want to make sure only users are imported that have are not regular authenticated), but have one or more custom defined roles. Good point, will look into improving this query.
But how come the User migration says it's migrating into the destination of a Profile node?
Comment #12
mixhael commentedNevermind, all fixed now by adding a $query->distinct();
The migration into a profile node was a conflict with another issue.