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