|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* webtrees: online genealogy |
|
5
|
|
|
* Copyright (C) 2022 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\Connection; |
|
|
|
|
|
|
23
|
|
|
use Doctrine\DBAL\Platforms\AbstractMySQLPlatform; |
|
24
|
|
|
use Doctrine\DBAL\Schema\SchemaException; |
|
25
|
|
|
use Doctrine\DBAL\Types\Type; |
|
26
|
|
|
use Doctrine\DBAL\Types\Types; |
|
27
|
|
|
use Exception; |
|
28
|
|
|
|
|
29
|
|
|
/** |
|
30
|
|
|
* Definitions for the webtrees database. |
|
31
|
|
|
*/ |
|
32
|
|
|
class WebtreesSchema |
|
33
|
|
|
{ |
|
34
|
|
|
public function foo(): 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
|
|
|
/** |
|
81
|
|
|
* @param Connection $connection |
|
82
|
|
|
* |
|
83
|
|
|
* @return void |
|
84
|
|
|
* |
|
85
|
|
|
* @throws SchemaException |
|
86
|
|
|
* @throws \Doctrine\DBAL\Exception |
|
87
|
|
|
*/ |
|
88
|
|
|
public static function migrate(Connection $connection): void |
|
89
|
|
|
{ |
|
90
|
|
|
$prefix = $connection->prefix; |
|
91
|
|
|
$platform = $connection->getDatabasePlatform(); |
|
92
|
|
|
|
|
93
|
|
|
if ($platform instanceof AbstractMySQLPlatform) { |
|
94
|
|
|
$ascii_bin = ['collation' => 'ascii_bin']; |
|
95
|
|
|
$utf8_bin = ['collation' => 'utf8mb4_bin']; |
|
96
|
|
|
//$ascii_bin = []; |
|
97
|
|
|
//$utf8_bin = []; |
|
98
|
|
|
} else { |
|
99
|
|
|
$ascii_bin = []; |
|
100
|
|
|
$utf8_bin = []; |
|
101
|
|
|
} |
|
102
|
|
|
|
|
103
|
|
|
// Existing MySQL databases may have enum columns. |
|
104
|
|
|
$platform->registerDoctrineTypeMapping('enum', 'string'); |
|
105
|
|
|
|
|
106
|
|
|
// Timestamp |
|
107
|
|
|
if (!Type::hasType(Timestamp::NAME)) { |
|
108
|
|
|
Type::addType(Timestamp::NAME, Timestamp::class); |
|
109
|
|
|
} |
|
110
|
|
|
|
|
111
|
|
|
$schema = new Schema($prefix); |
|
112
|
|
|
|
|
113
|
|
|
$table_gedcom = $schema->createTable('gedcom'); |
|
114
|
|
|
$table_gedcom->addColumn('gedcom_id', Types::INTEGER, ['autoincrement' => true]); |
|
115
|
|
|
$table_gedcom->addColumn('gedcom_name', Types::STRING, ['length' => 255, 'platformOptions' => $utf8_bin]); |
|
116
|
|
|
$table_gedcom->addColumn('sort_order', Types::INTEGER, ['default' => 0]); |
|
117
|
|
|
$table_gedcom->setPrimaryKey(['gedcom_id']); |
|
118
|
|
|
$table_gedcom->addUniqueIndex(['gedcom_name']); |
|
119
|
|
|
$table_gedcom->addIndex(['sort_order']); |
|
120
|
|
|
|
|
121
|
|
|
$table_user = $schema->createTable('user'); |
|
122
|
|
|
$table_user->addColumn('user_id', Types::INTEGER, ['autoincrement' => true]); |
|
123
|
|
|
$table_user->addColumn('user_name', Types::STRING, ['length' => 32, 'platformOptions' => $utf8_bin]); |
|
124
|
|
|
$table_user->addColumn('real_name', Types::STRING, ['length' => 64, 'platformOptions' => $utf8_bin]); |
|
125
|
|
|
$table_user->addColumn('email', Types::STRING, ['length' => 64, 'platformOptions' => $utf8_bin]); |
|
126
|
|
|
$table_user->addColumn('password', Types::STRING, ['length' => 128, 'platformOptions' => $utf8_bin]); |
|
127
|
|
|
$table_user->setPrimaryKey(['user_id']); |
|
128
|
|
|
$table_user->addUniqueIndex(['user_name']); |
|
129
|
|
|
$table_user->addUniqueIndex(['email']); |
|
130
|
|
|
|
|
131
|
|
|
$table_module = $schema->createTable('module'); |
|
132
|
|
|
$table_module->addColumn('module_name', Types::STRING, ['length' => 32, 'platformOptions' => $utf8_bin]); |
|
133
|
|
|
$table_module->addColumn('status', Types::STRING, ['length' => 8, 'platformOptions' => $ascii_bin]); |
|
134
|
|
|
$table_module->addColumn('tab_order', Types::INTEGER, ['notnull' => false]); |
|
135
|
|
|
$table_module->addColumn('menu_order', Types::INTEGER, ['notnull' => false]); |
|
136
|
|
|
$table_module->addColumn('sidebar_order', Types::INTEGER, ['notnull' => false]); |
|
137
|
|
|
$table_module->addColumn('footer_order', Types::INTEGER, ['notnull' => false]); |
|
138
|
|
|
$table_module->setPrimaryKey(['module_name']); |
|
139
|
|
|
|
|
140
|
|
|
$table_block = $schema->createTable('block'); |
|
141
|
|
|
$table_block->addColumn('block_id', Types::INTEGER, ['autoincrement' => true]); |
|
142
|
|
|
$table_block->addColumn('gedcom_id', Types::INTEGER, ['notnull' => false]); |
|
143
|
|
|
$table_block->addColumn('user_id', Types::INTEGER, ['notnull' => false]); |
|
144
|
|
|
$table_block->addColumn('xref', Types::STRING, ['length' => 20, 'notnull' => false, 'platformOptions' => $ascii_bin]); |
|
145
|
|
|
$table_block->addColumn('location', Types::STRING, ['length' => 4, 'notnull' => false, 'platformOptions' => $ascii_bin]); |
|
146
|
|
|
$table_block->addColumn('block_order', Types::INTEGER); |
|
147
|
|
|
$table_block->addColumn('module_name', Types::STRING, ['length' => 32, 'platformOptions' => $utf8_bin]); |
|
148
|
|
|
$table_block->setPrimaryKey(['block_id']); |
|
149
|
|
|
$table_block->addForeignKeyConstraint($table_gedcom->getName(), ['gedcom_id'], ['gedcom_id'], ['onDelete' => 'CASCADE', 'onUpdate' => 'CASCADE']); |
|
150
|
|
|
$table_block->addForeignKeyConstraint($table_user->getName(), ['user_id'], ['user_id'], ['onDelete' => 'CASCADE', 'onUpdate' => 'CASCADE']); |
|
151
|
|
|
$table_block->addForeignKeyConstraint($table_module->getName(), ['module_name'], ['module_name'], ['onDelete' => 'CASCADE', 'onUpdate' => 'CASCADE']); |
|
152
|
|
|
|
|
153
|
|
|
$table_block_setting = $schema->createTable('block_setting'); |
|
154
|
|
|
$table_block_setting->addColumn('block_id', Types::INTEGER); |
|
155
|
|
|
$table_block_setting->addColumn('setting_name', Types::STRING, ['length' => 32, 'platformOptions' => $ascii_bin]); |
|
156
|
|
|
$table_block_setting->addColumn('setting_value', Types::TEXT, ['platformOptions' => $utf8_bin]); |
|
157
|
|
|
$table_block_setting->setPrimaryKey(['block_id', 'setting_name']); |
|
158
|
|
|
$table_block_setting->addForeignKeyConstraint($table_block->getName(), ['block_id'], ['block_id'], ['onDelete' => 'CASCADE', 'onUpdate' => 'CASCADE']); |
|
159
|
|
|
|
|
160
|
|
|
$table_change = $schema->createTable('change'); |
|
161
|
|
|
$table_change->addColumn('change_id', Types::INTEGER, ['autoincrement' => true]); |
|
162
|
|
|
$table_change->addColumn('change_time', Types::DATETIME_MUTABLE, ['default' => 'CURRENT_TIMESTAMP']); |
|
163
|
|
|
$table_change->addColumn('status', Types::STRING, ['length' => 8, 'default' => 'pending', 'platformOptions' => $ascii_bin]); |
|
164
|
|
|
$table_change->addColumn('gedcom_id', Types::INTEGER); |
|
165
|
|
|
$table_change->addColumn('xref', Types::STRING, ['length' => 20, 'platformOptions' => $ascii_bin]); |
|
166
|
|
|
$table_change->addColumn('old_gedcom', Types::TEXT, ['platformOptions' => $utf8_bin]); |
|
167
|
|
|
$table_change->addColumn('new_gedcom', Types::TEXT, ['platformOptions' => $utf8_bin]); |
|
168
|
|
|
$table_change->addColumn('user_id', Types::INTEGER); |
|
169
|
|
|
$table_change->setPrimaryKey(['change_id']); |
|
170
|
|
|
$table_change->addIndex(['gedcom_id', 'status', 'xref']); |
|
171
|
|
|
$table_change->addIndex(['user_id']); |
|
172
|
|
|
$table_change->addForeignKeyConstraint($table_gedcom->getName(), ['gedcom_id'], ['gedcom_id'], ['onDelete' => 'CASCADE', 'onUpdate' => 'CASCADE']); |
|
173
|
|
|
$table_change->addForeignKeyConstraint($table_user->getName(), ['user_id'], ['user_id'], ['onDelete' => 'CASCADE', 'onUpdate' => 'CASCADE']); |
|
174
|
|
|
|
|
175
|
|
|
$table_dates = $schema->createTable('dates'); |
|
176
|
|
|
$table_dates->addColumn('d_day', Types::SMALLINT); |
|
177
|
|
|
$table_dates->addColumn('d_month', Types::STRING, ['length' => 5, 'fixed' => true, 'platformOptions' => $ascii_bin]); |
|
178
|
|
|
$table_dates->addColumn('d_mon', Types::SMALLINT); |
|
179
|
|
|
$table_dates->addColumn('d_year', Types::SMALLINT); |
|
180
|
|
|
$table_dates->addColumn('d_julianday1', Types::INTEGER); |
|
181
|
|
|
$table_dates->addColumn('d_julianday2', Types::INTEGER); |
|
182
|
|
|
$table_dates->addColumn('d_fact', Types::STRING, ['length' => 15, 'platformOptions' => $ascii_bin]); |
|
183
|
|
|
$table_dates->addColumn('d_gid', Types::STRING, ['length' => 20, 'platformOptions' => $ascii_bin]); |
|
184
|
|
|
$table_dates->addColumn('d_file', Types::INTEGER); |
|
185
|
|
|
$table_dates->addColumn('d_type', Types::STRING, ['length' => 13, 'platformOptions' => $ascii_bin]); |
|
186
|
|
|
$table_dates->addIndex(['d_day']); |
|
187
|
|
|
$table_dates->addIndex(['d_month']); |
|
188
|
|
|
$table_dates->addIndex(['d_mon']); |
|
189
|
|
|
$table_dates->addIndex(['d_year']); |
|
190
|
|
|
$table_dates->addIndex(['d_julianday1']); |
|
191
|
|
|
$table_dates->addIndex(['d_julianday2']); |
|
192
|
|
|
$table_dates->addIndex(['d_gid']); |
|
193
|
|
|
$table_dates->addIndex(['d_file']); |
|
194
|
|
|
$table_dates->addIndex(['d_type']); |
|
195
|
|
|
$table_dates->addIndex(['d_fact', 'd_gid']); |
|
196
|
|
|
|
|
197
|
|
|
$table_default_resn = $schema->createTable('default_resn'); |
|
198
|
|
|
$table_default_resn->addColumn('default_resn_id', Types::INTEGER, ['autoincrement' => true]); |
|
199
|
|
|
$table_default_resn->addColumn('gedcom_id', Types::INTEGER); |
|
200
|
|
|
$table_default_resn->addColumn('xref', Types::STRING, ['length' => 20, 'notNull' => false, 'platformOptions' => $ascii_bin]); |
|
201
|
|
|
$table_default_resn->addColumn('tag_type', Types::STRING, ['length' => 15, 'notNull' => false, 'platformOptions' => $ascii_bin]); |
|
202
|
|
|
$table_default_resn->addColumn('resn', Types::STRING, ['length' => 12, 'platformOptions' => $ascii_bin]); |
|
203
|
|
|
$table_default_resn->setPrimaryKey(['default_resn_id']); |
|
204
|
|
|
$table_default_resn->addIndex(['gedcom_id', 'xref', 'tag_type']); |
|
205
|
|
|
$table_default_resn->addForeignKeyConstraint($table_gedcom->getName(), ['gedcom_id'], ['gedcom_id'], ['onDelete' => 'CASCADE', 'onUpdate' => 'CASCADE']); |
|
206
|
|
|
|
|
207
|
|
|
$table_families = $schema->createTable('families'); |
|
208
|
|
|
$table_families->addColumn('f_id', Types::STRING, ['length' => 20, 'platformOptions' => $ascii_bin]); |
|
209
|
|
|
$table_families->addColumn('f_file', Types::INTEGER); |
|
210
|
|
|
$table_families->addColumn('f_husb', Types::STRING, ['length' => 20, 'notNull' => false, 'platformOptions' => $ascii_bin]); |
|
211
|
|
|
$table_families->addColumn('f_wife', Types::STRING, ['length' => 20, 'notNull' => false, 'platformOptions' => $ascii_bin]); |
|
212
|
|
|
$table_families->addColumn('f_gedcom', Types::TEXT, ['platformOptions' => $utf8_bin]); |
|
213
|
|
|
$table_families->addColumn('f_numchil', Types::INTEGER); |
|
214
|
|
|
$table_families->setPrimaryKey(['f_id', 'f_file']); |
|
215
|
|
|
$table_families->addUniqueIndex(['f_file', 'f_id']); |
|
216
|
|
|
$table_families->addIndex(['f_husb']); |
|
217
|
|
|
$table_families->addIndex(['f_wife']); |
|
218
|
|
|
|
|
219
|
|
|
$table_favorite = $schema->createTable('favorite'); |
|
220
|
|
|
$table_favorite->addColumn('favorite_id', Types::INTEGER, ['autoincrement' => true]); |
|
221
|
|
|
$table_favorite->addColumn('user_id', Types::INTEGER, ['notNull' => false]); |
|
222
|
|
|
$table_favorite->addColumn('xref', Types::STRING, ['length' => 20, 'notNull' => false, 'platformOptions' => $ascii_bin]); |
|
223
|
|
|
$table_favorite->addColumn('favorite_type', Types::STRING, ['length' => 4, 'platformOptions' => $ascii_bin]); |
|
224
|
|
|
$table_favorite->addColumn('url', Types::STRING, ['length' => 255, 'notNull' => false, 'platformOptions' => $utf8_bin]); |
|
225
|
|
|
$table_favorite->addColumn('title', Types::STRING, ['length' => 255, 'notNull' => false, 'platformOptions' => $utf8_bin]); |
|
226
|
|
|
$table_favorite->addColumn('note', Types::STRING, ['length' => 1000, 'notNull' => false, 'platformOptions' => $utf8_bin]); |
|
227
|
|
|
$table_favorite->addColumn('gedcom_id', Types::INTEGER); |
|
228
|
|
|
$table_favorite->setPrimaryKey(['favorite_id']); |
|
229
|
|
|
$table_favorite->addIndex(['user_id']); |
|
230
|
|
|
$table_favorite->addIndex(['gedcom_id', 'user_id']); |
|
231
|
|
|
$table_favorite->addForeignKeyConstraint($table_gedcom->getName(), ['gedcom_id'], ['gedcom_id'], ['onDelete' => 'CASCADE', 'onUpdate' => 'CASCADE']); |
|
232
|
|
|
$table_favorite->addForeignKeyConstraint($table_user->getName(), ['user_id'], ['user_id'], ['onDelete' => 'CASCADE', 'onUpdate' => 'CASCADE']); |
|
233
|
|
|
|
|
234
|
|
|
$table_gedcom_chunk = $schema->createTable('gedcom_chunk'); |
|
235
|
|
|
$table_gedcom_chunk->addColumn('gedcom_chunk_id', Types::INTEGER, ['autoincrement' => true]); |
|
236
|
|
|
$table_gedcom_chunk->addColumn('gedcom_id', Types::INTEGER); |
|
237
|
|
|
$table_gedcom_chunk->addColumn('chunk_data', Types::BLOB); |
|
238
|
|
|
$table_gedcom_chunk->addColumn('imported', Types::INTEGER, ['default' => 0]); |
|
239
|
|
|
$table_gedcom_chunk->setPrimaryKey(['gedcom_chunk_id']); |
|
240
|
|
|
$table_gedcom_chunk->addIndex(['gedcom_id', 'imported']); |
|
241
|
|
|
$table_gedcom_chunk->addForeignKeyConstraint($table_gedcom->getName(), ['gedcom_id'], ['gedcom_id'], ['onDelete' => 'CASCADE', 'onUpdate' => 'CASCADE']); |
|
242
|
|
|
|
|
243
|
|
|
$table_gedcom_setting = $schema->createTable('gedcom_setting'); |
|
244
|
|
|
$table_gedcom_setting->addColumn('gedcom_id', Types::INTEGER); |
|
245
|
|
|
$table_gedcom_setting->addColumn('setting_name', Types::STRING, ['length' => 32, 'platformOptions' => $ascii_bin]); |
|
246
|
|
|
$table_gedcom_setting->addColumn('setting_value', Types::STRING, ['length' => 255, 'platformOptions' => $utf8_bin]); |
|
247
|
|
|
$table_gedcom_setting->setPrimaryKey(['gedcom_id', 'setting_name']); |
|
248
|
|
|
$table_gedcom_setting->addForeignKeyConstraint($table_gedcom->getName(), ['gedcom_id'], ['gedcom_id'], ['onDelete' => 'CASCADE', 'onUpdate' => 'CASCADE']); |
|
249
|
|
|
|
|
250
|
|
|
$table_hit_counter = $schema->createTable('hit_counter'); |
|
251
|
|
|
$table_hit_counter->addColumn('gedcom_id', Types::INTEGER); |
|
252
|
|
|
$table_hit_counter->addColumn('page_name', Types::STRING, ['length' => 32, 'platformOptions' => $ascii_bin]); |
|
253
|
|
|
$table_hit_counter->addColumn('page_parameter', Types::STRING, ['length' => 20, 'platformOptions' => $ascii_bin]); |
|
254
|
|
|
$table_hit_counter->addColumn('page_count', Types::INTEGER); |
|
255
|
|
|
$table_hit_counter->setPrimaryKey(['gedcom_id', 'page_name', 'page_parameter']); |
|
256
|
|
|
$table_hit_counter->addForeignKeyConstraint($table_gedcom->getName(), ['gedcom_id'], ['gedcom_id'], ['onDelete' => 'CASCADE', 'onUpdate' => 'CASCADE']); |
|
257
|
|
|
|
|
258
|
|
|
$table_individuals = $schema->createTable('individuals'); |
|
259
|
|
|
$table_individuals->addColumn('i_id', Types::STRING, ['length' => 20, 'platformOptions' => $ascii_bin]); |
|
260
|
|
|
$table_individuals->addColumn('i_file', Types::INTEGER); |
|
261
|
|
|
$table_individuals->addColumn('i_rin', Types::STRING, ['length' => 20, 'platformOptions' => $utf8_bin]); |
|
262
|
|
|
$table_individuals->addColumn('i_sex', Types::STRING, ['length' => 1, 'platformOptions' => $ascii_bin]); |
|
263
|
|
|
$table_individuals->addColumn('i_gedcom', Types::TEXT, ['platformOptions' => $utf8_bin]); |
|
264
|
|
|
$table_individuals->setPrimaryKey(['i_id', 'i_file']); |
|
265
|
|
|
$table_individuals->addUniqueIndex(['i_file', 'i_id']); |
|
266
|
|
|
|
|
267
|
|
|
$table_link = $schema->createTable('link'); |
|
268
|
|
|
$table_link->addColumn('l_file', Types::INTEGER); |
|
269
|
|
|
$table_link->addColumn('l_from', Types::STRING, ['length' => 20, 'platformOptions' => $ascii_bin]); |
|
270
|
|
|
$table_link->addColumn('l_type', Types::STRING, ['length' => 15, 'platformOptions' => $ascii_bin]); |
|
271
|
|
|
$table_link->addColumn('l_to', Types::STRING, ['length' => 20, 'platformOptions' => $ascii_bin]); |
|
272
|
|
|
$table_link->setPrimaryKey(['l_from', 'l_file', 'l_type', 'l_to']); |
|
273
|
|
|
$table_link->addUniqueIndex(['l_to', 'l_file', 'l_type', 'l_from']); |
|
274
|
|
|
|
|
275
|
|
|
$table_log = $schema->createTable('log'); |
|
276
|
|
|
$table_log->addColumn('log_id', Types::INTEGER, ['autoincrement' => true]); |
|
277
|
|
|
$table_log->addColumn('log_time', 'timestamp', ['default' => 'CURRENT_TIMESTAMP', 'precision' => 0]); |
|
278
|
|
|
$table_log->addColumn('log_type', Types::STRING, ['length' => 6, 'platformOptions' => $ascii_bin]); |
|
279
|
|
|
$table_log->addColumn('log_message', Types::TEXT, ['platformOptions' => $utf8_bin]); |
|
280
|
|
|
$table_log->addColumn('ip_address', Types::STRING, ['length' => 45]); |
|
281
|
|
|
$table_log->addColumn('user_id', Types::INTEGER, ['notNull' => false]); |
|
282
|
|
|
$table_log->addColumn('gedcom_id', Types::INTEGER, ['notNull' => false]); |
|
283
|
|
|
$table_log->setPrimaryKey(['log_id']); |
|
284
|
|
|
$table_log->addIndex(['log_time']); |
|
285
|
|
|
$table_log->addIndex(['log_type']); |
|
286
|
|
|
$table_log->addIndex(['ip_address']); |
|
287
|
|
|
$table_log->addIndex(['user_id']); |
|
288
|
|
|
$table_log->addIndex(['gedcom_id']); |
|
289
|
|
|
$table_log->addForeignKeyConstraint($table_gedcom->getName(), ['gedcom_id'], ['gedcom_id'], ['onDelete' => 'CASCADE', 'onUpdate' => 'CASCADE']); |
|
290
|
|
|
$table_log->addForeignKeyConstraint($table_user->getName(), ['user_id'], ['user_id'], ['onDelete' => 'CASCADE', 'onUpdate' => 'CASCADE']); |
|
291
|
|
|
|
|
292
|
|
|
$table_media = $schema->createTable('media'); |
|
293
|
|
|
$table_media->addColumn('m_id', Types::STRING, ['length' => 20, 'platformOptions' => $ascii_bin]); |
|
294
|
|
|
$table_media->addColumn('m_file', Types::INTEGER); |
|
295
|
|
|
$table_media->addColumn('m_gedcom', Types::TEXT, ['platformOptions' => $utf8_bin]); |
|
296
|
|
|
$table_media->setPrimaryKey(['m_file', 'm_id']); |
|
297
|
|
|
$table_media->addUniqueIndex(['m_id', 'm_file']); |
|
298
|
|
|
|
|
299
|
|
|
$table_media_file = $schema->createTable('media_file'); |
|
300
|
|
|
$table_media_file->addColumn('id', Types::INTEGER, ['autoincrement' => true]); |
|
301
|
|
|
$table_media_file->addColumn('m_id', Types::STRING, ['length' => 20, 'platformOptions' => $ascii_bin]); |
|
302
|
|
|
$table_media_file->addColumn('m_file', Types::INTEGER); |
|
303
|
|
|
$table_media_file->addColumn('multimedia_file_refn', Types::STRING, ['length' => 246, 'platformOptions' => $utf8_bin]); |
|
304
|
|
|
$table_media_file->addColumn('multimedia_format', Types::STRING, ['length' => 4, 'platformOptions' => $utf8_bin]); |
|
305
|
|
|
$table_media_file->addColumn('source_media_type', Types::STRING, ['length' => 15, 'platformOptions' => $utf8_bin]); |
|
306
|
|
|
$table_media_file->addColumn('descriptive_title', Types::STRING, ['length' => 248, 'platformOptions' => $utf8_bin]); |
|
307
|
|
|
$table_media_file->setPrimaryKey(['id']); |
|
308
|
|
|
$table_media_file->addIndex(['m_id', 'm_file']); |
|
309
|
|
|
$table_media_file->addIndex(['m_file', 'm_id']); |
|
310
|
|
|
$table_media_file->addIndex(['m_file', 'multimedia_file_refn']); |
|
311
|
|
|
$table_media_file->addIndex(['m_file', 'multimedia_format']); |
|
312
|
|
|
$table_media_file->addIndex(['m_file', 'source_media_type']); |
|
313
|
|
|
$table_media_file->addIndex(['m_file', 'descriptive_title']); |
|
314
|
|
|
|
|
315
|
|
|
$table_message = $schema->createTable('message'); |
|
316
|
|
|
$table_message->addColumn('message_id', Types::INTEGER, ['autoincrement' => true]); |
|
317
|
|
|
$table_message->addColumn('sender', Types::STRING, ['length' => 64, 'platformOptions' => $utf8_bin]); |
|
318
|
|
|
$table_message->addColumn('ip_address', Types::STRING, ['length' => 45, 'platformOptions' => $ascii_bin]); |
|
319
|
|
|
$table_message->addColumn('user_id', Types::INTEGER); |
|
320
|
|
|
$table_message->addColumn('subject', Types::STRING, ['length' => 255, 'platformOptions' => $utf8_bin]); |
|
321
|
|
|
$table_message->addColumn('body', Types::TEXT, ['platformOptions' => $utf8_bin]); |
|
322
|
|
|
$table_message->addColumn('created', 'timestamp', ['default' => 'CURRENT_TIMESTAMP', 'precision' => 0]); |
|
323
|
|
|
$table_message->addIndex(['user_id']); |
|
324
|
|
|
$table_message->setPrimaryKey(['message_id']); |
|
325
|
|
|
$table_message->addForeignKeyConstraint($table_user->getName(), ['user_id'], ['user_id'], ['onDelete' => 'CASCADE', 'onUpdate' => 'CASCADE']); |
|
326
|
|
|
|
|
327
|
|
|
$table_module_privacy = $schema->createTable('module_privacy'); |
|
328
|
|
|
$table_module_privacy->addColumn('id', Types::INTEGER, ['autoincrement' => true]); |
|
329
|
|
|
$table_module_privacy->addColumn('module_name', Types::STRING, ['length' => 32, 'platformOptions' => $utf8_bin]); |
|
330
|
|
|
$table_module_privacy->addColumn('gedcom_id', Types::INTEGER); |
|
331
|
|
|
$table_module_privacy->addColumn('interface', Types::STRING, ['length' => 255, 'platformOptions' => $ascii_bin]); |
|
332
|
|
|
$table_module_privacy->addColumn('access_level', Types::SMALLINT); |
|
333
|
|
|
$table_module_privacy->addUniqueIndex(['gedcom_id', 'module_name', 'interface']); |
|
334
|
|
|
$table_module_privacy->addUniqueIndex(['module_name', 'gedcom_id', 'interface']); |
|
335
|
|
|
$table_module_privacy->setPrimaryKey(['id']); |
|
336
|
|
|
$table_module_privacy->addForeignKeyConstraint($table_gedcom->getName(), ['gedcom_id'], ['gedcom_id'], ['onDelete' => 'CASCADE', 'onUpdate' => 'CASCADE']); |
|
337
|
|
|
$table_module_privacy->addForeignKeyConstraint($table_module->getName(), ['module_name'], ['module_name'], ['onDelete' => 'CASCADE', 'onUpdate' => 'CASCADE']); |
|
338
|
|
|
|
|
339
|
|
|
$table_module_setting = $schema->createTable('module_setting'); |
|
340
|
|
|
$table_module_setting->addColumn('module_name', Types::STRING, ['length' => 32, 'platformOptions' => $utf8_bin]); |
|
341
|
|
|
$table_module_setting->addColumn('setting_name', Types::STRING, ['length' => 32, 'platformOptions' => $ascii_bin]); |
|
342
|
|
|
$table_module_setting->addColumn('setting_value', Types::TEXT, ['platformOptions' => $utf8_bin]); |
|
343
|
|
|
$table_module_setting->setPrimaryKey(['module_name', 'setting_name']); |
|
344
|
|
|
$table_module_setting->addForeignKeyConstraint($table_module->getName(), ['module_name'], ['module_name'], ['onDelete' => 'CASCADE', 'onUpdate' => 'CASCADE']); |
|
345
|
|
|
|
|
346
|
|
|
$table_name = $schema->createTable('name'); |
|
347
|
|
|
$table_name->addColumn('n_file', Types::INTEGER); |
|
348
|
|
|
$table_name->addColumn('n_id', Types::STRING, ['length' => 20, 'platformOptions' => $ascii_bin]); |
|
349
|
|
|
$table_name->addColumn('n_num', Types::INTEGER); |
|
350
|
|
|
$table_name->addColumn('n_type', Types::STRING, ['length' => 15, 'platformOptions' => $ascii_bin]); |
|
351
|
|
|
$table_name->addColumn('n_sort', Types::STRING, ['length' => 255, 'platformOptions' => $utf8_bin]); |
|
352
|
|
|
$table_name->addColumn('n_full', Types::STRING, ['length' => 255, 'platformOptions' => $utf8_bin]); |
|
353
|
|
|
$table_name->addColumn('n_surname', Types::STRING, ['length' => 255, 'platformOptions' => $utf8_bin]); |
|
354
|
|
|
$table_name->addColumn('n_surn', Types::STRING, ['length' => 255, 'platformOptions' => $utf8_bin]); |
|
355
|
|
|
$table_name->addColumn('n_givn', Types::STRING, ['length' => 255, 'platformOptions' => $utf8_bin]); |
|
356
|
|
|
$table_name->addColumn('n_soundex_givn_std', Types::STRING, ['length' => 255, 'notNull' => false, 'platformOptions' => $ascii_bin]); |
|
357
|
|
|
$table_name->addColumn('n_soundex_surn_std', Types::STRING, ['length' => 255, 'notNull' => false, 'platformOptions' => $ascii_bin]); |
|
358
|
|
|
$table_name->addColumn('n_soundex_givn_dm', Types::STRING, ['length' => 255, 'notNull' => false, 'platformOptions' => $ascii_bin]); |
|
359
|
|
|
$table_name->addColumn('n_soundex_surn_dm', Types::STRING, ['length' => 255, 'notNull' => false, 'platformOptions' => $ascii_bin]); |
|
360
|
|
|
$table_name->setPrimaryKey(['n_id', 'n_file', 'n_num']); |
|
361
|
|
|
$table_name->addIndex(['n_full', 'n_id', 'n_file']); |
|
362
|
|
|
$table_name->addIndex(['n_surn', 'n_file', 'n_type', 'n_id']); |
|
363
|
|
|
$table_name->addIndex(['n_givn', 'n_file', 'n_type', 'n_id']); |
|
364
|
|
|
|
|
365
|
|
|
$table_news = $schema->createTable('news'); |
|
366
|
|
|
$table_news->addColumn('news_id', Types::INTEGER, ['autoincrement' => true]); |
|
367
|
|
|
$table_news->addColumn('user_id', Types::INTEGER, ['notNull' => false]); |
|
368
|
|
|
$table_news->addColumn('gedcom_id', Types::INTEGER, ['notNull' => false]); |
|
369
|
|
|
$table_news->addColumn('subject', Types::STRING, ['length' => 255, 'platformOptions' => $utf8_bin]); |
|
370
|
|
|
$table_news->addColumn('body', Types::TEXT, ['platformOptions' => $utf8_bin]); |
|
371
|
|
|
$table_news->addColumn('updated', 'timestamp', ['default' => 'CURRENT_TIMESTAMP', 'precision' => 0]); |
|
372
|
|
|
$table_news->setPrimaryKey(['news_id']); |
|
373
|
|
|
$table_news->addIndex(['user_id', 'updated']); |
|
374
|
|
|
$table_news->addIndex(['gedcom_id', 'updated']); |
|
375
|
|
|
$table_news->addForeignKeyConstraint($table_gedcom->getName(), ['gedcom_id'], ['gedcom_id'], ['onDelete' => 'CASCADE', 'onUpdate' => 'CASCADE']); |
|
376
|
|
|
$table_news->addForeignKeyConstraint($table_user->getName(), ['user_id'], ['user_id'], ['onDelete' => 'CASCADE', 'onUpdate' => 'CASCADE']); |
|
377
|
|
|
|
|
378
|
|
|
$table_other = $schema->createTable('other'); |
|
379
|
|
|
$table_other->addColumn('o_id', Types::STRING, ['length' => 20, 'platformOptions' => $ascii_bin]); |
|
380
|
|
|
$table_other->addColumn('o_file', Types::INTEGER); |
|
381
|
|
|
$table_other->addColumn('o_type', Types::STRING, ['length' => 15, 'platformOptions' => $ascii_bin]); |
|
382
|
|
|
$table_other->addColumn('o_gedcom', Types::TEXT, ['platformOptions' => $utf8_bin]); |
|
383
|
|
|
$table_other->setPrimaryKey(['o_id', 'o_file']); |
|
384
|
|
|
$table_other->addUniqueIndex(['o_file', 'o_id']); |
|
385
|
|
|
|
|
386
|
|
|
$table_places = $schema->createTable('places'); |
|
387
|
|
|
$table_places->addColumn('p_id', Types::INTEGER, ['autoincrement' => true]); |
|
388
|
|
|
$table_places->addColumn('p_place', Types::STRING, ['length' => 150, 'platformOptions' => $utf8_bin]); |
|
389
|
|
|
$table_places->addColumn('p_parent_id', Types::INTEGER, ['notNull' => false]); |
|
390
|
|
|
$table_places->addColumn('p_file', Types::INTEGER); |
|
391
|
|
|
$table_places->addColumn('p_std_soundex', Types::TEXT, ['platformOptions' => $ascii_bin]); |
|
392
|
|
|
$table_places->addColumn('p_dm_soundex', Types::TEXT, ['platformOptions' => $ascii_bin]); |
|
393
|
|
|
$table_places->setPrimaryKey(['p_id']); |
|
394
|
|
|
$table_places->addUniqueIndex(['p_parent_id', 'p_file', 'p_place']); |
|
395
|
|
|
$table_places->addIndex(['p_file', 'p_place']); |
|
396
|
|
|
|
|
397
|
|
|
$table_placelinks = $schema->createTable('placelinks'); |
|
398
|
|
|
$table_placelinks->addColumn('pl_p_id', Types::INTEGER); |
|
399
|
|
|
$table_placelinks->addColumn('pl_gid', Types::STRING, ['length' => 20, 'platformOptions' => $ascii_bin]); |
|
400
|
|
|
$table_placelinks->addColumn('pl_file', Types::INTEGER); |
|
401
|
|
|
$table_placelinks->setPrimaryKey(['pl_p_id', 'pl_gid', 'pl_file']); |
|
402
|
|
|
$table_placelinks->addIndex(['pl_p_id']); |
|
403
|
|
|
$table_placelinks->addIndex(['pl_gid']); |
|
404
|
|
|
$table_placelinks->addIndex(['pl_file']); |
|
405
|
|
|
|
|
406
|
|
|
$table_place_location = $schema->createTable('place_location'); |
|
407
|
|
|
$table_place_location->addColumn('id', Types::INTEGER, ['autoincrement' => true]); |
|
408
|
|
|
$table_place_location->addColumn('parent_id', Types::INTEGER, ['notNull' => false]); |
|
409
|
|
|
$table_place_location->addColumn('place', Types::STRING, ['length' => 120, 'platformOptions' => $utf8_bin]); |
|
410
|
|
|
$table_place_location->addColumn('latitude', Types::FLOAT, ['notNull' => false]); |
|
411
|
|
|
$table_place_location->addColumn('longitude', Types::FLOAT, ['notNull' => false]); |
|
412
|
|
|
$table_place_location->setPrimaryKey(['id']); |
|
413
|
|
|
$table_place_location->addUniqueIndex(['parent_id', 'place']); |
|
414
|
|
|
$table_place_location->addUniqueIndex(['place', 'parent_id']); |
|
415
|
|
|
$table_place_location->addIndex(['latitude']); |
|
416
|
|
|
$table_place_location->addIndex(['longitude']); |
|
417
|
|
|
$table_place_location->addForeignKeyConstraint($table_place_location->getName(), ['parent_id'], ['id'], ['onDelete' => 'CASCADE', 'onUpdate' => 'CASCADE']); |
|
418
|
|
|
|
|
419
|
|
|
$table_sources = $schema->createTable('session'); |
|
420
|
|
|
$table_sources->addColumn('session_id', Types::STRING, ['length' => 32, 'platformOptions' => $ascii_bin]); |
|
421
|
|
|
$table_sources->addColumn('session_time', 'timestamp', ['default' => 'CURRENT_TIMESTAMP', 'precision' => 0]); |
|
422
|
|
|
$table_sources->addColumn('user_id', Types::INTEGER); |
|
423
|
|
|
$table_sources->addColumn('ip_address', Types::STRING, ['length' => 45, 'platformOptions' => $ascii_bin]); |
|
424
|
|
|
$table_sources->addColumn('session_data', Types::BLOB); |
|
425
|
|
|
$table_sources->setPrimaryKey(['session_id']); |
|
426
|
|
|
$table_sources->addIndex(['session_time']); |
|
427
|
|
|
$table_sources->addIndex(['user_id', 'ip_address']); |
|
428
|
|
|
|
|
429
|
|
|
$table_site_setting = $schema->createTable('site_setting'); |
|
430
|
|
|
$table_site_setting->addColumn('setting_name', Types::STRING, ['length' => 32, 'platformOptions' => $ascii_bin]); |
|
431
|
|
|
$table_site_setting->addColumn('setting_value', Types::STRING, ['length' => 2000, 'platformOptions' => $utf8_bin]); |
|
432
|
|
|
$table_site_setting->setPrimaryKey(['setting_name']); |
|
433
|
|
|
|
|
434
|
|
|
$table_sources = $schema->createTable('sources'); |
|
435
|
|
|
$table_sources->addColumn('s_id', Types::STRING, ['length' => 20, 'platformOptions' => $ascii_bin]); |
|
436
|
|
|
$table_sources->addColumn('s_file', Types::INTEGER); |
|
437
|
|
|
$table_sources->addColumn('s_name', Types::STRING, ['length' => 255, 'platformOptions' => $utf8_bin]); |
|
438
|
|
|
$table_sources->addColumn('s_gedcom', Types::TEXT, ['platformOptions' => $utf8_bin]); |
|
439
|
|
|
$table_sources->setPrimaryKey(['s_id', 's_file']); |
|
440
|
|
|
$table_sources->addUniqueIndex(['s_file', 's_id']); |
|
441
|
|
|
$table_sources->addIndex(['s_name']); |
|
442
|
|
|
|
|
443
|
|
|
$table_user_gedcom_setting = $schema->createTable('user_gedcom_setting'); |
|
444
|
|
|
$table_user_gedcom_setting->addColumn('user_id', Types::INTEGER); |
|
445
|
|
|
$table_user_gedcom_setting->addColumn('gedcom_id', Types::INTEGER); |
|
446
|
|
|
$table_user_gedcom_setting->addColumn('setting_name', Types::STRING, ['length' => 32, 'platformOptions' => $ascii_bin]); |
|
447
|
|
|
$table_user_gedcom_setting->addColumn('setting_value', Types::STRING, ['length' => 255, 'platformOptions' => $utf8_bin]); |
|
448
|
|
|
$table_user_gedcom_setting->setPrimaryKey(['user_id', 'gedcom_id', 'setting_name']); |
|
449
|
|
|
$table_user_gedcom_setting->addIndex(['gedcom_id']); |
|
450
|
|
|
$table_user_gedcom_setting->addForeignKeyConstraint($table_gedcom->getName(), ['gedcom_id'], ['gedcom_id'], ['onDelete' => 'CASCADE', 'onUpdate' => 'CASCADE']); |
|
451
|
|
|
$table_user_gedcom_setting->addForeignKeyConstraint($table_user->getName(), ['user_id'], ['user_id'], ['onDelete' => 'CASCADE', 'onUpdate' => 'CASCADE']); |
|
452
|
|
|
|
|
453
|
|
|
$table_user_setting = $schema->createTable('user_setting'); |
|
454
|
|
|
$table_user_setting->addColumn('user_id', Types::INTEGER); |
|
455
|
|
|
$table_user_setting->addColumn('setting_name', Types::STRING, ['length' => 32, 'platformOptions' => $ascii_bin]); |
|
456
|
|
|
$table_user_setting->addColumn('setting_value', Types::STRING, ['length' => 255, 'platformOptions' => $utf8_bin]); |
|
457
|
|
|
$table_user_setting->setPrimaryKey(['user_id', 'setting_name']); |
|
458
|
|
|
$table_user_setting->addForeignKeyConstraint($table_user->getName(), ['user_id'], ['user_id'], ['onDelete' => 'CASCADE', 'onUpdate' => 'CASCADE']); |
|
459
|
|
|
|
|
460
|
|
|
/* |
|
461
|
|
|
$site = $schema->createTable('site'); |
|
462
|
|
|
$site->addColumn('uuid', Types::STRING, ['length' => 36, 'platformOptions' => $ascii]); |
|
463
|
|
|
$site->addColumn('db_schema', Types::STRING, ['length' => 20, 'platformOptions' => $ascii]); |
|
464
|
|
|
$site->addColumn('created_at', Types::TIME_MUTABLE); |
|
465
|
|
|
$site->addColumn('updated_at', Types::TIME_MUTABLE); |
|
466
|
|
|
$site->setPrimaryKey(['uuid']); |
|
467
|
|
|
|
|
468
|
|
|
$job = $schema->createTable('job'); |
|
469
|
|
|
$job->addColumn('uuid', Types::STRING, ['length' => 36, 'platformOptions' => $ascii]); |
|
470
|
|
|
$job->addColumn('failures', Types::INTEGER, ['default' => 0]); |
|
471
|
|
|
$job->addColumn('job', Types::STRING, ['length' => 255, 'platformOptions' => $ascii]); |
|
472
|
|
|
$job->addColumn('parameters', Types::TEXT, ['platformOptions' => $utf8_bin]); |
|
473
|
|
|
$job->addColumn('error', Types::TEXT, ['notnull' => false, 'platformOptions' => $utf8_bin]); |
|
474
|
|
|
$job->addColumn('created_at', Types::TIME_MUTABLE); |
|
475
|
|
|
$job->addColumn('updated_at', Types::TIME_MUTABLE); |
|
476
|
|
|
$job->setPrimaryKey(['uuid']); |
|
477
|
|
|
|
|
478
|
|
|
$job_dependency = $schema->createTable('job_dependency'); |
|
479
|
|
|
$job_dependency->addColumn('uuid1', Types::STRING, ['length' => 36, 'platformOptions' => $ascii]); |
|
480
|
|
|
$job_dependency->addColumn('uuid2', Types::STRING, ['length' => 36, 'platformOptions' => $ascii]); |
|
481
|
|
|
$job_dependency->addUniqueIndex(['uuid1', 'uuid2']); |
|
482
|
|
|
$job_dependency->addUniqueIndex(['uuid2', 'uuid1']); |
|
483
|
|
|
$job_dependency->addForeignKeyConstraint($job->getName(), ['uuid1'], ['uuid'], ['onDelete' => 'CASCADE', 'onUpdate' => 'CASCADE']); |
|
484
|
|
|
$job_dependency->addForeignKeyConstraint($job->getName(), ['uuid2'], ['uuid'], ['onDelete' => 'CASCADE', 'onUpdate' => 'CASCADE']); |
|
485
|
|
|
*/ |
|
486
|
|
|
|
|
487
|
|
|
$current_schema = $connection |
|
488
|
|
|
->createSchemaManager() |
|
489
|
|
|
->introspectSchema(); |
|
490
|
|
|
|
|
491
|
|
|
$schema_diff = $connection |
|
492
|
|
|
->createSchemaManager() |
|
493
|
|
|
->createComparator() |
|
494
|
|
|
->compareSchemas($current_schema, $schema); |
|
495
|
|
|
|
|
496
|
|
|
$queries = $connection |
|
497
|
|
|
->getDatabasePlatform() |
|
498
|
|
|
->getAlterSchemaSQL($schema_diff); |
|
499
|
|
|
|
|
500
|
|
|
function f(string $query): int { |
|
501
|
|
|
if (str_contains($query, 'DROP FOREIGN KEY')) { |
|
502
|
|
|
return 1; |
|
503
|
|
|
} |
|
504
|
|
|
if (str_contains($query, 'ADD CONSTRAINT FK_')) { |
|
505
|
|
|
return 3; |
|
506
|
|
|
} |
|
507
|
|
|
return 2; |
|
508
|
|
|
}; |
|
509
|
|
|
|
|
510
|
|
|
// usort($queries, static fn(string $x, string $y): int => f($x) <=> f($y)); |
|
511
|
|
|
|
|
512
|
|
|
foreach ($queries as $query) { |
|
513
|
|
|
echo '<p>', $query, '</p>'; |
|
514
|
|
|
try { |
|
515
|
|
|
$connection->executeStatement($query); |
|
516
|
|
|
} catch (Exception $ex) { |
|
517
|
|
|
echo '<p>', $ex->getMessage(), '</p>'; |
|
518
|
|
|
} |
|
519
|
|
|
} |
|
520
|
|
|
exit; |
|
|
|
|
|
|
521
|
|
|
} |
|
522
|
|
|
} |
|
523
|
|
|
|
Let?s assume that you have a directory layout like this:
. |-- OtherDir | |-- Bar.php | `-- Foo.php `-- SomeDir `-- Foo.phpand let?s assume the following content of
Bar.php:If both files
OtherDir/Foo.phpandSomeDir/Foo.phpare loaded in the same runtime, you will see a PHP error such as the following:PHP Fatal error: Cannot use SomeDir\Foo as Foo because the name is already in use in OtherDir/Foo.phpHowever, as
OtherDir/Foo.phpdoes not necessarily have to be loaded and the error is only triggered if it is loaded beforeOtherDir/Bar.php, this problem might go unnoticed for a while. In order to prevent this error from surfacing, you must import the namespace with a different alias: