Drupal 7 Migration Questions

Has anyone imported Drupal 7 passwords into Discourse? This is one area where I’m stuck on my migration.

I found this plugin and this info, but am not sure how to modify it for Drupal 7.

If I don’t migrate the passwords (leaving the password_hash and salt fields as nil), will users still be able to request new passwords? I’m a little worried about that in either case, because there are 20,000 users, and they will start getting summary emails from Discourse, which might send a lot of people to the site at once. If there is a bug with passwords or resetting them, things might get chaotic.

Temporary email address were saved during the last test import – something like tmpemail111@example.com. I don’t know why the first part of that email address was used for the name field and why the email field is blank. The email address does appear on the site itself for this user.

Is enough data included here in this sample user to have the new site run correctly in production?

=> [#<User:0x0000000723ab23
  id: 197,
  username: "SomeUser",
  created_at: Sat, 30 Apr 2012 13:17:11 UTC +00:00,
  updated_at: Mon, 01 Oct 2017 10:19:37 UTC +00:00,
  name: "Tmpemail111", 
  seen_notification_id: 0,
  last_posted_at: nil,
  email: nil,
  password_hash: nil,
  salt: nil,
  active: true,
  username_lower: "someuser",
  last_seen_at: Sat, 30 Apr 2012 13:17:11 UTC +00:00,
  admin: false,
  last_emailed_at: Mon, 02 Oct 2017 23:19:33 UTC +00:00,
  trust_level: 1,
  approved: false,
  approved_by_id: nil,
  approved_at: nil,
  previous_visit_at: nil,
  suspended_at: nil,
  suspended_till: nil,
  date_of_birth: nil,
  views: 0,
  flag_level: 0,
  ip_address: nil,
  moderator: false,
  blocked: false,
  title: nil,
  uploaded_avatar_id: nil,
  locale: nil,
  suspended_at: nil,
  suspended_till: nil,
  date_of_birth: nil,
  views: 0,
  flag_level: 0,
  ip_address: nil,
  moderator: false,
  blocked: false,
  title: nil,
  uploaded_avatar_id: nil,
  locale: nil,
  primary_group_id: nil,
  registration_ip_address: nil,
  trust_level_locked: false,
  staged: false,
  first_seen_at: nil>]

Yes, and having your users change to decent passwords isn’t a bad idea anyway.

Yeah. You might disable summary emails, either for the whole site, or, do a rails console command to turn it off for each user and provide instructions for turning it on if they want it.

If the email addresses are wrong, and they can’t receive a password reset email , then they can’t reclaim their accounts. Even if they could log in, they couldn’t change their email address,

What importer did you use? It sounds broken. Are the email addresses and names not in the database?

1 Like

It’s a custom importer that I’m working on, based on the drupal.rb (Drupal 7) importer that comes with Discourse. The temporary email is just for the test runs – just to be sure that my laptop doesn’t accidentally notify all the users to visit localhost:3000 while I’m working on it. :slight_smile:

I’ll switch this out for the real email address when I run the final import:

create_users(@client.query(q)) do |row|
  { id: row['id'], username: row['name'], email: "tmpemail#{row['id']}@my_domain.com", created_at: Time.zone.at(row['created']) }
end

Yes, and having your users change to decent passwords isn’t a bad idea anyway.

I think that some of them are going to disagree, but maybe that’s best.

The user profile can display the temporary email address:

but the database shows nil for email and the first part of the email address ended up in name, which shouldn’t happen.

Ekrankopio de 2017-10-06 15-11-05

You probably don’t have your laptop configured to send email, but for the reasons you outline I put something like this in all of the importers that I touch:

  SiteSetting.disable_emails = true
  SiteSetting.allow_index_in_robots_txt=nil
  SiteSetting.login_required=true

Oh. Yeah. Email’s not stored in the user table anymore. If you go to /admin/users you can see them.

If you don’t include a name, it uses their username.

See this post for a code sample that pulls email addresses.

1 Like

Thanks. I can view the email addresses when visiting the individual user profiles, but they don’t appear in the list, except for the admin user I created in the terminal. Is that a bug?

No. Not a bug. Emails are private. There is a show emails button at the top right of /admin/users.

1 Like

@pfaffman - will that snippet work if I drop it within the import class something like this? Or is it better to run in the Rails console?

    class ImportScripts::Drupal < ImportScripts::Base

      SiteSetting.disable_emails = true
      SiteSetting.allow_index_in_robots_txt = nil
      SiteSetting.login_required = true

      ##
      # TODO: the MySQL database name gets loaded here
      #
      DRUPAL_DB = ENV['DRUPAL_DB'] || "tmp_deleteme"

      ##
      # The `VID` is a vocabulary ID.
      #
      # <snip> ...
    end

I usually add it to the initialize function.

1 Like

Thanks! Just about ready to run it for the live site. :slight_smile:

1 Like