You are here

function oauth_update_8100 in OAuth 1.0 8.2

Move any existing oauth data to UserData and remove 'oauth_consumers' table.

File

./oauth.install, line 43
Installation and schema related functions for the OAuth module.

Code

function oauth_update_8100(&$sandbox) {

  // Fetch any current consumer data.
  $result = Database::getConnection()
    ->query('select * from {oauth_consumer}');
  $user_data = \Drupal::service('user.data');
  foreach ($result as $row) {

    // Insert each row in to Userdata.
    $user_data
      ->set('oauth', $row->uid, $row->consumer_key, [
      'consumer_secret' => $row->consumer_secret,
      'key_hash' => $row->key_hash,
    ]);
  }

  // Remove the oauth_consumer table.
  Database::getConnection()
    ->schema()
    ->dropTable('oauth_consumer');
}