<?php
/**
 * @file
 * Implementations of installation hooks.
 */


function upei_roblib_ill_update_7100() {
  db_change_field('upei_roblib_ill_request', 'isbn', 'isbn',
    array(
      'description' => 'book isbn',
      'type' => 'varchar',
      'length' => '200',
      'not null' => FALSE,
    )
  );
}

/**
 * Implements hook_schema().
 */
function upei_roblib_ill_schema() {
  $schema['upei_roblib_ill_request'] = [
    'description' => 'Log table for ILL requests',
    'fields' => [
      'id' => [
        'description' => 'primary key',
        'type' => 'serial',
        'size' => 'big',
        'not null' => TRUE,
      ],
      'patron_id' => [
        'description' => 'The id of the user that submitted the request',
        'type' => 'varchar',
        'length' => '255',
        'not null' => TRUE,
      ],
      'patron_email' => [
        'description' => 'The email address of the user that submitted the request',
        'type' => 'varchar',
        'length' => '255',
        'not null' => FALSE,
      ],
      'patron_lastname' => [
        'description' => 'Lastname of the user that submitted the request',
        'type' => 'varchar',
        'length' => '60',
        'not null' => TRUE,
      ],
      'patron_firstname' => [
        'description' => 'Firstname of the user that submitted the request',
        'type' => 'varchar',
        'length' => '60',
        'not null' => TRUE,
      ],
      'patron_department' => [
        'description' => 'The department the user that submitted the request belongs',
        'type' => 'varchar',
        'length' => '128',
        'not null' => TRUE,
      ],
      'patron_type' => [
        'description' => 'The type of patron ',
        'type' => 'varchar',
        'length' => '128',
        'not null' => FALSE,
      ],
      'author' => [
        'description' => 'authors name',
        'type' => 'varchar',
        'length' => '128',
        'not null' => FALSE,
      ],
      'title' => [
        'description' => 'book or journal title',
        'type' => 'varchar',
        'length' => '512',
        'not null' => FALSE,
      ],
      'atitle' => [
        'description' => 'article or chapter title',
        'type' => 'varchar',
        'length' => '512',
        'not null' => FALSE,
      ],
      'issn' => [
        'description' => 'Article issn',
        'type' => 'varchar',
        'length' => '18',
        'not null' => FALSE,
      ],
      'isbn' => [
        'description' => 'book isbn',
        'type' => 'varchar',
        'length' => '200',
        'not null' => FALSE,
      ],
      'article_author' => [
        'description' => 'Article author',
        'type' => 'varchar',
        'length' => '128',
        'not null' => FALSE,
      ],
      'citation_date' => [
        'description' => 'Date and time of the request',
        'type' => 'varchar',
        'length' => '30',
        'not null' => TRUE,
      ],
      'pages_requested' => [
        'description' => 'pages requested',
        'type' => 'varchar',
        'length' => '30',
        'not null' => FALSE,
      ],
      'volume' => [
        'description' => 'Volume',
        'type' => 'varchar',
        'length' => '30',
        'not null' => FALSE,
      ],
      'issue' => [
        'description' => 'Issue',
        'type' => 'varchar',
        'length' => '50',
        'not null' => FALSE,
      ],
      'genre' => [
        'description' => 'type of material requested (article, book, book chapter)',
        'type' => 'varchar',
        'length' => '30',
        'not null' => TRUE,
      ],
      'doi' => [
        'description' => 'The DOI',
        'type' => 'varchar',
        'length' => '255',
        'not null' => FALSE,
      ],
      'relais_request_id' => [
        'description' => 'The request id stored in the Relais datbabase',
        'type' => 'varchar',
        'length' => '30',
        'not null' => FALSE,
      ],
      'relais_message' => [
        'description' => 'If the ILL request failed we will store a reason.',
        'type' => 'varchar',
        'length' => '255',
        'not null' => FALSE,
      ],
      'time_submitted' => [
        'description' => 'The time the request was submitted',
        'type' => 'int',
        'not null' => FALSE,
      ],
      'notes' => [
        'description' => 'Notes',
        'type' => 'varchar',
        'length' => '512',
        'not null' => FALSE,
      ],
    ],
    'primary key' => ['id'],
  ];
  return $schema;

}