You are here

function social_auth_update_8201 in Social Auth 3.x

Same name and namespace in other branches
  1. 8.2 social_auth.install \social_auth_update_8201()

Add 'social_auth' table when the module is updated from 1.x to 2.x.

Nothing changes if version 2.x is in use.

File

./social_auth.install, line 15
Install, update and uninstall functions for Social Auth.

Code

function social_auth_update_8201() {
  $schema = Database::getConnection()
    ->schema();
  if (!$schema
    ->tableExists('social_auth')) {
    $spec = [
      'description' => 'The base table for social_auth entities.',
      'fields' => [
        'id' => [
          'type' => 'serial',
          'length' => 10,
          'not null' => TRUE,
          'unsigned' => TRUE,
        ],
        'uuid' => [
          'type' => 'varchar_ascii',
          'length' => 128,
          'not null' => FALSE,
        ],
        'user_id' => [
          'description' => 'The ID of the target entity.',
          'type' => 'int',
          'length' => 10,
          'not null' => TRUE,
          'unsigned' => TRUE,
        ],
        'plugin_id' => [
          'type' => 'varchar',
          'length' => 255,
          'not null' => TRUE,
        ],
        'provider_user_id' => [
          'type' => 'varchar',
          'length' => 255,
          'not null' => TRUE,
        ],
        'created' => [
          'type' => 'int',
          'length' => 11,
          'not null' => TRUE,
        ],
        'changed' => [
          'type' => 'int',
          'length' => 11,
          'not null' => TRUE,
        ],
        'token' => [
          'type' => 'text',
          'not null' => TRUE,
          'size' => 'big',
        ],
        'additional_data' => [
          'type' => 'text',
          'not null' => TRUE,
          'size' => 'big',
        ],
      ],
      'primary key' => [
        'id',
      ],
      'unique keys' => [
        'social_auth_field__uuid__value' => [
          'uuid',
        ],
      ],
      'indexes' => [
        'social_auth_field__user_id__target_id' => [
          'user_id',
        ],
      ],
    ];
    $schema
      ->createTable('social_auth', $spec);
  }
}