|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* webtrees-lib: MyArtJaub library for webtrees |
|
5
|
|
|
* |
|
6
|
|
|
* @package MyArtJaub\Webtrees |
|
7
|
|
|
* @subpackage Sosa |
|
8
|
|
|
* @author Jonathan Jaubart <[email protected]> |
|
9
|
|
|
* @copyright Copyright (c) 2009-2020, Jonathan Jaubart |
|
10
|
|
|
* @license http://www.gnu.org/licenses/gpl.html GNU General Public License, version 3 |
|
11
|
|
|
*/ |
|
12
|
|
|
|
|
13
|
|
|
declare(strict_types=1); |
|
14
|
|
|
|
|
15
|
|
|
namespace MyArtJaub\Webtrees\Module\Sosa\Schema; |
|
16
|
|
|
|
|
17
|
|
|
use Fisharebest\Webtrees\Schema\MigrationInterface; |
|
18
|
|
|
use Illuminate\Database\Capsule\Manager as DB; |
|
19
|
|
|
use Illuminate\Database\Schema\Blueprint; |
|
20
|
|
|
|
|
21
|
|
|
/** |
|
22
|
|
|
* Upgrade the database schema from version 2 to version 3. |
|
23
|
|
|
*/ |
|
24
|
|
|
class Migration2 implements MigrationInterface { |
|
25
|
|
|
|
|
26
|
|
|
/** |
|
27
|
|
|
* {@inheritDoc} |
|
28
|
|
|
* @see \Fisharebest\Webtrees\Schema\MigrationInterface::upgrade() |
|
29
|
|
|
*/ |
|
30
|
|
|
public function upgrade(): void |
|
31
|
|
|
{ |
|
32
|
|
|
|
|
33
|
|
|
// Clean up previous sosa table if it exists |
|
34
|
|
|
DB::schema()->dropIfExists('maj_sosa'); |
|
35
|
|
|
|
|
36
|
|
|
DB::schema()->create('maj_sosa', static function (Blueprint $table): void { |
|
37
|
|
|
|
|
38
|
|
|
$table->integer('majs_gedcom_id'); |
|
39
|
|
|
$table->integer('majs_user_id')->default(-1); |
|
40
|
|
|
$table->bigInteger('majs_sosa')->unsigned(); // Allow to calculate sosa on 64 generations |
|
41
|
|
|
$table->string('majs_i_id', 20); |
|
42
|
|
|
$table->tinyInteger('majs_gen')->nullable(); |
|
43
|
|
|
$table->smallInteger('majs_birth_year')->nullable(); |
|
44
|
|
|
$table->smallInteger('majs_birth_year_est')->nullable(); |
|
45
|
|
|
$table->smallInteger('majs_death_year')->nullable(); |
|
46
|
|
|
$table->smallInteger('majs_death_year_est')->nullable(); |
|
47
|
|
|
|
|
48
|
|
|
$table->primary(['majs_gedcom_id', 'majs_user_id', 'majs_sosa']); |
|
49
|
|
|
|
|
50
|
|
|
$table->index(['majs_gedcom_id', 'majs_user_id']); |
|
51
|
|
|
$table->index(['majs_gedcom_id', 'majs_user_id', 'majs_i_id']); |
|
52
|
|
|
$table->index(['majs_gedcom_id', 'majs_user_id', 'majs_gen']); |
|
53
|
|
|
|
|
54
|
|
|
$table->foreign('majs_gedcom_id')->references('gedcom_id')->on('gedcom')->onDelete('cascade'); |
|
55
|
|
|
$table->foreign('majs_user_id')->references('user_id')->on('user')->onDelete('cascade'); |
|
56
|
|
|
}); |
|
57
|
|
|
} |
|
58
|
|
|
} |
|
59
|
|
|
|