Add an "is_active" column to the Thesaurus table.

@param \Magento\Framework\Setup\SchemaSetupInterface $setup Setup instance
162651
public function appendIsActiveColumn(SchemaSetupInterface $setup)
    {
        $setup->getConnection()->addColumn(
            $setup->getTable(ThesaurusInterface::TABLE_NAME),
            ThesaurusInterface::IS_ACTIVE,
            [
                'type'     => \Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT,
                'nullable' => false,
                'default'  => 1,
                'comment'  => 'If the Thesaurus is active',
            ]
        );
    }
845119
public function convertSerializedRulesToJson(\Magento\Setup\Module\DataSetup $setup)
    {
        $fieldDataConverter = $this->fieldDataConverterFactory->create(
            \Magento\Framework\DB\DataConverter\SerializedToJson::class
        );

        $fieldDataConverter->convert(
            $setup->getConnection(),
            $setup->getTable(OptimizerInterface::TABLE_NAME),
            OptimizerInterface::OPTIMIZER_ID,
            OptimizerInterface::CONFIG
        );

        $fieldDataConverter->convert(
            $setup->getConnection(),
            $setup->getTable(OptimizerInterface::TABLE_NAME),
            OptimizerInterface::OPTIMIZER_ID,
            OptimizerInterface::RULE_CONDITION
        );
    }
696658
public function createOptimizerTable(SchemaSetupInterface $setup)
    {
        if (!$setup->getConnection()->isTableExists($setup->getTable(OptimizerInterface::TABLE_NAME))) {
            $table = $setup->getConnection()
                ->newTable($setup->getTable(OptimizerInterface::TABLE_NAME))
                ->addColumn(
                    OptimizerInterface::OPTIMIZER_ID,
                    \Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT,
                    null,
                    ['identity' => true, 'nullable' => false, 'primary' => true],
                    'Optimizer ID'
                )
                ->addColumn(
                    OptimizerInterface::STORE_ID,
                    \Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT,
                    null,
                    ['nullable' => false],
                    'Store id'
                )
                ->addColumn(
                    OptimizerInterface::IS_ACTIVE,
                    \Magento\Framework\DB\Ddl\Table::TYPE_BOOLEAN,
                    null,
                    ['nullable' => false, 'default' => '1'],
                    'Is Optimizer Active'
                )
                ->addColumn(
                    OptimizerInterface::FROM_DATE,
                    \Magento\Framework\DB\Ddl\Table::TYPE_DATE,
                    null,
                    ['nullable' => true],
                    'Enable rule from date'
                )
                ->addColumn(
                    OptimizerInterface::TO_DATE,
                    \Magento\Framework\DB\Ddl\Table::TYPE_DATE,
                    null,
                    ['nullable' => true],
                    'Enable rule to date'
                )
                ->addColumn(
                    OptimizerInterface::NAME,
                    \Magento\Framework\DB\Ddl\Table::TYPE_TEXT,
                    255,
                    ['nullable' => false],
                    'Optimizer Name'
                )
                ->addColumn(
                    OptimizerInterface::MODEL,
                    \Magento\Framework\DB\Ddl\Table::TYPE_TEXT,
                    255,
                    [],
                    'Optimizer model'
                )
                ->addColumn(
                    OptimizerInterface::CONFIG,
                    \Magento\Framework\DB\Ddl\Table::TYPE_TEXT,
                    '',
                    [],
                    'Optimizer serialized configuration'
                )
                ->addColumn(
                    OptimizerInterface::RULE_CONDITION,
                    \Magento\Framework\DB\Ddl\Table::TYPE_TEXT,
                    '',
                    [],
                    'Optimizer rule condition configuration'
                )
                ->setComment('Search optimizer Table');

            $setup->getConnection()->createTable($table);
        }
    }
1325274
protected function setActiveSorting()
    {
        $this->sSorting = Input::get('sort');
        if (empty($this->sSorting)) {
            $this->sSorting = $this->property('sorting');
        }
    }
134001
public function upgrade(ModuleDataSetupInterface $setup, ModuleContextInterface $context)
    {
        $setup->startSetup();
        $eavSetup = $this->eavSetupFactory->create(['setup' => $setup]);

        if (version_compare($context->getVersion(), '1.2.0', '<')) {
            $this->catalogSetup->updateCategorySearchableAttributes($eavSetup);
        }

        if (version_compare($context->getVersion(), '1.2.1', '<')) {
            $this->catalogSetup->updateImageAttribute($eavSetup);
        }

        if (version_compare($context->getVersion(), '1.4.1', '<')) {
            $this->catalogSetup->updateImageAttribute($eavSetup);
        }

        $setup->endSetup();
    }
228303
public function upgrade(SchemaSetupInterface $setup, ModuleContextInterface $context)
    {
        $setup->startSetup();

        if (version_compare($context->getVersion(), "1.1.0") < 0) {
            $setup->startSetup();

            $logTable = $setup->getConnection()->newTable($setup->getTable('elasticsuite_tracker_log_event'))
                ->addColumn(
                    'event_id',
                    \Magento\Framework\DB\Ddl\Table::TYPE_TEXT,
                    '32',
                    ['nullable' => false, 'primary' => true],
                    'Event Id'
                )
                ->addColumn(
                    'date',
                    \Magento\Framework\DB\Ddl\Table::TYPE_TIMESTAMP,
                    null,
                    ['nullable' => false, 'default' => \Magento\Framework\DB\Ddl\Table::TIMESTAMP_INIT],
                    'Event date'
                )
                ->addColumn(
                    'data',
                    \Magento\Framework\DB\Ddl\Table::TYPE_TEXT,
                    '2M',
                    ['nullable' => false],
                    'Event data'
                )
                ->addColumn(
                    'data',
                    \Magento\Framework\DB\Ddl\Table::TYPE_TEXT,
                    '2M',
                    ['nullable' => false],
                    'Event data'
                );

            $setup->getConnection()->createTable($logTable);
        }

        if (version_compare($context->getVersion(), '1.2.0', '<')) {
            $this->createCustomerLinkTable($setup);
        }

        $setup->endSetup();
    }
205890
public function setFeatured($enable)
    {
        $t = $this->getNewsModelAdapter()->getTable();

        if (true === $enable) {
            $this->columns[] = "$t.featured=?";
            $this->values[] = 1;
        } elseif (false === $enable) {
            $this->columns[] = "$t.featured=?";
            $this->values[] = '';
        }
    }
121888
private function setup()
    {
        $manager = $this->getConnection()->getSchemaManager();
        if ($this->tablesExist === true || $manager->tablesExist([$this->options['db_table']]) === true) {
            $this->tablesExist = true;

            return;
        }

        $schema = new Schema();
        $table = $schema->createTable($this->options['db_table']);

        $table->addColumn($this->options['db_column_feature'], 'string', ['length' => 255]);
        $table->addColumn($this->options['db_column_state'], 'boolean');

        $table->setPrimaryKey([$this->options['db_column_feature']]);

        $platform = $this->getConnection()->getDatabasePlatform();
        $queries = $schema->toSql($platform);

        foreach ($queries as $query) {
            $this->getConnection()->executeQuery($query);
        }

        $this->tablesExist = true;
    }
69141
public function uninstall(SchemaSetupInterface $setup, ModuleContextInterface $context)
    {
        $statuses = [
            'pagseguro_iniciado',
            'pagseguro_aguardando_pagamento',
            'pagseguro_cancelada',
            'pagseguro_chargeback_debitado',
            'pagseguro_devolvida',
            'pagseguro_disponivel',
            'pagseguro_em_analise',
            'pagseguro_em_contestacao',
            'pagseguro_em_disputa',
            'pagseguro_paga'
        ];
        
        $paths = [
            'pagseguro/store/reference',
            'payment/pagseguro/active',
            'payment/pagseguro/title',
            'payment/pagseguro/email',
            'payment/pagseguro/token',
            'payment/pagseguro/redirect',
            'payment/pagseguro/notification',
            'payment/pagseguro/charset',
            'payment/pagseguro/log',
            'payment/pagseguro/log_file',
            'payment/pagseguro/checkout',
            'payment/pagseguro/environment',
            'payment/pagseguro/abandoned_active'
        ];

        $setup->startSetup();
        $this->dropPagSeguroOrdersTable($setup);
        $this->dropColumnsFromSalesOrderGrid($setup);
        $this->removeDataFromSalesOrderStatus($setup, $statuses);
        $this->removeDataFromSalesOrderStatusState($setup, $statuses);
        $this->removeDataFromCoreConfigData($setup, $paths);
        $setup->endSetup();
    }
171752
public function addSuite($suite)
    {
        if (true === $this->pending) {
            $suite->setPending();
        }
        $this->suites[] = $suite;
    }
694586
public function createOptimizerLimitationTable(SchemaSetupInterface $setup)
    {
        if (!$setup->getConnection()->isTableExists($setup->getTable(OptimizerInterface::TABLE_NAME_LIMITATION))) {
            $categoryIdField = $this->metadataPool->getMetadata(\Magento\Catalog\Api\Data\CategoryInterface::class)->getIdentifierField();

            $optimizerCategoryTable = $setup->getConnection()
                ->newTable($setup->getTable(OptimizerInterface::TABLE_NAME_LIMITATION))
                ->addColumn(
                    OptimizerInterface::OPTIMIZER_ID,
                    \Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT,
                    null,
                    ['nullable' => false],
                    'Optimizer ID'
                )
                ->addColumn(
                    'category_id',
                    \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER,
                    null,
                    ['unsigned' => true, 'nullable' => true, 'default' => null],
                    'Category ID'
                )
                ->addColumn(
                    'query_id',
                    \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER,
                    null,
                    ['unsigned' => true, 'nullable' => true, 'default' => null],
                    'Query ID'
                )
                ->addForeignKey(
                    $setup->getFkName(
                        OptimizerInterface::TABLE_NAME_LIMITATION,
                        OptimizerInterface::OPTIMIZER_ID,
                        OptimizerInterface::TABLE_NAME,
                        OptimizerInterface::OPTIMIZER_ID
                    ),
                    OptimizerInterface::OPTIMIZER_ID,
                    $setup->getTable(OptimizerInterface::TABLE_NAME),
                    OptimizerInterface::OPTIMIZER_ID,
                    \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
                )
                ->addForeignKey(
                    $setup->getFkName(
                        OptimizerInterface::TABLE_NAME_LIMITATION,
                        'category_id',
                        'catalog_category_entity',
                        $categoryIdField
                    ),
                    'category_id',
                    $setup->getTable('catalog_category_entity'),
                    $categoryIdField,
                    \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
                )
                ->addForeignKey(
                    $setup->getFkName(OptimizerInterface::TABLE_NAME_LIMITATION, 'query_id', 'search_query', 'query_id'),
                    'query_id',
                    $setup->getTable('search_query'),
                    'query_id',
                    \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
                )
                ->addIndex(
                    $setup->getIdxName(
                        OptimizerInterface::TABLE_NAME_LIMITATION,
                        [OptimizerInterface::OPTIMIZER_ID, 'category_id', 'query_id'],
                        \Magento\Framework\DB\Adapter\AdapterInterface::INDEX_TYPE_UNIQUE
                    ),
                    [OptimizerInterface::OPTIMIZER_ID, 'category_id', 'query_id'],
                    ['type' => \Magento\Framework\DB\Adapter\AdapterInterface::INDEX_TYPE_UNIQUE]
                )
                ->setComment('Search optimizer limitation Table');

            $setup->getConnection()->createTable($optimizerCategoryTable);
        }
    }
513182
private function addIndexKeyForCatalog(
        SchemaSetupInterface $setup,
        \Magento\Framework\DB\Adapter\AdapterInterface $connection
    ) {
        $connection->addForeignKey(
            $setup->getFkName(
                Schema::EMAIL_CATALOG_TABLE,
                'product_id',
                'catalog_product_entity',
                'entity_id'
            ),
            $setup->getTable(Schema::EMAIL_CATALOG_TABLE),
            'product_id',
            $setup->getTable('catalog_product_entity'),
            'entity_id',
            \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
        );
    }
27809
public function addStoreIdColumnToPositionTable(SchemaSetupInterface $setup)
    {
        $tableName = $setup->getTable('smile_virtualcategory_catalog_category_product_position');

        $setup->getConnection()->addColumn(
            $tableName,
            'store_id',
            [
                'type'     => \Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT,
                'unsigned' => true,
                'nullable' => false,
                'default'  => 0,
                'comment'  => 'Store ID',
                'after'    => 'product_id',
            ]
        );

        $primaryKeyName = $setup->getConnection()->getPrimaryKeyName($tableName);
        // The existing primary key will be dropped.
        $setup->getConnection()->addIndex(
            $tableName,
            $primaryKeyName,
            ['category_id', 'product_id', 'store_id'],
            AdapterInterface::INDEX_TYPE_PRIMARY
        );

        $setup->getConnection()->addForeignKey(
            $setup->getFkName($tableName, 'store_id', $setup->getTable('store'), 'store_id'),
            $tableName,
            'store_id',
            $setup->getTable('store'),
            'store_id',
            \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
        );
    }
1038736
public function install(SchemaSetupInterface $setup, ModuleContextInterface $context)
    {
        $installer = $setup;

        $installer->startSetup();

        $this->installPostEntity($installer);
        $this->installCategoryEntity($installer);

        $table = $installer->getConnection()
            ->newTable($installer->getTable('mst_blog_category_post'))
            ->addColumn(
                'category_id',
                Table::TYPE_INTEGER,
                null,
                ['unsigned' => true, 'nullable' => false, 'primary' => true, 'default' => '0'],
                'Category ID'
            )->addColumn(
                'post_id',
                Table::TYPE_INTEGER,
                null,
                ['unsigned' => true, 'nullable' => false, 'primary' => true, 'default' => '0'],
                'Post ID'
            )->addIndex(
                $installer->getIdxName('mst_blog_category_post', ['post_id']),
                ['post_id']
            )->addForeignKey(
                $installer->getFkName(
                    'mst_blog_category_post',
                    'category_id',
                    'mst_blog_category_entity',
                    'entity_id'
                ),
                'category_id',
                $installer->getTable('mst_blog_category_entity'),
                'entity_id',
                Table::ACTION_CASCADE
            )->addForeignKey(
                $installer->getFkName(
                    'mst_blog_category_post',
                    'post_id',
                    'mst_blog_post_entity',
                    'entity_id'
                ),
                'post_id',
                $installer->getTable('mst_blog_post_entity'),
                'entity_id',
                Table::ACTION_CASCADE
            )->setComment('Blog Post To Category Linkage Table');
        $installer->getConnection()->createTable($table);

        $table = $installer->getConnection()
            ->newTable($installer->getTable('mst_blog_tag'))
            ->addColumn(
                'tag_id',
                Table::TYPE_INTEGER,
                null,
                ['identity' => true, 'nullable' => false, 'primary' => true],
                'Tag ID'
            )->addColumn(
                'name',
                Table::TYPE_TEXT,
                255,
                [],
                'Name'
            )->addColumn(
                'url_key',
                Table::TYPE_TEXT,
                255,
                [],
                'Url Key'
            )->setComment('Tag Table');
        $installer->getConnection()->createTable($table);

        $table = $installer->getConnection()
            ->newTable($installer->getTable('mst_blog_tag_post'))
            ->addColumn(
                'tag_id',
                Table::TYPE_INTEGER,
                null,
                ['unsigned' => true, 'nullable' => false, 'primary' => true, 'default' => '0'],
                'Tag ID'
            )->addColumn(
                'post_id',
                Table::TYPE_INTEGER,
                null,
                ['unsigned' => true, 'nullable' => false, 'primary' => true, 'default' => '0'],
                'Post ID'
            )->addColumn(
                'store_id',
                Table::TYPE_SMALLINT,
                null,
                ['unsigned' => true, 'nullable' => false, 'default' => '0'],
                'Store ID'
            )->addIndex(
                $installer->getIdxName('mst_blog_tag_post', ['post_id']),
                ['post_id']
            )->addForeignKey(
                $installer->getFkName(
                    'mst_blog_tag_post',
                    'post_id',
                    'mst_blog_post_entity',
                    'entity_id'
                ),
                'post_id',
                $installer->getTable('mst_blog_post_entity'),
                'entity_id',
                Table::ACTION_CASCADE
            )->setComment('Blog Post To Tag Linkage Table');
        $installer->getConnection()->createTable($table);
    }
1080119
protected function addActiveConnection(ConnectionInterface $connection)
    {
        if (!$this->activeConnections) {
            $this->activeConnections = new \SplObjectStorage;
        }
        $this->activeConnections->attach($connection);
    }
1278117
public function setTable(Table $table, $setup_join_tables = false): self
        {
            $this->table = $table;

            if ($setup_join_tables) {
                $this->setupJoinTables();
            }

            return $this;
        }
90788
public function addUseStorePositionsAttribute(\Magento\Eav\Setup\EavSetup $eavSetup)
    {
        $eavSetup->addAttribute(
            Category::ENTITY,
            'use_store_positions',
            [
                'type'       => 'int',
                'input'      => 'select',
                'source'     => 'Magento\Eav\Model\Entity\Attribute\Source\Boolean',
                'label'      => 'Use store positions',
                'global'     => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_STORE,
                'required'   => true,
                'default'    => 0,
                'visible'    => true,
                'note'       => "Use store positions.",
                'sort_order' => 220,
                'group'      => 'General Information',
            ]
        );

        // Mandatory to ensure next installers will have proper EAV Attributes definitions.
        $this->eavConfig->clear();
    }