You are here

function views_schema_6000 in Views (for Drupal 7) 7.3

Same name and namespace in other branches
  1. 6.3 views.install \views_schema_6000()
  2. 6.2 views.install \views_schema_6000()

Views 2's initial schema.

Called directly by views_update_6000() for updates from Drupal 5.

Important: Do not edit this schema!

Updates to the views schema must be provided as views_schema_6xxx() functions, which views_schema() automatically sees and applies. See below for examples.

Please do document updates with comments in this function, however.

1 call to views_schema_6000()
views_update_6000 in ./views.install
Update a site to Drupal 6! Contains a bit of special code to detect if you've been running a beta version or something.

File

./views.install, line 88
Contains install and update functions for Views.

Code

function views_schema_6000() {
  $schema['views_view'] = array(
    'description' => 'Stores the general data for a view.',
    'export' => array(
      'identifier' => 'view',
      'bulk export' => TRUE,
      'primary key' => 'vid',
      'default hook' => 'views_default_views',
      'admin_title' => 'human_name',
      'admin_description' => 'description',
      'api' => array(
        'owner' => 'views',
        'api' => 'views_default',
        'minimum_version' => '2',
        'current_version' => '3.0',
      ),
      'object' => 'view',
      // the callback to load the displays.
      'subrecords callback' => 'views_load_display_records',
      // the variable that holds enabled/disabled status.
      'status' => 'views_defaults',
      // CRUD callbacks.
      'create callback' => 'views_new_view',
      'save callback' => 'views_save_view',
      'delete callback' => 'views_delete_view',
      'export callback' => 'views_export_view',
      'status callback' => 'views_export_status',
      'cache defaults' => TRUE,
      'default cache bin' => 'cache_views',
    ),
    'fields' => array(
      'vid' => array(
        'type' => 'serial',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'description' => 'The view ID of the field, defined by the database.',
        'no export' => TRUE,
      ),
      'name' => array(
        'type' => 'varchar',
        'length' => '32',
        'default' => '',
        'not null' => TRUE,
        'description' => 'The unique name of the view. This is the primary field views are loaded from, and is used so that views may be internal and not necessarily in the database. May only be alphanumeric characters plus underscores.',
      ),
      'description' => array(
        'type' => 'varchar',
        'length' => '255',
        'default' => '',
        'description' => 'A description of the view for the admin interface.',
      ),
      'tag' => array(
        'type' => 'varchar',
        'length' => '255',
        'default' => '',
        'description' => 'A tag used to group/sort views in the admin interface',
      ),
      'view_php' => array(
        'type' => 'blob',
        'description' => 'A chunk of PHP code that can be used to provide modifications to the view prior to building.',
      ),
      'base_table' => array(
        'type' => 'varchar',
        'length' => '32',
        // Updated to '64' in views_schema_6005()
        'default' => '',
        'not null' => TRUE,
        'description' => 'What table this view is based on, such as node, user, comment, or term.',
      ),
      'is_cacheable' => array(
        'type' => 'int',
        'default' => 0,
        'size' => 'tiny',
        'description' => 'A boolean to indicate whether or not this view may have its query cached.',
      ),
    ),
    'primary key' => array(
      'vid',
    ),
    'unique key' => array(
      'name' => array(
        'name',
      ),
    ),
  );
  $schema['views_display'] = array(
    'description' => 'Stores information about each display attached to a view.',
    'fields' => array(
      'vid' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
        'description' => 'The view this display is attached to.',
        'no export' => TRUE,
      ),
      'id' => array(
        'type' => 'varchar',
        'length' => '64',
        'default' => '',
        'not null' => TRUE,
        'description' => 'An identifier for this display; usually generated from the display_plugin, so should be something like page or page_1 or block_2, etc.',
      ),
      'display_title' => array(
        'type' => 'varchar',
        'length' => '64',
        'default' => '',
        'not null' => TRUE,
        'description' => 'The title of the display, viewable by the administrator.',
      ),
      'display_plugin' => array(
        'type' => 'varchar',
        'length' => '64',
        'default' => '',
        'not null' => TRUE,
        'description' => 'The type of the display. Usually page, block or embed, but is pluggable so may be other things.',
      ),
      'position' => array(
        'type' => 'int',
        'default' => 0,
        'description' => 'The order in which this display is loaded.',
      ),
      'display_options' => array(
        // Type corrected in update 6009
        'type' => 'blob',
        'description' => 'A serialized array of options for this display; it contains options that are generally only pertinent to that display plugin type.',
        'serialize' => TRUE,
        'serialized default' => 'a:0:{}',
      ),
    ),
    // Added primary keys in views_schema_6008()
    'indexes' => array(
      'vid' => array(
        'vid',
        'position',
      ),
    ),
  );
  $schema['cache_views'] = drupal_get_schema_unprocessed('system', 'cache');
  $schema['views_object_cache'] = array(
    'description' => 'A special cache used to store objects that are being edited; it serves to save state in an ordinarily stateless environment.',
    'fields' => array(
      'sid' => array(
        'type' => 'varchar',
        'length' => '64',
        'description' => 'The session ID this cache object belongs to.',
      ),
      'name' => array(
        'type' => 'varchar',
        'length' => '32',
        'description' => 'The name of the view this cache is attached to.',
      ),
      'obj' => array(
        'type' => 'varchar',
        'length' => '32',
        'description' => 'The name of the object this cache is attached to; this essentially represents the owner so that several sub-systems can use this cache.',
      ),
      'updated' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
        'description' => 'The time this cache was created or updated.',
      ),
      'data' => array(
        'type' => 'blob',
        // Updated to 'text' (with size => 'big') in views_schema_6004()
        'description' => 'Serialized data being stored.',
        'serialize' => TRUE,
      ),
    ),
    'indexes' => array(
      'sid_obj_name' => array(
        'sid',
        'obj',
        'name',
      ),
      'updated' => array(
        'updated',
      ),
    ),
  );

  // $schema['cache_views_data'] added in views_schema_6006().
  return $schema;
}