You are here

function push_notifications_schema in Push Notifications 7

Implements hook_field_scheme().

File

./push_notifications.install, line 56
Install files for Push Notifications module.

Code

function push_notifications_schema() {
  $schema = array();
  $schema['push_notifications_queue'] = array(
    'description' => 'Queue for scheduled push notifications',
    'fields' => array(
      'uid' => array(
        'description' => 'User ID',
        'type' => 'int',
        'not null' => TRUE,
      ),
      'payload' => array(
        'description' => 'Message',
        'type' => 'varchar',
        'length' => '2048',
        'not null' => TRUE,
      ),
      'timestamp' => array(
        'description' => 'Timestamp when message was added',
        'type' => 'int',
        'not null' => TRUE,
      ),
    ),
    'primary key' => array(
      'uid',
    ),
    'indexes' => array(
      'timestamp' => array(
        'timestamp',
      ),
    ),
  );
  $schema['push_notifications_tokens'] = array(
    'description' => 'Stores device tokens',
    'fields' => array(
      'id' => array(
        'description' => t('Push Notification auto-increment ID.'),
        'type' => 'serial',
        'not null' => TRUE,
      ),
      'token' => array(
        'description' => 'Device Token',
        'type' => 'varchar',
        'length' => '255',
        'not null' => TRUE,
      ),
      'uid' => array(
        'description' => 'User ID',
        'type' => 'int',
        'not null' => TRUE,
      ),
      'type' => array(
        'description' => 'Device Type (iPhone, Android)',
        'type' => 'int',
        'not null' => TRUE,
      ),
      'timestamp' => array(
        'description' => 'Timestamp token was added',
        'type' => 'int',
        'not null' => TRUE,
      ),
      'language' => array(
        'description' => 'Language',
        'type' => 'varchar',
        'length' => 11,
        'not null' => TRUE,
      ),
    ),
    'primary key' => array(
      'id',
    ),
    'indexes' => array(
      'timestamp' => array(
        'timestamp',
      ),
      'token' => array(
        'token',
      ),
      'type' => array(
        'type',
      ),
      'language' => array(
        'language',
      ),
      'token_uid' => array(
        'token',
        'uid',
      ),
    ),
  );
  return $schema;
}