<?php

function openid_server_install() {
  // Create table.
  drupal_install_schema('openid_server');
}

/**
 * Implementation of hook_uninstall().
 */
function openid_server_uninstall() {
  // Remove table.
  drupal_uninstall_schema('openid_server');
}

function openid_server_schema() {
  require_once 'modules/openid/openid.install';
  $tmp = openid_schema();
  $schema['openid_server_association'] = $tmp['openid_association'];
  $schema['openid_server_relying_party'] = array(
    'description' => 'TODO: Add description.',
    'fields' => array(
      'uid' => array(
        'type' => 'int',
        'unsigned' => 'true',
  		'not null' => 'true',
      ),
      'realm' => array(
        'type' => 'text',
        'not null' => true,
      ),
      'first_time' => array(
        'type' => 'int',
        'not null' => true,
      ),
      'last_time' => array(
        'type' => 'int',
        'not null' => 'true',
      ),
      'auto_release' => array(
        'type' => 'int',
        'size' => 'tiny',
        'not null' => true,
      ) 
    ),
    // There is no primary key since realm is a text field. I'm not sure if it's a good
    // idea to include realm (with key length) in the index.
    'indexes' => array('uid' => array('uid')),
  );
  return $schema;
}
