function autosave_form_schema in Autosave Form 8
Implements hook_schema().
File
- ./
autosave_form.install, line 15 - Install, update and uninstall functions for the autosave_form module.
Code
function autosave_form_schema() {
$schema = [];
// Define the schema for the autosave storage of entity forms.
$schema[AutosaveEntityFormStorageInterface::AUTOSAVE_ENTITY_FORM_TABLE] = [
'description' => 'Saves the form state of partially filled content entity form for restoration by the autosave_form module.',
'fields' => [
'form_id' => [
'type' => 'varchar_ascii',
'length' => AutosaveEntityFormStorageInterface::AUTOSAVE_FORM_FORM_ID_LENGTH,
'not null' => TRUE,
],
// We need the form session id as it is possible that the user opens the
// same form in two tabs and concurrently edits it. Therefore we have to
// assign each form session to an unique auto save session.
// We use the form build id for this and add an extra length to cover any
// case.
'form_session_id' => [
'type' => 'varchar_ascii',
'length' => AutosaveEntityFormStorageInterface::AUTOSAVE_FORM_FORM_ID_LENGTH,
'not null' => TRUE,
],
'entity_type_id' => [
'type' => 'varchar_ascii',
'length' => EntityTypeInterface::ID_MAX_LENGTH,
'not null' => TRUE,
],
'entity_id' => [
'type' => 'varchar_ascii',
'length' => EntityTypeInterface::ID_MAX_LENGTH,
'not null' => TRUE,
],
'langcode' => [
'type' => 'varchar_ascii',
'length' => 12,
'not null' => TRUE,
],
'uid' => [
'type' => 'int',
'not null' => TRUE,
],
'timestamp' => [
'type' => 'int',
'not null' => TRUE,
],
'entity' => [
'type' => 'blob',
'not null' => TRUE,
'size' => 'big',
],
'form_state' => [
'type' => 'blob',
'not null' => TRUE,
'size' => 'big',
],
],
'primary key' => [
'form_id',
'form_session_id',
'entity_type_id',
'entity_id',
'langcode',
'uid',
'timestamp',
],
];
return $schema;
}