xref: /webtrees/app/Schema/SeedGedcomTable.php (revision 736b8b72ed0af202b700901a7965eb77c180581f)
1c9beb871SGreg Roach<?php
23976b470SGreg Roach
3c9beb871SGreg Roach/**
4c9beb871SGreg Roach * webtrees: online genealogy
55bfc6897SGreg Roach * Copyright (C) 2022 webtrees development team
6c9beb871SGreg Roach * This program is free software: you can redistribute it and/or modify
7c9beb871SGreg Roach * it under the terms of the GNU General Public License as published by
8c9beb871SGreg Roach * the Free Software Foundation, either version 3 of the License, or
9c9beb871SGreg Roach * (at your option) any later version.
10c9beb871SGreg Roach * This program is distributed in the hope that it will be useful,
11c9beb871SGreg Roach * but WITHOUT ANY WARRANTY; without even the implied warranty of
12c9beb871SGreg Roach * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13c9beb871SGreg Roach * GNU General Public License for more details.
14c9beb871SGreg Roach * You should have received a copy of the GNU General Public License
1589f7189bSGreg Roach * along with this program. If not, see <https://www.gnu.org/licenses/>.
16c9beb871SGreg Roach */
17fcfa147eSGreg Roach
18c9beb871SGreg Roachdeclare(strict_types=1);
19c9beb871SGreg Roach
20c9beb871SGreg Roachnamespace Fisharebest\Webtrees\Schema;
21c9beb871SGreg Roach
22c9beb871SGreg Roachuse Illuminate\Database\Capsule\Manager as DB;
23c9beb871SGreg Roach
24c9beb871SGreg Roach/**
25c9beb871SGreg Roach * Populate the gedcom table
26c9beb871SGreg Roach */
27c9beb871SGreg Roachclass SeedGedcomTable implements SeedInterface
28c9beb871SGreg Roach{
29c9beb871SGreg Roach    /**
30c9beb871SGreg Roach     *  Run the seeder.
31c9beb871SGreg Roach     *
32c9beb871SGreg Roach     * @return void
33c9beb871SGreg Roach     */
34c9beb871SGreg Roach    public function run(): void
35c9beb871SGreg Roach    {
36c9beb871SGreg Roach        // Add a "default" tree, to store default settings
37*736b8b72SGreg Roach
38*736b8b72SGreg Roach        if (DB::connection()->getDriverName() === 'sqlsrv') {
39*736b8b72SGreg Roach            DB::statement('SET IDENTITY_INSERT [' . DB::connection()->getTablePrefix() . 'gedcom] ON');
40*736b8b72SGreg Roach        }
41*736b8b72SGreg Roach
42c9beb871SGreg Roach        DB::table('gedcom')->updateOrInsert([
43c9beb871SGreg Roach            'gedcom_id'   => -1,
44c9beb871SGreg Roach        ], [
45c9beb871SGreg Roach            'gedcom_name'  => 'DEFAULT_TREE',
46c9beb871SGreg Roach        ]);
47*736b8b72SGreg Roach
48*736b8b72SGreg Roach        if (DB::connection()->getDriverName() === 'sqlsrv') {
49*736b8b72SGreg Roach            DB::statement('SET IDENTITY_INSERT [' . DB::connection()->getTablePrefix() . 'gedcom] OFF');
50*736b8b72SGreg Roach        }
51c9beb871SGreg Roach    }
52c9beb871SGreg Roach}
53