forked from tripvenue/drupal-tenant
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtenant.install
More file actions
131 lines (124 loc) · 3.23 KB
/
tenant.install
File metadata and controls
131 lines (124 loc) · 3.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
<?php
/**
* @file
* Install, update and uninstall functions for the user module.
*/
use Drupal\Core\Entity\Sql\SqlContentEntityStorage;
/**
* Implements hook_schema().
*/
function tenant_schema() {
$schema['tenant_data'] = [
'description' => 'Stores module data as key/value pairs per tenant.',
'fields' => [
'tenant_id' => [
'description' => 'The {groups}.id this record affects.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
],
'module' => [
'description' => 'The name of the module declaring the variable.',
'type' => 'varchar_ascii',
'length' => DRUPAL_EXTENSION_NAME_MAX_LENGTH,
'not null' => TRUE,
'default' => '',
],
'name' => [
'description' => 'The identifier of the data.',
'type' => 'varchar_ascii',
'length' => 128,
'not null' => TRUE,
'default' => '',
],
'value' => [
'description' => 'The value.',
'type' => 'blob',
'not null' => FALSE,
'size' => 'big',
],
'serialized' => [
'description' => 'Whether value is serialized.',
'type' => 'int',
'size' => 'tiny',
'unsigned' => TRUE,
'default' => 0,
],
],
'primary key' => ['tenant_id', 'module', 'name'],
'indexes' => [
'module' => ['module'],
'name' => ['name'],
],
'foreign keys' => [
'data_user' => [
'table' => 'groups',
'columns' => [
'tenant_id' => 'tenant_id',
],
],
],
];
return $schema;
}
function tenant_update_9501() {
$database = \Drupal::service('database');
if ($database->schema()->tableExists('tenant_data')) {
print "The 'tenant_data' table already exists";
return;
}
$schema = [
'description' => 'Stores module data as key/value pairs per tenant.',
'fields' => [
'tenant_id' => [
'description' => 'The {groups}.id this record affects.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
],
'module' => [
'description' => 'The name of the module declaring the variable.',
'type' => 'varchar_ascii',
'length' => DRUPAL_EXTENSION_NAME_MAX_LENGTH,
'not null' => TRUE,
'default' => '',
],
'name' => [
'description' => 'The identifier of the data.',
'type' => 'varchar_ascii',
'length' => 128,
'not null' => TRUE,
'default' => '',
],
'value' => [
'description' => 'The value.',
'type' => 'blob',
'not null' => FALSE,
'size' => 'big',
],
'serialized' => [
'description' => 'Whether value is serialized.',
'type' => 'int',
'size' => 'tiny',
'unsigned' => TRUE,
'default' => 0,
],
],
'primary key' => ['tenant_id', 'module', 'name'],
'indexes' => [
'module' => ['module'],
'name' => ['name'],
],
'foreign keys' => [
'data_user' => [
'table' => 'groups',
'columns' => [
'tenant_id' => 'tenant_id',
],
],
],
];
$database->schema()->createTable('tenant_data', $schema);
}