You are here

function stripe_schema in Stripe 7

Implements hook_schema().

File

./stripe.install, line 42
Install, update and uninstall functions for the Stripe module.

Code

function stripe_schema() {

  // Table for logging webhook events.
  // @see https://stripe.com/docs/api/php#idempotent_requests
  $schema['stripe_webhook_events'] = array(
    'description' => 'This table logs webhook events for idempotency.',
    'fields' => array(
      'event_id' => array(
        'description' => 'The unique event_id of the received webhook.',
        'type' => 'varchar',
        'length' => 128,
        'not null' => TRUE,
        'default' => '',
      ),
      'idempotency_key' => array(
        'description' => 'The optional idempotency_key supplied to Stripe during a request.',
        'type' => 'varchar',
        'length' => 128,
      ),
      'type' => array(
        'description' => 'The event type.',
        'type' => 'varchar',
        'length' => 64,
      ),
      'api_version' => array(
        'description' => 'The version of Stripe API which generated this webhook.',
        'type' => 'varchar',
        'length' => 64,
      ),
      'created' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
        'description' => 'The timestamp when this webhook was created.',
      ),
      'received' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
        'description' => 'The timestamp when this webhook was received.',
      ),
      'livemode' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
        'description' => 'Whether this webhook was created in live or test mode.',
      ),
      'processed' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
        'description' => 'The timestamp when this webhook was processed.',
      ),
    ),
    'primary key' => array(
      'event_id',
    ),
    'indexes' => array(
      'created' => array(
        'created',
      ),
      'received' => array(
        'received',
      ),
      'processed' => array(
        'processed',
      ),
      'api_version' => array(
        'api_version',
      ),
    ),
  );
  return $schema;
}