66 lines
		
	
	
		
			1.6 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
			
		
		
	
	
			66 lines
		
	
	
		
			1.6 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
<?php
 | 
						|
 | 
						|
/**
 | 
						|
 * @file
 | 
						|
 * Install, update and uninstall functions for File module.
 | 
						|
 */
 | 
						|
 | 
						|
/**
 | 
						|
 * Implements hook_schema().
 | 
						|
 */
 | 
						|
function file_schema(): array {
 | 
						|
  $schema['file_usage'] = [
 | 
						|
    'description' => 'Track where a file is used.',
 | 
						|
    'fields' => [
 | 
						|
      'fid' => [
 | 
						|
        'description' => 'File ID.',
 | 
						|
        'type' => 'int',
 | 
						|
        'unsigned' => TRUE,
 | 
						|
        'not null' => TRUE,
 | 
						|
      ],
 | 
						|
      'module' => [
 | 
						|
        'description' => 'The name of the module that is using the file.',
 | 
						|
        'type' => 'varchar_ascii',
 | 
						|
        'length' => DRUPAL_EXTENSION_NAME_MAX_LENGTH,
 | 
						|
        'not null' => TRUE,
 | 
						|
        'default' => '',
 | 
						|
      ],
 | 
						|
      'type' => [
 | 
						|
        'description' => 'The name of the object type in which the file is used.',
 | 
						|
        'type' => 'varchar_ascii',
 | 
						|
        'length' => 64,
 | 
						|
        'not null' => TRUE,
 | 
						|
        'default' => '',
 | 
						|
      ],
 | 
						|
      'id' => [
 | 
						|
        'description' => 'The primary key of the object using the file.',
 | 
						|
        'type' => 'varchar_ascii',
 | 
						|
        'length' => 64,
 | 
						|
        'not null' => TRUE,
 | 
						|
        'default' => 0,
 | 
						|
      ],
 | 
						|
      'count' => [
 | 
						|
        'description' => 'The number of times this file is used by this object.',
 | 
						|
        'type' => 'int',
 | 
						|
        'unsigned' => TRUE,
 | 
						|
        'not null' => TRUE,
 | 
						|
        'default' => 0,
 | 
						|
      ],
 | 
						|
    ],
 | 
						|
    'primary key' => ['fid', 'type', 'id', 'module'],
 | 
						|
    'indexes' => [
 | 
						|
      'type_id' => ['type', 'id'],
 | 
						|
      'fid_count' => ['fid', 'count'],
 | 
						|
      'fid_module' => ['fid', 'module'],
 | 
						|
    ],
 | 
						|
  ];
 | 
						|
  return $schema;
 | 
						|
}
 | 
						|
 | 
						|
/**
 | 
						|
 * Implements hook_update_last_removed().
 | 
						|
 */
 | 
						|
function file_update_last_removed(): int {
 | 
						|
  return 8700;
 | 
						|
}
 |