You are here

function notifications_widget_update_8104 in Notifications widget 8

Create new schema for notifications actions.

File

./notifications_widget.install, line 239
Install, update and uninstall functions for the notification module module.

Code

function notifications_widget_update_8104() {
  $spec = [
    'description' => 'Create table used to store data of each action on notifications by the users',
    'fields' => [
      'id' => [
        'type' => 'serial',
        'not null' => TRUE,
        'unsigned' => TRUE,
        'description' => 'Unique ID for this record.',
      ],
      'notification_id' => [
        'description' => 'Notificaiton id of action performed',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ],
      'uid' => [
        'description' => 'Entity uid of action performed',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ],
      'status' => [
        'description' => 'Status of the notification 1=read, 2=>delete',
        'type' => 'int',
        'not null' => TRUE,
      ],
      'created' => [
        'type' => 'int',
        'not null' => TRUE,
        'description' => "Timestamp for the record insert.",
      ],
    ],
    'indexes' => [
      'notification_id' => [
        'notification_id',
      ],
      'uid' => [
        'uid',
      ],
      'notification_update_timestamp' => [
        'created',
      ],
    ],
    'primary key' => [
      'id',
    ],
  ];
  $clearAllSpec = [
    'description' => 'Create table used to store data for clearall status',
    'fields' => [
      'id' => [
        'type' => 'serial',
        'not null' => TRUE,
        'unsigned' => TRUE,
        'description' => 'Unique ID for this record.',
      ],
      'notification_id' => [
        'description' => 'Last Notificaiton id of action performed',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ],
      'uid' => [
        'description' => 'logged-in uid of action performed',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ],
      'created' => [
        'type' => 'int',
        'not null' => TRUE,
        'description' => "Timestamp for the record insert.",
      ],
    ],
    'indexes' => [
      'uid' => [
        'uid',
      ],
      'notification_update_timestamp' => [
        'created',
      ],
    ],
    'primary key' => [
      'id',
    ],
  ];
  $schema = Database::getConnection()
    ->schema();
  $schema
    ->createTable('notifications_actions', $spec);
  $schema
    ->createTable('notifications_clear_all', $clearAllSpec);
}