View source
<?php
use Drupal\Core\Database\Database;
function tacjs_schema() {
$schema['tacjslog'] = [
'description' => 'The proof of consent.',
'fields' => [
'uid' => [
'description' => 'Primary Key: unique ID.',
'type' => 'serial',
'unsigned' => TRUE,
'not null' => TRUE,
],
'timestamp' => [
'description' => 'The Timestamp.',
'type' => 'int',
'not null' => TRUE,
'default' => 0,
],
'ip_address' => [
'description' => 'The IP address.',
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => '',
],
'services_allowed' => [
'description' => 'The service.',
'type' => 'text',
'not null' => TRUE,
],
],
'primary key' => [
'uid',
],
'indexes' => [
'uid' => [
'uid',
],
],
];
return $schema;
}
function tacjs_update_8001() {
$schema = Database::getConnection()
->schema();
if (!$schema
->tableExists('tacjslog')) {
$spec = tacjs_schema()['tacjslog'];
$schema
->createTable('tacjslog', $spec);
}
}