1 file.install | file_schema() |
Implements hook_schema().
File
- core/
modules/ file/ file.install, line 48 - Install, update and uninstall functions for File module.
Code
function file_schema() {
$schema['file_managed'] = array(
'description' => 'Stores information for uploaded files.',
'fields' => array(
'fid' => array(
'description' => 'File ID.',
'type' => 'serial',
'unsigned' => TRUE,
'not null' => TRUE,
),
'uid' => array(
'description' => 'The {users}.uid of the user who is associated with the file.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
),
'filename' => array(
'description' => 'Name of the file with no path components. This may differ from the basename of the URI if the file is renamed to avoid overwriting an existing file.',
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => '',
),
'uri' => array(
'description' => 'The URI to access the file (either local or remote).',
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => '',
),
'filemime' => array(
'description' => "The file's MIME type.",
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => '',
),
'filesize' => array(
'description' => 'The size of the file in bytes.',
'type' => 'int',
'size' => 'big',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
),
'status' => array(
'description' => 'A field indicating the status of the file. Two status are defined in core: temporary (0) and permanent (1). Temporary files older than BACKDROP_MAXIMUM_TEMP_FILE_AGE will be removed during a cron run.',
'type' => 'int',
'not null' => TRUE,
'default' => 0,
'size' => 'tiny',
),
'timestamp' => array(
'description' => 'UNIX timestamp for when the file was added.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
),
'type' => array(
'description' => 'The type of this file.',
'type' => 'varchar',
'length' => 50,
'not null' => TRUE,
// If the FILE_TYPE_NONE constant ever changes, then change the value here
// too, and add an update function to deal with existing records. The
// constant isn't used here, because there may be cases where this function
// runs without the module file loaded.
'default' => 'undefined',
),
),
'indexes' => array(
'uid' => array('uid'),
'status' => array('status'),
'timestamp' => array('timestamp'),
'file_type' => array('type'),
),
'unique keys' => array(
'uri' => array('uri'),
),
'primary key' => array('fid'),
'foreign keys' => array(
'file_owner' => array(
'table' => 'users',
'columns' => array('uid' => 'uid'),
),
),
);
$schema['file_usage'] = array(
'description' => 'Track where a file is used.',
'fields' => array(
'fid' => array(
'description' => 'File ID.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
),
'module' => array(
'description' => 'The name of the module that is using the file.',
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => '',
),
'type' => array(
'description' => 'The name of the object type in which the file is used.',
'type' => 'varchar',
'length' => 64,
'not null' => TRUE,
'default' => '',
),
'id' => array(
'description' => 'The primary key of the object using the file.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
),
'count' => array(
'description' => 'The number of times this file is used by this object.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
),
),
'primary key' => array('fid', 'type', 'id', 'module'),
'indexes' => array(
'type_id' => array('type', 'id'),
'fid_count' => array('fid', 'count'),
'fid_module' => array('fid', 'module'),
),
);
$schema['file_metadata'] = array(
'description' => 'Cache image metadata.',
'fields' => array(
'fid' => array(
'description' => 'The {file_managed}.fid of the metadata.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
),
'name' => array(
'description' => "The name of the metadata (e.g. 'width').",
'type' => 'varchar',
'length' => '255',
'not null' => TRUE,
),
'value' => array(
'description' => "The value of the metadata (e.g. '200').",
'type' => 'blob',
'not null' => FALSE,
'size' => 'big',
'serialize' => TRUE,
),
),
'primary key' => array('fid', 'name'),
'foreign keys' => array(
'file_managed' => array(
'table' => 'file_managed',
'columns' => array('fid' => 'fid'),
),
),
);
$cache_schema = backdrop_get_schema_unprocessed('system', 'cache');
$schema['cache_entity_file'] = $cache_schema;
$schema['cache_entity_file']['description'] = "Cache table used to store File entity records.";
return $schema;
}