You are here

function notifications_widget_schema in Notifications widget 8

Implements hook_schema().

File

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

Code

function notifications_widget_schema() {
  $schema['notifications'] = [
    'description' => 'Create table used to store data of each site notifications of users',
    'fields' => [
      'id' => [
        'type' => 'serial',
        'not null' => TRUE,
        'unsigned' => TRUE,
        'description' => 'Unique ID for this record.',
      ],
      'entity_id' => [
        'description' => 'Entity id of action performed',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ],
      'entity_uid' => [
        'description' => 'Entity uid of action performed',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ],
      'action' => [
        'description' => 'Actions type Create, Update, Delete',
        'type' => 'varchar',
        'length' => 30,
        'not null' => TRUE,
        'default' => '',
      ],
      'bundle' => [
        'description' => 'Name of the bundle',
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => '',
      ],
      'uid' => [
        'description' => 'uid of actioned user',
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => '',
      ],
      'user_name' => [
        'description' => 'Name of the user',
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => '',
      ],
      'message' => [
        'description' => 'Notification message based on confiuration',
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
      ],
      'status' => [
        'description' => 'Status of the notification',
        'type' => 'int',
        'not null' => TRUE,
      ],
      'created' => [
        'type' => 'int',
        'not null' => TRUE,
        'description' => "Timestamp for the record insert.",
      ],
    ],
    'indexes' => [
      'notification_uid' => [
        'uid',
      ],
      'notification_entity' => [
        'entity_id',
      ],
      'notification_created_timestamp' => [
        'created',
      ],
    ],
    'primary key' => [
      'id',
    ],
  ];
  $schema['notifications_actions'] = [
    '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',
    ],
  ];
  $schema['notifications_clear_all'] = [
    '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',
    ],
  ];
  return $schema;
}