# Drupal 7 Migration Questions

**URL:** https://meta.discourse.org/t/drupal-7-migration-questions/71539
**Category:** Development
**Created:** [October 6, 2017, 6:17pm UTC](https://meta.discourse.org/t/drupal-7-migration-questions/71539 "2017-10-06T18:17:04Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![j127](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/j127/32/79093_2.png) [@j127](https://meta.discourse.org/u/j127)
#### Post date: [October 6, 2017, 6:17pm UTC](https://meta.discourse.org/t/drupal-7-migration-questions/71539/1 "2017-10-06T18:17:04Z")

</div>

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

I found [this plugin](https://github.com/communiteq/discourse-migratepassword/blob/master/plugin.rb) and [this](https://stackoverflow.com/a/19274472/1365699) [info](https://api.drupal.org/api/drupal/includes%21password.inc/7.x), 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>]

```

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [October 6, 2017, 10:00pm UTC](https://meta.discourse.org/t/drupal-7-migration-questions/71539/2 "2017-10-06T22:00:44Z")

</div>

> [@j127](#):
>
> 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?

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

> [@](#):
>
> 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.

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.

> [@](#):
>
> Temporary email address were saved during the last test import – something like [tmpemail111@example.com](mailto: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.

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?

---

<div class="post-metadata">

### Author: ![j127](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/j127/32/79093_2.png) [@j127](https://meta.discourse.org/u/j127)
#### Post date: [October 6, 2017, 10:13pm UTC](https://meta.discourse.org/t/drupal-7-migration-questions/71539/3 "2017-10-06T22:13:26Z")

</div>

> [@pfaffman](#):
>
> 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?

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. 🙂

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:

 ![Ekrankopio de 2017-10-06 15-09-11](https://global.discourse-cdn.com/meta/original/3X/1/7/174927763e4426e67c440447f0171344523ec32a.png)

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](https://global.discourse-cdn.com/meta/original/3X/9/d/9d4c740ec8658532fd56938022c130554a837b4a.png)

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [October 6, 2017, 10:34pm UTC](https://meta.discourse.org/t/drupal-7-migration-questions/71539/4 "2017-10-06T22:34:39Z")

</div>

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:

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

```

> [@j127](#):
>
> but the database shows nil for email and the first part of the email address ended up in name, which shouldn’t happen.

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](https://meta.discourse.org/t/change-user-creation-date-for-multiple-users/70391/5) for a code sample that pulls email addresses.

---

<div class="post-metadata">

### Author: ![j127](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/j127/32/79093_2.png) [@j127](https://meta.discourse.org/u/j127)
#### Post date: [October 6, 2017, 10:46pm UTC](https://meta.discourse.org/t/drupal-7-migration-questions/71539/5 "2017-10-06T22:46:31Z")

</div>

> [@pfaffman](#):
>
> If you go to /admin/users you can see them.

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?

 ![Ekrankopio de 2017-10-06 15-43-14](https://global.discourse-cdn.com/meta/original/3X/d/4/d40eb1147d29d9861421beee6e822e7042915f1c.png)

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [October 6, 2017, 10:49pm UTC](https://meta.discourse.org/t/drupal-7-migration-questions/71539/6 "2017-10-06T22:49:02Z")

</div>

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

---

<div class="post-metadata">

### Author: ![j127](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/j127/32/79093_2.png) [@j127](https://meta.discourse.org/u/j127)
#### Post date: [October 17, 2017, 7:18pm UTC](https://meta.discourse.org/t/drupal-7-migration-questions/71539/7 "2017-10-17T19:18:42Z")

</div>

> [@pfaffman](#):
>
> SiteSetting.disable\_emails = true  
> SiteSetting.allow\_index\_in\_robots\_txt=nil  
> SiteSetting.login\_required=true

@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?

```ruby
    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

```

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [October 17, 2017, 7:27pm UTC](https://meta.discourse.org/t/drupal-7-migration-questions/71539/8 "2017-10-17T19:27:09Z")

</div>

I usually add it to the `initialize` function.

---

<div class="post-metadata">

### Author: ![j127](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/j127/32/79093_2.png) [@j127](https://meta.discourse.org/u/j127)
#### Post date: [October 17, 2017, 7:29pm UTC](https://meta.discourse.org/t/drupal-7-migration-questions/71539/9 "2017-10-17T19:29:52Z")

</div>

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