You are here

function drupagram_schema in Drupagram 6

Same name and namespace in other branches
  1. 7 drupagram.install \drupagram_schema()

Implements hook_schema().

File

./drupagram.install, line 13
Install, update and uninstall functions for the drupagram module.

Code

function drupagram_schema() {
  $schema = array();

  /**
   * Instagram media objects have the following attributes:
   *
   * public drupagram_id;
   * public username;
   * public type;
   * public images;
   * public location;
   * public comments;
   * public caption;
   * public link;
   * public likes;
   * public filter;
   * public created_at;
   * public created_time;
   */
  $schema['drupagram'] = array(
    'description' => "Stores individual Instagrams (media).",
    'fields' => array(
      'drupagram_id' => array(
        'description' => "Unique identifier for each {drupagram} post.",
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => '',
      ),
      'username' => array(
        'description' => "Username of the {drupagram_account} user.",
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => '',
      ),
      'type' => array(
        'description' => "The type of {drupagram} post.",
        'type' => 'varchar',
        'length' => 64,
        'not null' => TRUE,
        'default' => 'image',
      ),
      'images' => array(
        'description' => "The images available for the {drupagram} post. Serialied array.",
        'type' => 'text',
        'not null' => FALSE,
      ),
      'location' => array(
        'description' => "The location of the {drupagram} post.",
        'type' => 'varchar',
        'length' => 255,
        'not null' => FALSE,
      ),
      'comments' => array(
        'description' => "The comments made on the {drupagram} post.",
        'type' => 'text',
        'not null' => FALSE,
      ),
      'caption' => array(
        'description' => "The caption of the {drupagram} post.",
        'type' => 'text',
        'not null' => FALSE,
      ),
      'link' => array(
        'description' => "The link to the {drupagram} post.",
        'type' => 'varchar',
        'length' => 255,
        'not null' => FALSE,
        'default' => '',
      ),
      'likes' => array(
        'description' => "The link to the {drupagram} post.",
        'type' => 'text',
        'not null' => FALSE,
      ),
      'filter' => array(
        'description' => "The filter used on this {drupagram} post.",
        'type' => 'varchar',
        'length' => 255,
        'not null' => FALSE,
      ),
      'created_at' => array(
        'description' => "Date and time the {drupagram} post was created.",
        'type' => 'varchar',
        'length' => 64,
        'not null' => TRUE,
        'default' => '',
      ),
      'created_time' => array(
        'description' => "A duplicate of {drupagram}.created_at in UNIX timestamp format.",
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
      ),
    ),
    'indexes' => array(
      'username' => array(
        'username',
      ),
    ),
    'primary key' => array(
      'drupagram_id',
    ),
  );

  /**
   * Instagram user objects have the following attributes:
   *
   * public drupagram_id;
   * public uid;
   * public username;
   * public password;
   * public oauth_token;
   * public oauth_token_secret;
   * public full_name;
   * public last_name;
   * public profile_picture;
   * public bio;
   * public website;
   * public media_count;
   * public follows_count;
   * public followed_by_count;
   * public follows;
   * public followed_by;
   * public url;
   * public import;
   * public last_refresh;
   * public is_global;
   */
  $schema['drupagram_account'] = array(
    'description' => "Stores information on specific Instagram user accounts.",
    'fields' => array(
      'drupagram_id' => array(
        'description' => "The unique identifier of the {drupagram_account}.",
        'type' => 'numeric',
        'unsigned' => TRUE,
        'precision' => 20,
        'scale' => 0,
        'not null' => TRUE,
        'default' => 0,
      ),
      'uid' => array(
        'description' => "The {users}.uid of the owner of this account",
        'type' => 'int',
        'unsigned' => TRUE,
        'size' => 'big',
        'not null' => TRUE,
      ),
      'username' => array(
        'description' => "The unique login name of the {drupagram_account} user.",
        'type' => 'varchar',
        'length' => 255,
      ),
      'password' => array(
        'description' => "The password for the Instagram account.",
        'type' => 'varchar',
        'length' => 64,
      ),
      'oauth_token' => array(
        'description' => 'The token_key for oauth-based access.',
        'type' => 'varchar',
        'length' => 64,
      ),
      'oauth_token_secret' => array(
        'description' => 'The token_secret for oauth-based access.',
        'type' => 'varchar',
        'length' => 64,
      ),
      'full_name' => array(
        'description' => "The full name of the {drupagram_account} user.",
        'type' => 'varchar',
        'length' => 64,
        'not null' => TRUE,
        'default' => '',
      ),
      'first_name' => array(
        'description' => "The first name of the {drupagram_account} user.",
        'type' => 'varchar',
        'length' => 64,
        'not null' => FALSE,
        'default' => '',
      ),
      'last_name' => array(
        'description' => "The last name of the {drupagram_account} user.",
        'type' => 'varchar',
        'length' => 64,
        'not null' => FALSE,
        'default' => '',
      ),
      'profile_picture' => array(
        'description' => "The url of the {drupagram_account}'s profile image.",
        'type' => 'varchar',
        'length' => 255,
      ),
      'bio' => array(
        'description' => "The description/biography associated with the {drupagram_account}.",
        'type' => 'varchar',
        'length' => 255,
      ),
      'website' => array(
        'description' => "The url of the {drupagram_account}'s home page.",
        'type' => 'varchar',
        'length' => 255,
      ),
      'media_count' => array(
        'description' => "The total number of status updates performed by a user, excluding direct messages sent.",
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
      ),
      'follows_count' => array(
        'description' => "The number of users this {drupagram_account} is following.",
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
      ),
      'followed_by_count' => array(
        'description' => "The number of users following this {drupagram_account}.",
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
      ),
      'follows' => array(
        'description' => "The users this {drupagram_account} is following.",
        'type' => 'text',
        'not null' => FALSE,
      ),
      'followed_by' => array(
        'description' => "The users following this {drupagram_account}.",
        'type' => 'text',
        'not null' => FALSE,
      ),
      'url' => array(
        'description' => "The url of the {drupagram_account}'s Instagram page.",
        'type' => 'varchar',
        'length' => 255,
      ),
      'import' => array(
        'description' => "Boolean flag indicating whether the {drupagram_user}'s posts should be pulled in by the site.",
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 1,
      ),
      'last_refresh' => array(
        'description' => "A UNIX timestamp marking the date Instagram statuses were last fetched on.",
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
      ),
      'is_global' => array(
        'description' => "Boolean flag indicating if this account is available for global use",
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ),
    ),
    'indexes' => array(
      'username' => array(
        'username',
      ),
    ),
    'primary key' => array(
      'drupagram_id',
    ),
  );
  return $schema;
}