Migration from Subscriptions module on D7

Created on 19 September 2023, about 1 year ago
Updated 29 May 2024, 6 months ago

Problem/Motivation

We're upgrading a site from D7 that used the Subscriptions system for managing content subscriptions. We need to migrate this to DANSE on D10.

Proposed resolution

Document how to migrate data from Subscriptions to DANSE.

Remaining tasks

Work out the necessary plugins, etc to migrate data from Subscriptions on DANSE.

User interface changes

TBD

API changes

n/a

Data model changes

n/a

πŸ“Œ Task
Status

Active

Version

2.2

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States DamienMcKenna NH, USA

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @DamienMcKenna
  • πŸ‡©πŸ‡ͺGermany jurgenhaas Gottmadingen

    Nice to see that usecase. Not sure if I can be of much help here since I'm not sure about the former subscription data structure. I could certainly provide some feedback on how the subscription data is stored by DANSE, though. @DamienMcKenna let me know if and what you would need from our side, please.

  • πŸ‡ΊπŸ‡ΈUnited States DamienMcKenna NH, USA

    WIP source plugin.

    <?php
    
    namespace Drupal\my_migrate_stuff\Plugin\migrate\source;
    
    use Drupal\migrate\Annotation\MigrateSource;
    use Drupal\migrate\Plugin\migrate\source\SqlBase;
    use Drupal\migrate\Plugin\MigrationInterface;
    
    /**
     * Migrate source for the Subscriptions data.
     *
     * @MigrateSource(
     *   id = "d7_subscriptions",
     *   source_module = "subscriptions"
     * )
     */
    class UserSubscriptions extends SqlBase {
    
      /**
       * {@inheritdoc}
       */
      public function query() {
        $query = $this->select('subscriptions', 's');
        $query->join('subscriptions_user', 'su', 's.recipient_uid = su.uid');
        $query->fields('s', [
          'sid', 'module', 'field', 'value', 'recipient_uid',
          'send_interval', 'author_uid', 'send_updates', 'send_comments',
        ]);
        $query->fields('su', [
          'uid', 'digest', 'secure_links', 'send_interval',
          // Ignore these two columns as they're duplicates for our use case.
          // 'send_updates', 'send_comments',
          'send_interval_visible', 'send_updates_visible',
          'send_comments_visible', 'autosub_on_post', 'autosub_on_update',
          'autosub_on_comment', 'send_self', 'suspended',
        ]);
        $query->orderBy('s.sid');
        print_r((string), $query);
    
        return $query;
      }
    
      /**
       * {@inheritdoc}
       */
      public function fields() {
        $fields = [
          'sid' => 'sid',
        ];
        return $fields;
      }
    
      /**
       * {@inheritdoc}
       */
      public function getIds() {
        return [
          'sid' => [
            'type' => 'integer',
            'alias' => 's',
          ],
        ];
      }
    
    }
    
  • πŸ‡ΊπŸ‡ΈUnited States DamienMcKenna NH, USA

    Migration config for the "update" data:

    id: mysite_users_subscriptions_update
    migration_group: mysite
    label: 'Users: Subscriptions: Update'
    audit: true
    migration_tags:
      - LBL
      - Users
    source:
      plugin: d7_lbl_subscriptions
      constants:
        type: 'content'
        subtype: 'taxonomy_term'
        operation: 2
        publish: 'publish'
        update: 'update'
    process:
      # None of these values are used.
      # sid: sid
      # field: field
      # recipient_uid: recipient_uid
      # send_interval: send_interval
      # author_uid: author_uid
      # send_updates: send_updates
      # send_comments: send_comments
      # digest: digest
      # secure_links: secure_links
      # send_interval: send_interval
      # send_interval_visible: send_interval_visible
      # send_updates_visible: send_updates_visible
      # send_comments_visible: send_comments_visible
      # autosub_on_post: autosub_on_post
      # autosub_on_update: autosub_on_update
      # autosub_on_comment: autosub_on_comment
      # send_self: send_self
      # suspended: suspended
    
      uid: uid
      module:
        plugin: default_value
        default_value: 'danse'
      key:
        plugin: concat
        delimiter: '-'
        source:
          - 'constants/type'
          - 'constants/subtype'
          - value
          - 'constants/operation'
          - 'constants/update'
      settings:
        plugin: default_value
        default_value: 1
    
    destination:
      plugin: user_data
    migration_dependencies:
      required: {  }
      optional: {  }
    
  • πŸ‡ΊπŸ‡ΈUnited States DamienMcKenna NH, USA

    Migration config for the "publish" data:

    id: mysite_users_subscriptions_publish
    migration_group: mysite
    label: 'Users: Subscriptions: Publish'
    audit: true
    migration_tags:
      - mysite
      - Users
    source:
      plugin: d7_lbl_subscriptions
      constants:
        type: 'content'
        subtype: 'taxonomy_term'
        operation: 2
        publish: 'publish'
        update: 'update'
    process:
      # None of these values are used.
      # sid: sid
      # field: field
      # recipient_uid: recipient_uid
      # send_interval: send_interval
      # author_uid: author_uid
      # send_updates: send_updates
      # send_comments: send_comments
      # digest: digest
      # secure_links: secure_links
      # send_interval: send_interval
      # send_interval_visible: send_interval_visible
      # send_updates_visible: send_updates_visible
      # send_comments_visible: send_comments_visible
      # autosub_on_post: autosub_on_post
      # autosub_on_update: autosub_on_update
      # autosub_on_comment: autosub_on_comment
      # send_self: send_self
      # suspended: suspended
    
      uid: uid
      module:
        plugin: default_value
        default_value: 'danse'
      key:
        plugin: concat
        delimiter: '-'
        source:
          - 'constants/type'
          - 'constants/subtype'
          - value
          - 'constants/operation'
          - 'constants/publish'
      settings:
        plugin: default_value
        default_value: 1
    
    destination:
      plugin: user_data
    migration_dependencies:
      required: {  }
      optional: {  }
    
  • πŸ‡ΊπŸ‡ΈUnited States rclemings

    Is this still a work in progress or is it ready to use (more or less)?

Production build 0.71.5 2024