src/Helper/UpgradeHandler.php
protected static function upgradeInputScreenFlag()
    {
        $objDB = self::DB();
        if (!$objDB->tableExists('tl_metamodel_dca', null, true)) {
            return;
        }
        if (!$objDB->fieldExists('flag', 'tl_metamodel_dca')) {
            return;
        }

        if (!$objDB->tableExists('tl_metamodel_dca_sortgroup', null, true)) {
            $objDB->execute('
                CREATE TABLE `tl_metamodel_dca_sortgroup` (
                `id` int(10) unsigned NOT NULL auto_increment,
                `pid` int(10) unsigned NOT NULL default \'0\',
                `sorting` int(10) unsigned NOT NULL default \'0\',
                `tstamp` int(10) unsigned NOT NULL default \'0\',
                `name` text NULL,
                `isdefault` char(1) NOT NULL default \'\',
                `ismanualsort` char(1) NOT NULL default \'\',
                `rendergrouptype` varchar(10) NOT NULL default \'none\',
                `rendergrouplen` int(10) unsigned NOT NULL default \'1\',
                `rendergroupattr` int(10) unsigned NOT NULL default \'0\',
                `rendersort` varchar(10) NOT NULL default \'asc\',
                `rendersortattr` int(10) unsigned NOT NULL default \'0\',
                PRIMARY KEY  (`id`)
                ) ENGINE=MyISAM DEFAULT CHARSET=utf8;
            ');
        }

        $dca = $objDB->execute('SELECT * FROM tl_metamodel_dca');

        while ($dca->next()) {
            $renderGroupLen = 0;
            if (in_array($dca->flag, array(1,2,3,4))) {
                $renderGroupType = 'char';
                if (in_array($dca->flag, array(1,2))) {
                    $renderGroupLen = 1;
                } else {
                    $renderGroupLen = 2;
                }
            } elseif (in_array($dca->flag, array(5,6))) {
                $renderGroupType = 'day';
            } elseif (in_array($dca->flag, array(7,8))) {
                $renderGroupType = 'month';
            } elseif (in_array($dca->flag, array(9,10))) {
                $renderGroupType = 'year';
            } elseif (in_array($dca->flag, array(11,12))) {
                $renderGroupType = 'digit';
            } else {
                $renderGroupType = 'none';
            }

            $data = array(
                'pid'             => $dca->id,
                'sorting'         => 128,
                'tstamp'          => time(),
                'name'            => null,
                'isdefault'       => '1',
                'ismanualsort'    => '1',
                'rendergrouptype' => $renderGroupType,
                'rendergrouplen'  => $renderGroupLen,
                'rendergroupattr' => 0,
                'rendersort'      => in_array($dca->flag, array(2,4,6,8,10,12)) ? 'desc' : 'asc',
                'rendersortattr'  => 0,
            );

            $objDB
                ->prepare('INSERT INTO tl_metamodel_dca_sortgroup %s')
                ->set($data)
                ->execute();
        }

        TableManipulation::dropColumn('tl_metamodel_dca', 'flag', true);
    }
protected static function upgradeInputScreenFlag()
    {
        $objDB = self::DB();
        if (!$objDB->tableExists('tl_metamodel_dca', null, true)) {
            return;
        }
        if (!$objDB->fieldExists('flag', 'tl_metamodel_dca')) {
            return;
        }

        if (!$objDB->tableExists('tl_metamodel_dca_sortgroup', null, true)) {
            $objDB->execute('
                CREATE TABLE `tl_metamodel_dca_sortgroup` (
                `id` int(10) unsigned NOT NULL auto_increment,
                `pid` int(10) unsigned NOT NULL default \'0\',
                `sorting` int(10) unsigned NOT NULL default \'0\',
                `tstamp` int(10) unsigned NOT NULL default \'0\',
                `name` text NULL,
                `isdefault` char(1) NOT NULL default \'\',
                `ismanualsort` char(1) NOT NULL default \'\',
                `rendergrouptype` varchar(10) NOT NULL default \'none\',
                `rendergrouplen` int(10) unsigned NOT NULL default \'1\',
                `rendergroupattr` int(10) unsigned NOT NULL default \'0\',
                `rendersort` varchar(10) NOT NULL default \'asc\',
                `rendersortattr` int(10) unsigned NOT NULL default \'0\',
                PRIMARY KEY  (`id`)
                ) ENGINE=MyISAM DEFAULT CHARSET=utf8;
            ');
        }

        $dca = $objDB->execute('SELECT * FROM tl_metamodel_dca');

        while ($dca->next()) {
            $renderGroupLen = 0;
            if (in_array($dca->flag, array(1,2,3,4))) {
                $renderGroupType = 'char';
                if (in_array($dca->flag, array(1,2))) {
                    $renderGroupLen = 1;
                } else {
                    $renderGroupLen = 2;
                }
            } elseif (in_array($dca->flag, array(5,6))) {
                $renderGroupType = 'day';
            } elseif (in_array($dca->flag, array(7,8))) {
                $renderGroupType = 'month';
            } elseif (in_array($dca->flag, array(9,10))) {
                $renderGroupType = 'year';
            } elseif (in_array($dca->flag, array(11,12))) {
                $renderGroupType = 'digit';
            } else {
                $renderGroupType = 'none';
            }

            $data = array(
                'pid'             => $dca->id,
                'sorting'         => 128,
                'tstamp'          => time(),
                'name'            => null,
                'isdefault'       => '1',
                'ismanualsort'    => '1',
                'rendergrouptype' => $renderGroupType,
                'rendergrouplen'  => $renderGroupLen,
                'rendergroupattr' => 0,
                'rendersort'      => in_array($dca->flag, array(2,4,6,8,10,12)) ? 'desc' : 'asc',
                'rendersortattr'  => 0,
            );

            $objDB
                ->prepare('INSERT INTO tl_metamodel_dca_sortgroup %s')
                ->set($data)
                ->execute();
        }

        TableManipulation::dropColumn('tl_metamodel_dca', 'flag', true);
    }
Upgrade the input screens.

@return void

@SuppressWarnings(PHPMD.CyclomaticComplexity)