You are here

public static function LearningPathAccess::createUserStatusTable in Opigno Learning path 3.x

Same name and namespace in other branches
  1. 8 src/LearningPathAccess.php \Drupal\opigno_learning_path\LearningPathAccess::createUserStatusTable()

Creates database table for Learning Path group user statuses.

1 call to LearningPathAccess::createUserStatusTable()
opigno_learning_path_install in ./opigno_learning_path.install
Implements hook_install().

File

src/LearningPathAccess.php, line 495

Class

LearningPathAccess
Class LearningPathAccess.

Namespace

Drupal\opigno_learning_path

Code

public static function createUserStatusTable() {
  $schema = Database::getConnection()
    ->schema();
  if (!$schema
    ->tableExists('opigno_learning_path_group_user_status')) {
    $spec = [
      'description' => 'Learning Path group user statuses',
      'fields' => [
        'id' => [
          'type' => 'serial',
          'not null' => TRUE,
        ],
        'mid' => [
          'description' => 'Membership ID',
          'type' => 'int',
          'unsigned' => TRUE,
          'not null' => TRUE,
        ],
        'uid' => [
          'description' => 'User ID',
          'type' => 'int',
          'unsigned' => TRUE,
          'not null' => TRUE,
        ],
        'gid' => [
          'description' => 'Group ID',
          'type' => 'int',
          'unsigned' => TRUE,
          'not null' => TRUE,
        ],
        'status' => [
          'description' => 'Member status',
          'type' => 'int',
          'unsigned' => TRUE,
          'not null' => TRUE,
          'default' => 0,
        ],
        'message' => [
          'description' => 'User message',
          'type' => 'varchar',
          'length' => 200,
          'not null' => TRUE,
          'default' => '',
        ],
      ],
      'primary key' => [
        'id',
      ],
      'indexes' => [
        'mid' => [
          'mid',
        ],
        'gid' => [
          'gid',
        ],
        'uid' => [
          'uid',
        ],
      ],
      'foreign keys' => [
        'group_content' => [
          'mid' => 'id',
        ],
        'users' => [
          'uid' => 'uid',
        ],
        'groups' => [
          'gid' => 'id',
        ],
      ],
    ];
    $schema
      ->createTable('opigno_learning_path_group_user_status', $spec);
  }
}