<?php

/**
 * Implements hook_schema().
 */
function diy_newsletter_schema() {

  $schema = array();

  $schema['diy_newsletter'] = array(
    'description' => 'The base table for DIY newsletter',
    'fields' => array(
      'id' => array(
        'description' => 'Primary key of the DIY newsletter entity',
        'type' => 'serial',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
      'subject' => array(
        'description' => 'Newsletter subject.',
        'type' => 'varchar',
        'length' => 255,
        'not null' => FALSE,
      ),
      'status' => array(
        'description' => 'Newsletter status.',
        'type' => 'int',
        'length' => 1,
        'not null' => FALSE,
      ),
      'created' => array(
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
        'description' => 'The time that the newsletter was created, as a Unix timestamp.',
      )
    ),
    'primary key' => array('id'),
  );

  $schema['diy_newsletter_used'] = array(
    'description' => 'Storage of used nodes inside newsletters',
    'fields' => array(
      'newsletter_id' => array(
        'description' => 'Newsletter id.',
        'type' => 'int',
        'length' => 255,
        'not null' => TRUE,
      ),
      'node_id' => array(
        'description' => 'Node id.',
        'type' => 'int',
        'length' => 255,
        'not null' => TRUE,
      ),
    ),
    'primary key' => array('newsletter_id', 'node_id'),
  );

  return $schema;
}