| Total Complexity | 76 |
| Total Lines | 655 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
Complex classes like WebtreesSchema often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use WebtreesSchema, and based on these observations, apply Extract Interface, too.
| 1 | <?php |
||
| 29 | class WebtreesSchema |
||
| 30 | { |
||
| 31 | /** |
||
| 32 | * @return void |
||
| 33 | */ |
||
| 34 | public function historicSchemaVersions(): void |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 633 | } |
||
| 634 | |||
| 635 | public static function tableUserSetting(): Table |
||
| 636 | { |
||
| 637 | return Table::editor() |
||
| 645 | } |
||
| 646 | |||
| 647 | public static function schema(): \Doctrine\DBAL\Schema\Schema |
||
| 648 | { |
||
| 649 | return new \Doctrine\DBAL\Schema\Schema([ |
||
| 650 | self::tableBlock(), |
||
| 684 | ]); |
||
| 685 | } |
||
| 686 | } |
||
| 687 |