xref: /webtrees/app/Schema/Migration35.php (revision 362be83a34a1d0ba0292c4387f55a3b0ea10cb2f)
115e87d46SGreg Roach<?php
215e87d46SGreg Roach/**
315e87d46SGreg Roach * webtrees: online genealogy
41062a142SGreg Roach * Copyright (C) 2018 webtrees development team
515e87d46SGreg Roach * This program is free software: you can redistribute it and/or modify
615e87d46SGreg Roach * it under the terms of the GNU General Public License as published by
715e87d46SGreg Roach * the Free Software Foundation, either version 3 of the License, or
815e87d46SGreg Roach * (at your option) any later version.
915e87d46SGreg Roach * This program is distributed in the hope that it will be useful,
1015e87d46SGreg Roach * but WITHOUT ANY WARRANTY; without even the implied warranty of
1115e87d46SGreg Roach * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1215e87d46SGreg Roach * GNU General Public License for more details.
1315e87d46SGreg Roach * You should have received a copy of the GNU General Public License
1415e87d46SGreg Roach * along with this program. If not, see <http://www.gnu.org/licenses/>.
1515e87d46SGreg Roach */
16e7f56f2aSGreg Roachdeclare(strict_types=1);
17e7f56f2aSGreg Roach
1815e87d46SGreg Roachnamespace Fisharebest\Webtrees\Schema;
1915e87d46SGreg Roach
2015e87d46SGreg Roachuse Fisharebest\Webtrees\Database;
2115e87d46SGreg Roach
2215e87d46SGreg Roach/**
2315e87d46SGreg Roach * Upgrade the database schema from version 35 to version 36.
2415e87d46SGreg Roach */
25c1010edaSGreg Roachclass Migration35 implements MigrationInterface
26c1010edaSGreg Roach{
2715e87d46SGreg Roach    /**
2815e87d46SGreg Roach     * Upgrade to to the next version
2919d91378SGreg Roach     *
3019d91378SGreg Roach     * @return void
3115e87d46SGreg Roach     */
32*362be83aSGreg Roach    public function upgrade(): void
33c1010edaSGreg Roach    {
3415e87d46SGreg Roach        // Use LONGTEXT instead of TEXT and MEDIUMTEXT, and make NOT NULL.
3515e87d46SGreg Roach        Database::exec("UPDATE `##news`   SET body          = '' WHERE body          IS NULL");
3615e87d46SGreg Roach        Database::exec("UPDATE `##other`  SET o_gedcom      = '' WHERE o_gedcom      IS NULL");
3715e87d46SGreg Roach        Database::exec("UPDATE `##places` SET p_std_soundex = '' WHERE p_std_soundex IS NULL");
3815e87d46SGreg Roach        Database::exec("UPDATE `##places` SET p_dm_soundex  = '' WHERE p_dm_soundex  IS NULL");
3915e87d46SGreg Roach        Database::exec("ALTER TABLE `##block_setting`  CHANGE setting_value setting_value LONGTEXT COLLATE utf8_unicode_ci NOT NULL");
4015e87d46SGreg Roach        Database::exec("ALTER TABLE `##change`         CHANGE new_gedcom    new_gedcom    LONGTEXT COLLATE utf8_unicode_ci NOT NULL");
4115e87d46SGreg Roach        Database::exec("ALTER TABLE `##change`         CHANGE old_gedcom    old_gedcom    LONGTEXT COLLATE utf8_unicode_ci NOT NULL");
4215e87d46SGreg Roach        Database::exec("ALTER TABLE `##families`       CHANGE f_gedcom      f_gedcom      LONGTEXT COLLATE utf8_unicode_ci NOT NULL");
4315e87d46SGreg Roach        Database::exec("ALTER TABLE `##individuals`    CHANGE i_gedcom      i_gedcom      LONGTEXT COLLATE utf8_unicode_ci NOT NULL");
4415e87d46SGreg Roach        Database::exec("ALTER TABLE `##log`            CHANGE log_message   log_message   LONGTEXT COLLATE utf8_unicode_ci NOT NULL");
4515e87d46SGreg Roach        Database::exec("ALTER TABLE `##media`          CHANGE m_gedcom      m_gedcom      LONGTEXT COLLATE utf8_unicode_ci NOT NULL");
4615e87d46SGreg Roach        Database::exec("ALTER TABLE `##message`        CHANGE body          body          LONGTEXT COLLATE utf8_unicode_ci NOT NULL");
4715e87d46SGreg Roach        Database::exec("ALTER TABLE `##module_setting` CHANGE setting_value setting_value LONGTEXT COLLATE utf8_unicode_ci NOT NULL");
4815e87d46SGreg Roach        Database::exec("ALTER TABLE `##news`           CHANGE body          body          LONGTEXT COLLATE utf8_unicode_ci NOT NULL");
4915e87d46SGreg Roach        Database::exec("ALTER TABLE `##other`          CHANGE o_gedcom      o_gedcom      LONGTEXT COLLATE utf8_unicode_ci NOT NULL");
5015e87d46SGreg Roach        Database::exec("ALTER TABLE `##places`         CHANGE p_std_soundex p_std_soundex LONGTEXT COLLATE utf8_unicode_ci NOT NULL");
5115e87d46SGreg Roach        Database::exec("ALTER TABLE `##places`         CHANGE p_dm_soundex  p_dm_soundex  LONGTEXT COLLATE utf8_unicode_ci NOT NULL");
5215e87d46SGreg Roach        Database::exec("ALTER TABLE `##sources`        CHANGE s_gedcom      s_gedcom      LONGTEXT COLLATE utf8_unicode_ci NOT NULL");
5315e87d46SGreg Roach        // Use LONGBLOB instead of MEDIUMBLOB.
5415e87d46SGreg Roach        Database::exec("ALTER TABLE `##gedcom_chunk`   CHANGE chunk_data    chunk_data    LONGBLOB NOT NULL");
5515e87d46SGreg Roach        Database::exec("ALTER TABLE `##session`        CHANGE session_data  session_data  LONGBLOB NOT NULL");
5615e87d46SGreg Roach    }
5715e87d46SGreg Roach}
58