1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* webtrees: online genealogy |
5
|
|
|
* Copyright (C) 2024 webtrees development team |
6
|
|
|
* This program is free software: you can redistribute it and/or modify |
7
|
|
|
* it under the terms of the GNU General Public License as published by |
8
|
|
|
* the Free Software Foundation, either version 3 of the License, or |
9
|
|
|
* (at your option) any later version. |
10
|
|
|
* This program is distributed in the hope that it will be useful, |
11
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
12
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13
|
|
|
* GNU General Public License for more details. |
14
|
|
|
* You should have received a copy of the GNU General Public License |
15
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>. |
16
|
|
|
*/ |
17
|
|
|
|
18
|
|
|
declare(strict_types=1); |
19
|
|
|
|
20
|
|
|
namespace Fisharebest\Webtrees\DB; |
21
|
|
|
|
22
|
|
|
use Doctrine\DBAL\Schema\Schema; |
23
|
|
|
use Fisharebest\Webtrees\DB; |
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* Definitions for the webtrees database. |
27
|
|
|
*/ |
28
|
|
|
class WebtreesSchema |
29
|
|
|
{ |
30
|
|
|
/** |
31
|
|
|
* @return void |
32
|
|
|
*/ |
33
|
|
|
public function historicSchemaVersions(): void |
34
|
|
|
{ |
35
|
|
|
switch ('webtrees_schema') { |
36
|
|
|
case 1: // webtrees 1.0.0 - 1.0.3 |
37
|
|
|
case 2: // webtrees 1.0.4 |
38
|
|
|
case 3: |
39
|
|
|
case 4: // webtrees 1.0.5 |
40
|
|
|
case 5: // webtrees 1.0.6 |
41
|
|
|
case 6: |
42
|
|
|
case 7: |
43
|
|
|
case 8: |
44
|
|
|
case 9: // webtrees 1.1.0 - 1.1.1 |
45
|
|
|
case 10: // webtrees 1.1.2 |
46
|
|
|
case 11: // webtrees 1.2.0 |
47
|
|
|
case 12: // webtrees 1.2.1 - 1.2.3 |
48
|
|
|
case 13: |
49
|
|
|
case 14: |
50
|
|
|
case 15: // webtrees 1.2.4 - 1.2.5 |
51
|
|
|
case 16: // webtrees 1.2.7 |
52
|
|
|
case 17: |
53
|
|
|
case 18: // webtrees 1.3.0 |
54
|
|
|
case 19: // webtrees 1.3.1 |
55
|
|
|
case 20: // webtrees 1.3.2 |
56
|
|
|
case 21: |
57
|
|
|
case 22: |
58
|
|
|
case 23: // webtrees 1.4.0 - 1.4.1 |
59
|
|
|
case 24: |
60
|
|
|
case 25: // webtrees 1.4.2 - 1.4.4, 1.5.0 |
61
|
|
|
case 26: // webtrees 1.4.5 - 1.4.6 |
62
|
|
|
case 27: // webtrees 1.5.1 - 1.6.0 |
63
|
|
|
case 28: |
64
|
|
|
case 29: // webtrees 1.6.1 - 1.6.2 |
65
|
|
|
case 30: |
66
|
|
|
case 31: // webtrees 1.7.0 - 1.7.1 |
67
|
|
|
case 32: // webtrees 1.7.2 |
68
|
|
|
case 33: |
69
|
|
|
case 34: // webtrees 1.7.3 - 1.7.4 |
70
|
|
|
case 35: |
71
|
|
|
case 36: // webtrees 1.7.5 - 1.7.7 |
72
|
|
|
case 37: // webtrees 1.7.8 - 2.0.0 |
73
|
|
|
case 38: |
74
|
|
|
case 39: |
75
|
|
|
case 40: // webtrees 2.0.1 - 2.1.15 |
76
|
|
|
} |
77
|
|
|
} |
78
|
|
|
|
79
|
|
|
public static function tableBlock(): Table |
80
|
|
|
{ |
81
|
|
|
return new Table( |
82
|
|
|
'block', |
83
|
|
|
DB::integer(name: 'block_id')->autoincrement(), |
84
|
|
|
DB::integer(name: 'gedcom_id')->nullable(), |
85
|
|
|
DB::integer(name: 'user_id')->nullable(), |
86
|
|
|
DB::varchar(name: 'xref', length: 20)->nullable(), |
87
|
|
|
DB::char(name: 'location', length: 4)->nullable(), |
88
|
|
|
DB::integer(name: 'block_order'), |
89
|
|
|
DB::varchar(name: 'module_name', length: 32), |
90
|
|
|
DB::primaryKey(columns: ['block_id']), |
91
|
|
|
DB::index(columns: ['gedcom_id']), |
92
|
|
|
DB::index(columns: ['user_id']), |
93
|
|
|
DB::index(columns: ['module_name']), |
94
|
|
|
DB::foreignKey(local_columns: ['gedcom_id'], foreign_table: 'gedcom')->onDeleteCascade()->onUpdateCascade(), |
95
|
|
|
DB::foreignKey(local_columns: ['user_id'], foreign_table: 'user')->onDeleteCascade()->onUpdateCascade(), |
96
|
|
|
DB::foreignKey(local_columns: ['module_name'], foreign_table: 'module')->onDeleteCascade()->onUpdateCascade(), |
97
|
|
|
); |
98
|
|
|
} |
99
|
|
|
|
100
|
|
|
public static function tableBlockSetting(): Table |
101
|
|
|
{ |
102
|
|
|
return new Table( |
103
|
|
|
'block_setting', |
104
|
|
|
DB::integer(name: 'block_id'), |
105
|
|
|
DB::varchar(name: 'setting_name', length: 32), |
106
|
|
|
DB::text('setting_value'), |
107
|
|
|
DB::primaryKey(columns: ['block_id', 'setting_name']), |
108
|
|
|
DB::foreignKey(local_columns: ['block_id'], foreign_table: 'block')->onDeleteCascade()->onUpdateCascade(), |
109
|
|
|
); |
110
|
|
|
} |
111
|
|
|
|
112
|
|
|
public static function tableChange(): Table |
113
|
|
|
{ |
114
|
|
|
return new Table( |
115
|
|
|
'change', |
116
|
|
|
DB::integer(name: 'change_id')->autoincrement(), |
117
|
|
|
DB::timestamp(name: 'change_time')->default(default: 'CURRENT_TIMESTAMP'), |
118
|
|
|
DB::char(name: 'status', length: 8), |
119
|
|
|
DB::integer(name: 'gedcom_id'), |
120
|
|
|
DB::varchar(name: 'xref', length: 20), |
121
|
|
|
DB::text(name: 'old_gedcom'), |
122
|
|
|
DB::text(name: 'new_gedcom'), |
123
|
|
|
DB::integer(name: 'user_id'), |
124
|
|
|
DB::primaryKey(columns: ['change_id']), |
125
|
|
|
DB::index(columns: ['gedcom_id', 'status', 'xref']), |
126
|
|
|
DB::index(columns: ['user_id']), |
127
|
|
|
DB::foreignKey(local_columns: ['user_id'], foreign_table: 'user')->onDeleteCascade()->onUpdateCascade(), |
128
|
|
|
DB::foreignKey(local_columns: ['gedcom_id'], foreign_table: 'gedcom')->onDeleteCascade()->onUpdateCascade(), |
129
|
|
|
); |
130
|
|
|
} |
131
|
|
|
|
132
|
|
|
public static function tableDates(): Table |
133
|
|
|
{ |
134
|
|
|
return new Table( |
135
|
|
|
'dates', |
136
|
|
|
DB::integer(name: 'd_day'), |
137
|
|
|
DB::char(name: 'd_month', length: 5), |
138
|
|
|
DB::integer(name: 'd_mon'), |
139
|
|
|
DB::integer(name: 'd_year'), |
140
|
|
|
DB::integer(name: 'd_julianday1'), |
141
|
|
|
DB::integer(name: 'd_julianday2'), |
142
|
|
|
DB::varchar(name: 'd_fact', length: 15), |
143
|
|
|
DB::varchar(name: 'd_gid', length: 20), |
144
|
|
|
DB::integer(name: 'd_file'), |
145
|
|
|
DB::varchar(name: 'd_type', length: 13), |
146
|
|
|
DB::index(columns: ['d_day']), |
147
|
|
|
DB::index(columns: ['d_month']), |
148
|
|
|
DB::index(columns: ['d_mon']), |
149
|
|
|
DB::index(columns: ['d_year']), |
150
|
|
|
DB::index(columns: ['d_julianday1']), |
151
|
|
|
DB::index(columns: ['d_julianday2']), |
152
|
|
|
DB::index(columns: ['d_gid']), |
153
|
|
|
DB::index(columns: ['d_file']), |
154
|
|
|
DB::index(columns: ['d_type']), |
155
|
|
|
DB::index(columns: ['d_fact', 'd_gid']), |
156
|
|
|
DB::foreignKey(local_columns: ['d_file'], foreign_table: 'gedcom', foreign_columns: ['gedcom_id'])->onDeleteCascade()->onUpdateCascade(), |
157
|
|
|
); |
158
|
|
|
} |
159
|
|
|
|
160
|
|
|
public static function tableDefaultResn(): Table |
161
|
|
|
{ |
162
|
|
|
return new Table( |
163
|
|
|
'default_resn', |
164
|
|
|
DB::integer(name: 'default_resn_id')->autoincrement(), |
165
|
|
|
DB::integer(name: 'gedcom_id'), |
166
|
|
|
DB::varchar(name: 'xref', length: 20)->nullable(), |
167
|
|
|
DB::varchar(name: 'tag_type', length: 15)->nullable(), |
168
|
|
|
DB::varchar(name: 'resn', length: 12), |
169
|
|
|
DB::primaryKey(columns: ['default_resn_id']), |
170
|
|
|
DB::uniqueIndex(columns: ['gedcom_id', 'xref', 'tag_type']), |
171
|
|
|
DB::foreignKey(local_columns: ['gedcom_id'], foreign_table: 'gedcom')->onDeleteCascade()->onUpdateCascade(), |
172
|
|
|
); |
173
|
|
|
} |
174
|
|
|
|
175
|
|
|
public static function tableFamilies(): Table |
176
|
|
|
{ |
177
|
|
|
return new Table( |
178
|
|
|
'families', |
179
|
|
|
DB::varchar(name: 'f_id', length: 20), |
180
|
|
|
DB::integer(name: 'f_file'), |
181
|
|
|
DB::varchar(name: 'f_husb', length: 20)->nullable(), |
182
|
|
|
DB::varchar(name: 'f_wife', length: 20)->nullable(), |
183
|
|
|
DB::text(name: 'f_gedcom'), |
184
|
|
|
DB::integer(name: 'f_numchil'), |
185
|
|
|
DB::primaryKey(columns: ['f_file', 'f_id']), |
186
|
|
|
DB::uniqueIndex(columns: ['f_id', 'f_file']), |
187
|
|
|
DB::index(columns: ['f_file', 'f_husb']), |
188
|
|
|
DB::index(columns: ['f_file', 'f_wife']), |
189
|
|
|
DB::index(columns: ['f_file', 'f_numchil']), |
190
|
|
|
DB::foreignKey(local_columns: ['f_file'], foreign_table: 'gedcom', foreign_columns: ['gedcom_id'])->onDeleteCascade()->onUpdateCascade(), |
191
|
|
|
); |
192
|
|
|
} |
193
|
|
|
|
194
|
|
|
public static function tableFavorite(): Table |
195
|
|
|
{ |
196
|
|
|
return new Table( |
197
|
|
|
'favorite', |
198
|
|
|
DB::integer(name: 'favorite_id')->autoincrement(), |
199
|
|
|
DB::integer(name: 'user_id')->nullable(), |
200
|
|
|
DB::integer(name: 'gedcom_id'), |
201
|
|
|
DB::varchar(name: 'xref', length: 20)->nullable(), |
202
|
|
|
DB::char(name: 'favorite_type', length: 4), |
203
|
|
|
DB::varchar(name: 'url', length: 255)->nullable(), |
204
|
|
|
DB::varchar(name: 'title', length: 255)->nullable(), |
205
|
|
|
DB::varchar(name: 'note', length: 1000)->nullable(), |
206
|
|
|
DB::primaryKey(columns: ['favorite_id']), |
207
|
|
|
DB::index(columns: ['user_id']), |
208
|
|
|
DB::index(columns: ['gedcom_id', 'user_id']), |
209
|
|
|
DB::foreignKey(local_columns: ['user_id'], foreign_table: 'user')->onDeleteCascade()->onUpdateCascade(), |
210
|
|
|
DB::foreignKey(local_columns: ['gedcom_id'], foreign_table: 'gedcom')->onDeleteCascade()->onUpdateCascade(), |
211
|
|
|
); |
212
|
|
|
} |
213
|
|
|
|
214
|
|
|
public static function tableFile(): Table |
215
|
|
|
{ |
216
|
|
|
return new Table( |
217
|
|
|
'file', |
218
|
|
|
DB::nvarchar(name: 'name', length: 255), |
219
|
|
|
DB::integer(name: 'size')->nullable(), |
220
|
|
|
DB::integer(name: 'last_modified')->nullable(), |
221
|
|
|
DB::varchar(name: 'mime_type', length: 255)->nullable(), |
222
|
|
|
DB::nvarchar(name: 'sha1', length: 40)->nullable(), |
223
|
|
|
DB::integer(name: 'file_exists')->nullable(), |
224
|
|
|
DB::primaryKey(['name']), |
225
|
|
|
DB::index(columns: ['sha1']), |
226
|
|
|
DB::index(columns: ['size']), |
227
|
|
|
DB::index(columns: ['mime_type']), |
228
|
|
|
DB::index(columns: ['last_modified']), |
229
|
|
|
); |
230
|
|
|
} |
231
|
|
|
|
232
|
|
|
public static function tableGedcom(): Table |
233
|
|
|
{ |
234
|
|
|
return new Table( |
235
|
|
|
'gedcom', |
236
|
|
|
DB::integer(name: 'gedcom_id')->autoincrement(), |
237
|
|
|
DB::nvarchar(name: 'gedcom_name', length: 255), |
238
|
|
|
DB::integer(name: 'sort_order')->default(default: 0), |
239
|
|
|
DB::primaryKey(columns: ['gedcom_id']), |
240
|
|
|
DB::uniqueIndex(columns: ['gedcom_name']), |
241
|
|
|
DB::index(columns: ['sort_order']), |
242
|
|
|
); |
243
|
|
|
} |
244
|
|
|
|
245
|
|
|
public static function tableGedcomChunk(): Table |
246
|
|
|
{ |
247
|
|
|
return new Table( |
248
|
|
|
'gedcom_chunk', |
249
|
|
|
DB::integer(name: 'gedcom_chunk_id')->autoincrement(), |
250
|
|
|
DB::integer(name: 'gedcom_id'), |
251
|
|
|
DB::text(name: 'chunk_data'), |
252
|
|
|
DB::integer(name: 'imported')->default(default: 0), |
253
|
|
|
DB::primaryKey(columns: ['gedcom_chunk_id']), |
254
|
|
|
DB::index(columns: ['gedcom_id', 'imported']), |
255
|
|
|
DB::foreignKey(local_columns: ['gedcom_id'], foreign_table: 'gedcom')->onDeleteCascade()->onUpdateCascade(), |
256
|
|
|
); |
257
|
|
|
} |
258
|
|
|
|
259
|
|
|
public static function tableGedcomSetting(): Table |
260
|
|
|
{ |
261
|
|
|
return new Table( |
262
|
|
|
'gedcom_setting', |
263
|
|
|
DB::integer('gedcom_id'), |
264
|
|
|
DB::varchar('setting_name', length: 32), |
265
|
|
|
DB::nvarchar('setting_value', length: 255), |
266
|
|
|
DB::primaryKey(columns: ['gedcom_id', 'setting_name']), |
267
|
|
|
DB::foreignKey(local_columns: ['gedcom_id'], foreign_table: 'gedcom')->onDeleteCascade()->onUpdateCascade(), |
268
|
|
|
); |
269
|
|
|
} |
270
|
|
|
|
271
|
|
|
public static function tableHitCounter(): Table |
272
|
|
|
{ |
273
|
|
|
return new Table( |
274
|
|
|
'hit_counter', |
275
|
|
|
DB::integer('gedcom_id'), |
276
|
|
|
DB::varchar('page_name', length: 32), |
277
|
|
|
DB::varchar('page_parameter', length: 32), |
278
|
|
|
DB::integer('page_count'), |
279
|
|
|
DB::primaryKey(columns: ['gedcom_id', 'page_name', 'page_parameter']), |
280
|
|
|
DB::foreignKey(local_columns: ['gedcom_id'], foreign_table: 'gedcom')->onDeleteCascade()->onUpdateCascade(), |
281
|
|
|
); |
282
|
|
|
} |
283
|
|
|
|
284
|
|
|
public static function tableIndividuals(): Table |
285
|
|
|
{ |
286
|
|
|
return new Table( |
287
|
|
|
'individuals', |
288
|
|
|
DB::varchar(name: 'i_id', length: 20), |
289
|
|
|
DB::integer(name: 'i_file'), |
290
|
|
|
DB::varchar(name: 'i_rin', length: 20), |
291
|
|
|
DB::char(name: 'i_sex', length: 1), |
292
|
|
|
DB::text(name: 'i_gedcom'), |
293
|
|
|
DB::primaryKey(columns: ['i_id', 'i_file']), |
294
|
|
|
DB::uniqueIndex(columns: ['i_file', 'i_id']), |
295
|
|
|
DB::index(columns: ['i_file', 'i_sex']), |
296
|
|
|
DB::foreignKey(local_columns: ['i_file'], foreign_table: 'gedcom', foreign_columns: ['gedcom_id'])->onDeleteCascade()->onUpdateCascade(), |
297
|
|
|
); |
298
|
|
|
} |
299
|
|
|
|
300
|
|
|
public static function tableJob(): Table |
301
|
|
|
{ |
302
|
|
|
return new Table( |
303
|
|
|
'job', |
304
|
|
|
DB::integer(name: 'job_id')->autoincrement(), |
305
|
|
|
DB::varchar(name: 'job_status', length: 15)->default('queued'), |
306
|
|
|
DB::integer(name: 'fail_count')->default(0), |
307
|
|
|
DB::timestamp(name: 'queued_at')->default(default: 'CURRENT_TIMESTAMP'), |
308
|
|
|
DB::timestamp(name: 'queued_at'), |
309
|
|
|
DB::primaryKey(columns: ['job_id']), |
310
|
|
|
); |
311
|
|
|
} |
312
|
|
|
|
313
|
|
|
public static function tableLink(): Table |
314
|
|
|
{ |
315
|
|
|
return new Table( |
316
|
|
|
'link', |
317
|
|
|
DB::integer(name: 'l_file'), |
318
|
|
|
DB::varchar(name: 'l_from', length: 20), |
319
|
|
|
DB::varchar(name: 'l_type', length: 15), |
320
|
|
|
DB::varchar(name: 'l_to', length: 20), |
321
|
|
|
DB::primaryKey(columns: ['l_from', 'l_file', 'l_type', 'l_to']), |
322
|
|
|
DB::uniqueIndex(columns: ['l_to', 'l_file', 'l_type', 'l_from']), |
323
|
|
|
DB::foreignKey(local_columns: ['l_file'], foreign_table: 'gedcom', foreign_columns: ['gedcom_id'])->onDeleteCascade()->onUpdateCascade(), |
324
|
|
|
); |
325
|
|
|
} |
326
|
|
|
|
327
|
|
|
public static function tableLog(): Table |
328
|
|
|
{ |
329
|
|
|
return new Table( |
330
|
|
|
'log', |
331
|
|
|
DB::integer(name: 'log_id')->autoincrement(), |
332
|
|
|
DB::timestamp(name: 'log_time')->default(default: 'CURRENT_TIMESTAMP'), |
333
|
|
|
DB::varchar(name: 'log_type', length: 6), |
334
|
|
|
DB::text(name: 'log_message'), |
335
|
|
|
DB::varchar(name: 'ip_address', length: 45), |
336
|
|
|
DB::integer(name: 'user_id')->nullable(), |
337
|
|
|
DB::integer(name: 'gedcom_id')->nullable(), |
338
|
|
|
DB::primaryKey(columns: ['log_id']), |
339
|
|
|
DB::index(columns: ['gedcom_id']), |
340
|
|
|
DB::index(columns: ['user_id']), |
341
|
|
|
DB::index(columns: ['log_time']), |
342
|
|
|
DB::index(columns: ['log_type']), |
343
|
|
|
DB::index(columns: ['ip_address']), |
344
|
|
|
DB::foreignKey(local_columns: ['user_id'], foreign_table: 'user')->onDeleteSetNull()->onUpdateCascade(), |
345
|
|
|
DB::foreignKey(local_columns: ['gedcom_id'], foreign_table: 'gedcom')->onDeleteSetNull()->onUpdateCascade(), |
346
|
|
|
); |
347
|
|
|
} |
348
|
|
|
|
349
|
|
|
public static function tableMedia(): Table |
350
|
|
|
{ |
351
|
|
|
return new Table( |
352
|
|
|
'media', |
353
|
|
|
DB::varchar(name: 'm_id', length: 20), |
354
|
|
|
DB::integer(name: 'm_file'), |
355
|
|
|
DB::text(name: 'm_gedcom'), |
356
|
|
|
DB::primaryKey(columns: ['m_file', 'm_id']), |
357
|
|
|
DB::uniqueIndex(columns: ['m_id', 'm_file']), |
358
|
|
|
DB::foreignKey(local_columns: ['m_file'], foreign_table: 'gedcom', foreign_columns: ['gedcom_id'])->onDeleteCascade()->onUpdateCascade(), |
359
|
|
|
); |
360
|
|
|
} |
361
|
|
|
|
362
|
|
|
public static function tableMediaFile(): Table |
363
|
|
|
{ |
364
|
|
|
return new Table( |
365
|
|
|
'media_file', |
366
|
|
|
DB::integer(name: 'id')->autoincrement(), |
367
|
|
|
DB::varchar(name: 'm_id', length: 20), |
368
|
|
|
DB::integer(name: 'm_file'), |
369
|
|
|
DB::nvarchar(name: 'multimedia_file_refn', length: 248), |
370
|
|
|
DB::nvarchar(name: 'multimedia_format', length: 4), |
371
|
|
|
DB::nvarchar(name: 'source_media_type', length: 15), |
372
|
|
|
DB::nvarchar(name: 'descriptive_title', length: 248), |
373
|
|
|
DB::primaryKey(columns: ['id']), |
374
|
|
|
DB::index(columns: ['m_id', 'm_file']), |
375
|
|
|
DB::index(columns: ['m_file', 'm_id']), |
376
|
|
|
DB::index(columns: ['m_file', 'multimedia_file_refn']), |
377
|
|
|
DB::index(columns: ['m_file', 'multimedia_format']), |
378
|
|
|
DB::index(columns: ['m_file', 'source_media_type']), |
379
|
|
|
DB::index(columns: ['m_file', 'descriptive_title']), |
380
|
|
|
); |
381
|
|
|
} |
382
|
|
|
|
383
|
|
|
public static function tableMessage(): Table |
384
|
|
|
{ |
385
|
|
|
return new Table( |
386
|
|
|
'message', |
387
|
|
|
DB::integer(name: 'message_id')->autoincrement(), |
388
|
|
|
DB::nvarchar(name: 'sender', length: 64), |
389
|
|
|
DB::varchar(name: 'ip_address', length: 45), |
390
|
|
|
DB::integer(name: 'user_id'), |
391
|
|
|
DB::nvarchar(name: 'subject', length: 255), |
392
|
|
|
DB::text(name: 'body'), |
393
|
|
|
DB::timestamp(name: 'created')->default(default: 'CURRENT_TIMESTAMP'), |
394
|
|
|
DB::primaryKey(columns: ['message_id']), |
395
|
|
|
DB::index(columns: ['user_id']), |
396
|
|
|
DB::foreignKey(local_columns: ['user_id'], foreign_table: 'user')->onDeleteCascade()->onUpdateCascade(), |
397
|
|
|
); |
398
|
|
|
} |
399
|
|
|
|
400
|
|
|
public static function tableModule(): Table |
401
|
|
|
{ |
402
|
|
|
return new Table( |
403
|
|
|
'module', |
404
|
|
|
DB::varchar(name: 'module_name', length: 32), |
405
|
|
|
DB::char(name: 'status', length: 8)->default(default: 'enabled'), |
406
|
|
|
DB::integer(name: 'tab_order')->nullable(), |
407
|
|
|
DB::integer(name: 'menu_order')->nullable(), |
408
|
|
|
DB::integer(name: 'sidebar_order')->nullable(), |
409
|
|
|
DB::integer(name: 'footer_order')->nullable(), |
410
|
|
|
DB::primaryKey(columns: ['module_name']), |
411
|
|
|
); |
412
|
|
|
} |
413
|
|
|
|
414
|
|
|
public static function tableModulePrivacy(): Table |
415
|
|
|
{ |
416
|
|
|
return new Table( |
417
|
|
|
'module_privacy', |
418
|
|
|
DB::integer(name: 'id')->autoincrement(), |
419
|
|
|
DB::varchar(name: 'module_name', length: 32), |
420
|
|
|
DB::integer(name: 'gedcom_id'), |
421
|
|
|
DB::varchar(name: 'interface', length: 255), |
422
|
|
|
DB::integer(name: 'access_level'), |
423
|
|
|
DB::primaryKey(columns: ['id']), |
424
|
|
|
DB::uniqueIndex(columns: ['gedcom_id', 'module_name', 'interface']), |
425
|
|
|
DB::uniqueIndex(columns: ['module_name', 'gedcom_id', 'interface']), |
426
|
|
|
DB::foreignKey(local_columns: ['gedcom_id'], foreign_table: 'gedcom')->onDeleteCascade()->onUpdateCascade(), |
427
|
|
|
DB::foreignKey(local_columns: ['module_name'], foreign_table: 'module')->onDeleteCascade()->onUpdateCascade(), |
428
|
|
|
); |
429
|
|
|
} |
430
|
|
|
|
431
|
|
|
public static function tableModuleSetting(): Table |
432
|
|
|
{ |
433
|
|
|
return new Table( |
434
|
|
|
'module_setting', |
435
|
|
|
DB::varchar(name: 'module_name', length: 32), |
436
|
|
|
DB::varchar(name: 'setting_name', length: 32), |
437
|
|
|
DB::text(name: 'setting_value'), |
438
|
|
|
DB::primaryKey(columns: ['module_name', 'setting_name']), |
439
|
|
|
DB::foreignKey(local_columns: ['module_name'], foreign_table: 'module')->onDeleteCascade()->onUpdateCascade(), |
440
|
|
|
); |
441
|
|
|
} |
442
|
|
|
|
443
|
|
|
public static function tableName(): Table |
444
|
|
|
{ |
445
|
|
|
return new Table( |
446
|
|
|
'name', |
447
|
|
|
DB::integer(name: 'n_file'), |
448
|
|
|
DB::varchar(name: 'n_id', length: 20), |
449
|
|
|
DB::integer(name: 'n_num'), |
450
|
|
|
DB::varchar(name: 'n_type', length: 15), |
451
|
|
|
DB::nvarchar(name: 'n_sort', length: 255), |
452
|
|
|
DB::nvarchar(name: 'n_full', length: 255), |
453
|
|
|
DB::nvarchar(name: 'n_surname', length: 255)->nullable(), |
454
|
|
|
DB::nvarchar(name: 'n_surn', length: 255)->nullable(), |
455
|
|
|
DB::nvarchar(name: 'n_givn', length: 255)->nullable(), |
456
|
|
|
DB::varchar(name: 'n_soundex_givn_std', length: 255)->nullable(), |
457
|
|
|
DB::varchar(name: 'n_soundex_surn_std', length: 255)->nullable(), |
458
|
|
|
DB::varchar(name: 'n_soundex_givn_dm', length: 255)->nullable(), |
459
|
|
|
DB::varchar(name: 'n_soundex_surn_dm', length: 255)->nullable(), |
460
|
|
|
DB::primaryKey(columns: ['n_id', 'n_file', 'n_num']), |
461
|
|
|
DB::index(columns: ['n_full', 'n_id', 'n_file']), |
462
|
|
|
DB::index(columns: ['n_givn', 'n_file', 'n_type', 'n_id']), |
463
|
|
|
DB::index(columns: ['n_surn', 'n_file', 'n_type', 'n_id']), |
464
|
|
|
DB::foreignKey(local_columns: ['n_file', 'n_id'], foreign_table: 'individuals', foreign_columns: ['i_file', 'i_id'])->onDeleteCascade()->onUpdateCascade(), |
465
|
|
|
); |
466
|
|
|
} |
467
|
|
|
|
468
|
|
|
public static function tableNews(): Table |
469
|
|
|
{ |
470
|
|
|
return new Table( |
471
|
|
|
'news', |
472
|
|
|
DB::integer(name: 'news_id')->autoincrement(), |
473
|
|
|
DB::integer(name: 'user_id')->nullable(), |
474
|
|
|
DB::integer(name: 'gedcom_id')->nullable(), |
475
|
|
|
DB::nvarchar(name: 'subject', length: 255), |
476
|
|
|
DB::text(name: 'body'), |
477
|
|
|
DB::timestamp(name: 'updated')->default(default: 'CURRENT_TIMESTAMP'), |
478
|
|
|
DB::primaryKey(columns: ['news_id']), |
479
|
|
|
DB::foreignKey(local_columns: ['user_id'], foreign_table: 'user')->onDeleteCascade()->onUpdateCascade(), |
480
|
|
|
DB::foreignKey(local_columns: ['gedcom_id'], foreign_table: 'gedcom')->onDeleteCascade()->onUpdateCascade(), |
481
|
|
|
); |
482
|
|
|
} |
483
|
|
|
|
484
|
|
|
public static function tableOther(): Table |
485
|
|
|
{ |
486
|
|
|
return new Table( |
487
|
|
|
'other', |
488
|
|
|
DB::varchar(name: 'o_id', length: 20), |
489
|
|
|
DB::integer(name: 'o_file'), |
490
|
|
|
DB::varchar(name: 'o_type', length: 15), |
491
|
|
|
DB::text(name: 'o_gedcom'), |
492
|
|
|
DB::primaryKey(columns: ['o_file', 'o_id']), |
493
|
|
|
DB::uniqueIndex(columns: ['o_id', 'o_file']), |
494
|
|
|
DB::foreignKey(local_columns: ['o_file'], foreign_table: 'gedcom', foreign_columns: ['gedcom_id'])->onDeleteCascade()->onUpdateCascade(), |
495
|
|
|
); |
496
|
|
|
} |
497
|
|
|
|
498
|
|
|
public static function tablePlaceLocation(): Table |
499
|
|
|
{ |
500
|
|
|
return new Table( |
501
|
|
|
'place_location', |
502
|
|
|
DB::integer(name: 'id')->autoincrement(), |
503
|
|
|
DB::integer(name: 'parent_id')->nullable(), |
504
|
|
|
DB::nvarchar(name: 'place', length: 120), |
505
|
|
|
DB::float(name: 'latitude')->nullable(), |
506
|
|
|
DB::float(name: 'longitude')->nullable(), |
507
|
|
|
DB::primaryKey(columns: ['id']), |
508
|
|
|
DB::uniqueIndex(columns: ['parent_id', 'place']), |
509
|
|
|
DB::uniqueIndex(columns: ['place', 'parent_id']), |
510
|
|
|
DB::foreignKey(local_columns: ['parent_id'], foreign_table: 'place_location', foreign_columns: ['id']), |
511
|
|
|
DB::index(columns: ['latitude']), |
512
|
|
|
DB::index(columns: ['longitude']), |
513
|
|
|
); |
514
|
|
|
} |
515
|
|
|
|
516
|
|
|
public static function tablePlaceLinks(): Table |
517
|
|
|
{ |
518
|
|
|
return new Table( |
519
|
|
|
'placelinks', |
520
|
|
|
DB::integer(name: 'pl_p_id'), |
521
|
|
|
DB::varchar(name: 'pl_gid', length: 20), |
522
|
|
|
DB::integer(name: 'pl_file'), |
523
|
|
|
DB::primaryKey(columns: ['pl_p_id', 'pl_gid', 'pl_file']), |
524
|
|
|
DB::index(columns: ['pl_p_id']), |
525
|
|
|
DB::index(columns: ['pl_gid']), |
526
|
|
|
DB::index(columns: ['pl_file']), |
527
|
|
|
DB::foreignKey(local_columns: ['pl_file'], foreign_table: 'gedcom', foreign_columns: ['gedcom_id'])->onDeleteCascade()->onUpdateCascade(), |
528
|
|
|
); |
529
|
|
|
} |
530
|
|
|
|
531
|
|
|
public static function tablePlaces(): Table |
532
|
|
|
{ |
533
|
|
|
return new Table( |
534
|
|
|
'places', |
535
|
|
|
DB::integer(name: 'p_id')->autoincrement(), |
536
|
|
|
DB::nvarchar(name: 'p_place', length: 150), |
537
|
|
|
DB::integer(name: 'p_parent_id')->nullable(), |
538
|
|
|
DB::integer(name: 'p_file'), |
539
|
|
|
DB::text(name: 'p_std_soundex'), |
540
|
|
|
DB::text(name: 'p_dm_soundex'), |
541
|
|
|
DB::primaryKey(columns: ['p_id']), |
542
|
|
|
DB::uniqueIndex(columns: ['p_parent_id', 'p_file', 'p_place']), |
543
|
|
|
DB::foreignKey(local_columns: ['p_file'], foreign_table: 'gedcom', foreign_columns: ['gedcom_id'])->onDeleteCascade()->onUpdateCascade(), |
544
|
|
|
); |
545
|
|
|
} |
546
|
|
|
|
547
|
|
|
public static function tableSession(): Table |
548
|
|
|
{ |
549
|
|
|
return new Table( |
550
|
|
|
'session', |
551
|
|
|
DB::varchar(name: 'session_id', length: 32), |
552
|
|
|
DB::timestamp(name: 'session_time')->default(default: 'CURRENT_TIMESTAMP'), |
553
|
|
|
DB::integer(name: 'user_id')->nullable(), |
554
|
|
|
DB::varchar(name: 'ip_address', length: 45), |
555
|
|
|
DB::text(name: 'session_data'), |
556
|
|
|
DB::primaryKey(columns: ['session_id']), |
557
|
|
|
DB::index(columns: ['session_time']), |
558
|
|
|
DB::index(columns: ['user_id', 'ip_address']), |
559
|
|
|
DB::foreignKey(local_columns: ['user_id'], foreign_table: 'user')->onDeleteCascade()->onUpdateCascade(), |
560
|
|
|
); |
561
|
|
|
} |
562
|
|
|
|
563
|
|
|
public static function tableSiteSetting(): Table |
564
|
|
|
{ |
565
|
|
|
return new Table( |
566
|
|
|
'site_setting', |
567
|
|
|
DB::varchar(name: 'setting_name', length: 32), |
568
|
|
|
DB::nvarchar(name: 'setting_value', length: 2000), |
569
|
|
|
DB::primaryKey(columns: ['setting_name']), |
570
|
|
|
); |
571
|
|
|
} |
572
|
|
|
|
573
|
|
|
public static function tableSources(): Table |
574
|
|
|
{ |
575
|
|
|
return new Table( |
576
|
|
|
'sources', |
577
|
|
|
DB::varchar(name: 's_id', length: 20), |
578
|
|
|
DB::integer(name: 's_file'), |
579
|
|
|
DB::nvarchar(name: 's_name', length: 255), |
580
|
|
|
DB::text(name: 's_gedcom'), |
581
|
|
|
DB::primaryKey(columns: ['s_file', 's_id']), |
582
|
|
|
DB::uniqueIndex(columns: ['s_id', 's_file']), |
583
|
|
|
DB::index(columns: ['s_file', 's_name']), |
584
|
|
|
DB::foreignKey(local_columns: ['s_file'], foreign_table: 'gedcom', foreign_columns: ['gedcom_id'])->onDeleteCascade()->onUpdateCascade(), |
585
|
|
|
); |
586
|
|
|
} |
587
|
|
|
|
588
|
|
|
public static function tableUser(): Table |
589
|
|
|
{ |
590
|
|
|
return new Table( |
591
|
|
|
'user', |
592
|
|
|
DB::integer('user_id')->autoincrement(), |
593
|
|
|
DB::nvarchar('user_name', length: 32), |
594
|
|
|
DB::nvarchar('real_name', length: 64), |
595
|
|
|
DB::nvarchar('email', length: 64), |
596
|
|
|
DB::varchar('password', length: 128), |
597
|
|
|
DB::primaryKey(columns: ['user_id']), |
598
|
|
|
DB::uniqueIndex(columns: ['user_name']), |
599
|
|
|
DB::uniqueIndex(columns: ['email']), |
600
|
|
|
); |
601
|
|
|
} |
602
|
|
|
|
603
|
|
|
public static function tableUserGedcomSetting(): Table |
604
|
|
|
{ |
605
|
|
|
return new Table( |
606
|
|
|
'user_gedcom_setting', |
607
|
|
|
DB::integer(name: 'user_id'), |
608
|
|
|
DB::integer(name: 'gedcom_id'), |
609
|
|
|
DB::varchar(name: 'setting_name', length: 32), |
610
|
|
|
DB::nvarchar(name: 'setting_value', length: 255), |
611
|
|
|
DB::primaryKey(columns: ['user_id', 'gedcom_id', 'setting_name']), |
612
|
|
|
DB::index(columns: ['gedcom_id']), |
613
|
|
|
DB::foreignKey(local_columns: ['user_id'], foreign_table: 'user')->onDeleteCascade()->onUpdateCascade(), |
614
|
|
|
DB::foreignKey(local_columns: ['gedcom_id'], foreign_table: 'gedcom')->onDeleteCascade()->onUpdateCascade(), |
615
|
|
|
); |
616
|
|
|
} |
617
|
|
|
|
618
|
|
|
public static function tableUserSetting(): Table |
619
|
|
|
{ |
620
|
|
|
return new Table( |
621
|
|
|
'user_setting', |
622
|
|
|
DB::integer(name: 'user_id'), |
623
|
|
|
DB::varchar(name: 'setting_name', length: 32), |
624
|
|
|
DB::nvarchar(name: 'setting_value', length: 255), |
625
|
|
|
DB::primaryKey(columns: ['user_id', 'setting_name']), |
626
|
|
|
DB::foreignKey(local_columns: ['user_id'], foreign_table: 'user')->onDeleteCascade()->onUpdateCascade(), |
627
|
|
|
); |
628
|
|
|
} |
629
|
|
|
|
630
|
|
|
public static function schema(): Schema |
631
|
|
|
{ |
632
|
|
|
return new Schema( |
633
|
|
|
[ |
634
|
|
|
self::tableBlock(), |
635
|
|
|
self::tableBlockSetting(), |
636
|
|
|
self::tableChange(), |
637
|
|
|
self::tableDates(), |
638
|
|
|
self::tableDefaultResn(), |
639
|
|
|
self::tableFamilies(), |
640
|
|
|
self::tableFavorite(), |
641
|
|
|
//self::tableFile(), |
642
|
|
|
self::tableGedcom(), |
643
|
|
|
self::tableGedcomChunk(), |
644
|
|
|
self::tableGedcomSetting(), |
645
|
|
|
self::tableHitCounter(), |
646
|
|
|
self::tableIndividuals(), |
647
|
|
|
//self::tableJob(), |
648
|
|
|
self::tableLink(), |
649
|
|
|
self::tableLog(), |
650
|
|
|
self::tableMedia(), |
651
|
|
|
self::tableMediaFile(), |
652
|
|
|
self::tableMessage(), |
653
|
|
|
self::tableModule(), |
654
|
|
|
self::tableModulePrivacy(), |
655
|
|
|
self::tableModuleSetting(), |
656
|
|
|
self::tableName(), |
657
|
|
|
self::tableNews(), |
658
|
|
|
self::tableOther(), |
659
|
|
|
self::tablePlaceLocation(), |
660
|
|
|
self::tablePlaceLinks(), |
661
|
|
|
self::tablePlaces(), |
662
|
|
|
self::tableSession(), |
663
|
|
|
self::tableSiteSetting(), |
664
|
|
|
self::tableSources(), |
665
|
|
|
self::tableUser(), |
666
|
|
|
self::tableUserGedcomSetting(), |
667
|
|
|
self::tableUserSetting(), |
668
|
|
|
], |
669
|
|
|
); |
670
|
|
|
} |
671
|
|
|
} |
672
|
|
|
|