Upgrade nipap database schema
776364
def _db_upgrade(self, db_name):
        
        current_db_version = self._get_db_version()
        self._execute(db_schema.functions)
        for i in range(current_db_version, nipap.__db_version__):
            self._logger.info("Upgrading DB schema:", i, "to", i+1)
            upgrade_sql = db_schema.upgrade[i-1] # 0 count on array
            self._execute(upgrade_sql % (db_name))
        self._execute(db_schema.triggers)
80982
public function upgradeDatabase()
    {
        $factory = $this->app->make(TypeFactory::class);

        // check if an attribute with the 'user_selector' handle exists
        $userSelectorAttribute = $factory->getByHandle('user_selector');
        if (is_object($userSelectorAttribute)) {

            // unlink the attribute type from any package and change its name
            $userSelectorAttribute->setPackage(null);
            $userSelectorAttribute->setAttributeTypeName(t('User Selector'));
            $em = $this->app->make(EntityManager::class);
            $em->persist($userSelectorAttribute);
            $em->flush();
        } else {

            // add the 'user_selector' attribute
            $type = $factory->add('user_selector', t('User Selector'));

            // associate the 'user_selector' attribute to collection category
            $category = Category::getByHandle('collection')->getController();
            $category->associateAttributeKeyType($type);

            // associate the 'user_selector' attribute to site category
            $category = Category::getByHandle('site')->getController();
            $category->associateAttributeKeyType($type);

            // associate the 'user_selector' attribute to user category
            $category = Category::getByHandle('user')->getController();
            $category->associateAttributeKeyType($type);

            // associate the 'user_selector' attribute to file category
            $category = Category::getByHandle('file')->getController();
            $category->associateAttributeKeyType($type);

            // associate the 'user_selector' attribute to file category
            $category = Category::getByHandle('event')->getController();
            $category->associateAttributeKeyType($type);
        }

        $db = $this->connection;
        if ($db->tableExists('atUserSelector')) {
            // This is the name of the user selector attribute table in some implementations of the user selector attribute
            // We need to take this data and place it into atNumber.
            $db->query(<<<EOT
insert into atNumber (avID, value)
    select
        atUserSelector.avID, atUserSelector.value
    from
        atUserSelector
    inner join
        AttributeValues on atUserSelector.avID = AttributeValues.avID
    left join
        atNumber on atUserSelector.avID = atNumber.avID
    where
        atNumber.avID is null
EOT
            );
        }
    }
208591
public function upgradeDatabase()
    {
        $em = $this->getPackageEntityManager();
        if ($em !== null) {
            $this->destroyProxyClasses($em);
            $this->installEntitiesDatabase();
        }
        static::installDB($this->getPackagePath() . '/' . FILENAME_PACKAGE_DB);
    }
218971
public function upgradeDatabase()
    {
        $app = Application::getFacadeApplication();

        $this->refreshEntities([
            DateTimeSettings::class,
        ]);
        $config = $app->make('config');
        if (!$config->get('app.curl.verifyPeer')) {
            $config->save('app.http_client.sslverifypeer', false);
        }
        $this->migrateDrafts();

        $this->createSinglePage('/dashboard/system/files/thumbnails/options', 'Thumbnail Options', ['exclude_nav' => true, 'meta_keywords' => 'thumbnail, format, png, jpg, jpeg, quality, compression, gd, imagick, imagemagick, transparency']);
    }
980005
def upgrade():
    """"""
    op.create_table(
        'transaction',
        sa.Column('issued_at', sa.DateTime(), nullable=True),
        sa.Column('id', sa.BigInteger(), nullable=False),
        sa.Column('remote_addr', sa.String(length=50), nullable=True),
    )
    op.create_primary_key('pk_transaction', 'transaction', ['id'])
    if op._proxy.migration_context.dialect.supports_sequences:
        op.execute(CreateSequence(Sequence('transaction_id_seq')))
84957
def upgrade():
    """"""
    op.create_table(
        'records_metadata',
        sa.Column('created', sa.DateTime(), nullable=False),
        sa.Column('updated', sa.DateTime(), nullable=False),
        sa.Column(
            'id', sqlalchemy_utils.types.uuid.UUIDType(), nullable=False),
        sa.Column('json', sqlalchemy_utils.JSONType().with_variant(
            sa.dialects.postgresql.JSON(
                none_as_null=True), 'postgresql',
        ), nullable=True),
        sa.Column('version_id', sa.Integer(), nullable=False),
        sa.PrimaryKeyConstraint('id')
    )
    op.create_table(
        'records_metadata_version',
        sa.Column('created', sa.DateTime(),
                  autoincrement=False, nullable=True),
        sa.Column('updated', sa.DateTime(),
                  autoincrement=False, nullable=True),
        sa.Column('id', sqlalchemy_utils.types.uuid.UUIDType(),
                  autoincrement=False, nullable=False),
        sa.Column('json', sqlalchemy_utils.JSONType().with_variant(
            sa.dialects.postgresql.JSON(
                none_as_null=True), 'postgresql',
        ), autoincrement=False, nullable=True),
        sa.Column('version_id', sa.Integer(),
                  autoincrement=False, nullable=True),
        sa.Column('transaction_id', sa.BigInteger(),
                  autoincrement=False, nullable=False),
        sa.Column('end_transaction_id',
                  sa.BigInteger(), nullable=True),
        sa.Column('operation_type',
                  sa.SmallInteger(), nullable=False),
        sa.PrimaryKeyConstraint('id', 'transaction_id')
    )
    op.create_index(
        op.f('ix_records_metadata_version_end_transaction_id'),
        'records_metadata_version', ['end_transaction_id'], unique=False
    )
    op.create_index(
        op.f('ix_records_metadata_version_operation_type'),
        'records_metadata_version', ['operation_type'], unique=False
    )
    op.create_index(
        op.f('ix_records_metadata_version_transaction_id'),
        'records_metadata_version', ['transaction_id'], unique=False
    )
1262377
public function upgradeSchema(Schema $schema)
    {
        $table = $schema->getTable('FileImageThumbnailPaths');
        if ($table->hasIndex('thumbnailPathID')) {
            $table->dropIndex('thumbnailPathID');
        }
        if (!$table->hasColumn('thumbnailFormat')) {
            $table->addColumn(
                'thumbnailFormat',
                'string',
                [
                    'notnull' => true,
                    'default' => '',
                    'length' => 5,
                ]
            );
            $table->setPrimaryKey([
                'fileID',
                'fileVersionID',
                'thumbnailTypeHandle',
                'storageLocationID',
                'thumbnailFormat',
            ]);
        }
    }
702695
public function upgradeDatabase()
    {
        // assign the page owner access entity to the page type category
        $pe = Type::getByHandle('page_owner');
        $category = Category::getByHandle('page_type');
        if (is_object($category) && is_object($pe)) {
            $category->associateAccessEntityType($pe);
        }
    }
764164
def do_upgrade():
    """"""
    op.alter_column(
        table_name='knwKBRVAL',
        column_name='id_knwKB',
        type_=db.MediumInteger(8, unsigned=True),
        existing_nullable=False,
        existing_server_default='0'
    )
962296
public function upgradeDatabase()
    {
        $this->refreshEntities([
            ThumbnailTypeEntity::class,
            ThumbnailTypeFileSet::class,
        ]);

        $type = Type::getByHandle('file_manager_detail');
        if ($type) {
            /*
             * Fix issue where file manager detail thumbnails were being added without a height.
             *
             * @var \Concrete\Core\Entity\File\Image\Thumbnail\Type\Type $type
             */
            if (!$type->getHeight()) {
                $type->setHeight($type->getWidth());
                $em = $this->connection->getEntityManager();
                $em->persist($type);
                $em->flush();
            }
        }
    }
142809
public function upgradeDatabase()
    {
        $this->output(t('Refreshing table FileImageThumbnailPaths...'));
        \Concrete\Core\Database\Schema\Schema::refreshCoreXMLSchema([
            'FileImageThumbnailPaths',
        ]);
    }
715514
public function upgradeDatabase()
    {
        \Concrete\Core\Database\Schema\Schema::refreshCoreXMLSchema([
            'PageFeeds',
        ]);

        // I can't seem to get the doctrine cache to clear any other way.
        $cms = \Core::make('app');
        $cms->clearCaches();

        $this->purgeOrphanedScrapbooksBlocks();
    }
213913
public function upgradeDatabase()
    {
        if ($this->connection->getSchemaManager()->tablesExist('CalendarEventVersions')) {
            $events = (int) $this->connection->fetchColumn('select count(*) from CalendarEventVersions');
        } else {
            $events = null;
        }
        if ($events === null || $events === 0) {
            $this->migrateCalendar();
        }
    }
852156
def upgrade():
    """"""
    op.create_table(
        'access_actionsroles',
        sa.Column('id', sa.Integer(), nullable=False),
        sa.Column('action', sa.String(length=80), nullable=True),
        sa.Column('exclude', sa.Boolean(name='exclude'), server_default='0',
                  nullable=False),
        sa.Column('argument', sa.String(length=255), nullable=True),
        sa.Column('role_id', sa.Integer(), nullable=False),
        sa.ForeignKeyConstraint(['role_id'], [u'accounts_role.id'], ),
        sa.PrimaryKeyConstraint('id'),
        sa.UniqueConstraint('action', 'exclude', 'argument', 'role_id',
                            name='access_actionsroles_unique')
    )
    op.create_index(
        op.f('ix_access_actionsroles_action'), 'access_actionsroles',
        ['action'], unique=False)
    op.create_index(
        op.f('ix_access_actionsroles_argument'), 'access_actionsroles',
        ['argument'], unique=False)
    op.create_table(
        'access_actionsusers',
        sa.Column('id', sa.Integer(), nullable=False),
        sa.Column('action', sa.String(length=80), nullable=True),
        sa.Column('exclude', sa.Boolean(name='exclude'), server_default='0',
                  nullable=False),
        sa.Column('argument', sa.String(length=255), nullable=True),
        sa.Column('user_id', sa.Integer(), nullable=True),
        sa.ForeignKeyConstraint(['user_id'], [u'accounts_user.id'], ),
        sa.PrimaryKeyConstraint('id'),
        sa.UniqueConstraint('action', 'exclude', 'argument', 'user_id',
                            name='access_actionsusers_unique')
    )
    op.create_index(
        op.f('ix_access_actionsusers_action'), 'access_actionsusers',
        ['action'], unique=False)
    op.create_index(
        op.f('ix_access_actionsusers_argument'), 'access_actionsusers',
        ['argument'], unique=False)
807391
public function upgradeDatabase()
    {
        $ft = FlagType::getByhandle('spam');
        if (!is_object($ft)) {
            FlagType::add('spam');
        }

        $this->refreshBlockType('image_slider');

        $types = [Type::getByHandle('group'), Type::getByHandle('user'), Type::getByHandle('group_set'), Type::getByHandle('group_combination')];
        $categories = [Category::getByHandle('conversation'), Category::getByHandle('conversation_message')];
        foreach ($categories as $category) {
            foreach ($types as $pe) {
                if (is_object($category) && is_object($pe)) {
                    $category->associateAccessEntityType($pe);
                }
            }
        }

        try {
            $gat = AuthenticationType::getByHandle('google');
        } catch (Exception $e) {
            $gat = AuthenticationType::add('google', 'Google');
            if (is_object($gat)) {
                $gat->disable();
            }
        }

        // fix register page permissions
        $g1 = \Group::getByID(GUEST_GROUP_ID);
        $register = \Page::getByPath('/register', 'RECENT');
        $register->assignPermissions($g1, ['view_page']);

        // add new permissions, set it to the same value as edit page permissions on all pages.
        $epk = PermissionKey::getByHandle('edit_page_permissions');
        $msk = PermissionKey::getByHandle('edit_page_multilingual_settings');
        $ptk = PermissionKey::getByHandle('edit_page_page_type');
        if (!is_object($msk)) {
            $msk = PermissionKey::add('page', 'edit_page_multilingual_settings', 'Edit Multilingual Settings', 'Controls whether a user can see the multilingual settings menu, re-map a page or set a page as ignored in multilingual settings.', false, false);
        }
        if (!is_object($ptk)) {
            $ptk = PermissionKey::add('page', 'edit_page_page_type', 'Edit Page Type', 'Change the type of an existing page.', false, false);
        }
        $db = \Database::get();
        $r = $db->Execute('select cID from Pages where cInheritPermissionsFrom = "OVERRIDE" order by cID asc');
        while ($row = $r->FetchRow()) {
            $c = Page::getByID($row['cID']);
            if (is_object($c) && !$c->isError()) {
                $epk->setPermissionObject($c);
                $msk->setPermissionObject($c);
                $ptk->setPermissionObject($c);
                $rpa = $epk->getPermissionAccessObject();
                if (is_object($rpa)) {
                    $pt = $msk->getPermissionAssignmentObject();
                    if (is_object($pt)) {
                        $pt->clearPermissionAssignment();
                        $pt->assignPermissionAccess($rpa);
                    }
                    $pt = $ptk->getPermissionAssignmentObject();
                    if (is_object($pt)) {
                        $pt->clearPermissionAssignment();
                        $pt->assignPermissionAccess($rpa);
                    }
                }
            }
        }

        // add new page type permissions
        $epk = PermissionKey::getByHandle('edit_page_type_permissions');
        $msk = PermissionKey::getByHandle('edit_page_type');
        $dsk = PermissionKey::getByHandle('delete_page_type');
        if (!is_object($msk)) {
            $msk = PermissionKey::add('page_type', 'edit_page_type', 'Edit Page Type', '', false, false);
        }
        if (!is_object($dsk)) {
            $dsk = PermissionKey::add('page_type', 'delete_page_type', 'Delete Page Type', '', false, false);
        }
        $list = \Concrete\Core\Page\Type\Type::getList();
        foreach ($list as $pagetype) {
            $epk->setPermissionObject($pagetype);
            $msk->setPermissionObject($pagetype);
            $dsk->setPermissionObject($pagetype);
            $rpa = $epk->getPermissionAccessObject();
            if (is_object($rpa)) {
                $pt = $msk->getPermissionAssignmentObject();
                if (is_object($pt)) {
                    $pt->clearPermissionAssignment();
                    $pt->assignPermissionAccess($rpa);
                }
                $pt = $dsk->getPermissionAssignmentObject();
                if (is_object($pt)) {
                    $pt->clearPermissionAssignment();
                    $pt->assignPermissionAccess($rpa);
                }
            }
        }

        // block type
        $bt = BlockType::getByHandle('switch_language');
        if (!is_object($bt)) {
            $bt = BlockType::installBlockType('switch_language');
        }

        // single pages
        $this->createSinglePage('/dashboard/system/multilingual', 'Multilingual', ['meta_keywords' => 'multilingual, localization, internationalization, i18n']);
        $this->createSinglePage('/dashboard/system/multilingual/setup', 'Multilingual Setup');
        $this->createSinglePage('/dashboard/system/multilingual/page_report', 'Page Report');
        $this->createSinglePage('/dashboard/system/multilingual/translate_interface', 'Translate Interface');
        $this->createSinglePage('/dashboard/pages/types/attributes', 'Page Type Attributes');
    }
1366222
def upgrade():
    """"""
    op.create_table(
        'pidstore_pid',
        sa.Column('created', sa.DateTime(), nullable=False),
        sa.Column('updated', sa.DateTime(), nullable=False),
        sa.Column('id', sa.Integer(), nullable=False),
        sa.Column('pid_type', sa.String(length=6), nullable=False),
        sa.Column('pid_value', sa.String(length=255), nullable=False),
        sa.Column('pid_provider', sa.String(length=8), nullable=True),
        sa.Column('status', sa.CHAR(1), nullable=False),
        sa.Column('object_type', sa.String(length=3), nullable=True),
        sa.Column(
            'object_uuid',
            sqlalchemy_utils.types.uuid.UUIDType(),
            nullable=True
        ),
        sa.PrimaryKeyConstraint('id')
    )
    op.create_index(
        'idx_object', 'pidstore_pid', ['object_type', 'object_uuid'],
        unique=False
    )
    op.create_index('idx_status', 'pidstore_pid', ['status'], unique=False)
    op.create_index(
        'uidx_type_pid', 'pidstore_pid', ['pid_type', 'pid_value'],
        unique=True
    )
    op.create_table(
        'pidstore_recid',
        sa.Column('recid', sa.BigInteger(), nullable=False),
        sa.PrimaryKeyConstraint('recid')
    )
    op.create_table(
        'pidstore_redirect',
        sa.Column('created', sa.DateTime(), nullable=False),
        sa.Column('updated', sa.DateTime(), nullable=False),
        sa.Column(
            'id',
            sqlalchemy_utils.types.uuid.UUIDType(),
            nullable=False
        ),
        sa.Column('pid_id', sa.Integer(), nullable=False),
        sa.ForeignKeyConstraint(
            ['pid_id'],
            [u'pidstore_pid.id'],
            onupdate='CASCADE',
            ondelete='RESTRICT'
        ),
        sa.PrimaryKeyConstraint('id')
    )
412842
public function upgradeDatabase()
    {
        $db = $this->connection;
        $db->executeQuery("UPDATE FileImageThumbnailPaths SET thumbnailFormat = ? WHERE thumbnailFormat = '' AND (path LIKE '%.jpg' OR path LIKE '%.jpeg' OR path LIKE '%.pjpg' OR path LIKE '%.pjpeg')", [BitmapFormat::FORMAT_JPEG]);
        $db->executeQuery("UPDATE FileImageThumbnailPaths SET thumbnailFormat = ? WHERE thumbnailFormat = ''", [BitmapFormat::FORMAT_PNG]);
    }