Installs DB schema for a module Faonni_ProductSaleIndexer

@param SchemaSetupInterface $setup
@param ModuleContextInterface $context
@return void
550495
public function install(SchemaSetupInterface $setup, ModuleContextInterface $context)
    {
        $installer = $setup;
        $installer->startSetup();
        $connection = $installer->getConnection();

        /**
         * Create table 'faonni_catalog_product_index_sale'
         */
        if (!$installer->tableExists('faonni_catalog_product_index_sale')) {
			$table = $connection
				->newTable($installer->getTable('faonni_catalog_product_index_sale'))
				->addColumn(
					'entity_id',
					Table::TYPE_INTEGER,
					null,
					['unsigned' => true, 'nullable' => false, 'primary' => true],
					'Entity Id'
				)
				->addColumn(
					'website_id',
					Table::TYPE_SMALLINT,
					null,
					['unsigned' => true, 'nullable' => false, 'primary' => true],
					'Website ID'
				)				
				->addIndex(
					$installer->getIdxName('faonni_catalog_product_index_sale', ['website_id']),
					['website_id']
				)				
				->addForeignKey(
					$installer->getFkName('faonni_catalog_product_index_sale', 'website_id', 'store_website', 'website_id'),
					'website_id',
					$installer->getTable('store_website'),
					'website_id',
					Table::ACTION_CASCADE
				)
				->addForeignKey(
					$installer->getFkName('faonni_catalog_product_index_sale', 'entity_id', 'catalog_product_entity', 'entity_id'),
					'entity_id',
					$installer->getTable('catalog_product_entity'),
					'entity_id',
					Table::ACTION_CASCADE
				)
				->setComment('Catalog Product Sale Index Table');

			$connection->createTable($table);		
		} 

        $installer->endSetup();
    }
892883
private function checkAndCreateAbandonedCart($setup, $context)
    {
        $connection = $setup->getConnection();
        $abandonedCartTableName = $setup->getTable(Schema::EMAIL_ABANDONED_CART_TABLE);

        if (version_compare($context->getVersion(), '2.3.8', '>') &&
            ! $connection->isTableExists($abandonedCartTableName)
        ) {
            $this->shared->createAbandonedCartTable($setup, $abandonedCartTableName);
        }
    }
1166651
protected function setupObject()
    {
        $this->setPackage($this->getAttribute("package", $this->pkg));
        $this->setSchema($this->getAttribute("schema", $this->schema));
        $this->setNamespace($this->getAttribute("namespace", $this->namespace));
    }
778646
public function initializeContext(Context $context)
    {
        if (false === $context instanceof AliceContextInterface) {
            return;
        }

        /* @var AliceContextInterface $context */
        $fixturesBasePath = $this->fixturesBasePath;
        switch (true) {

            case $context instanceof AliceODMContext:
                $fixturesBasePath .= '/ODM';
                break;

            case $context instanceof AliceORMContext:
                $fixturesBasePath .= '/ORM';
                break;

            case $context instanceof AlicePHPCRContext:
                $fixturesBasePath .= '/PHPCR';
                break;
        }

        if (null === $context->getBasePath()) {
            $context->setBasePath($fixturesBasePath);
        }
    }
1315234
public function install(SchemaSetupInterface $setup, ModuleContextInterface $context)
    {
        $installer = $setup;

        $installer->startSetup();

        /*
         * Create table 'wk_grid_records'
         */

        $table = $installer->getConnection()->newTable(
            $installer->getTable('worldnettps_securecard_records')
        )->addColumn(
            'entity_id',
            \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER,
            null,
            ['identity' => true, 'nullable' => false, 'primary' => true],
            'Grid Record Id'
        )->addColumn(
            'merchant_ref',
            \Magento\Framework\DB\Ddl\Table::TYPE_TEXT,
            50,
            ['nullable' => false],
            'Merchant Ref'
        )->addColumn(
            'terminal_id',
            \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER,
            null,
            ['nullable' => false],
            'Terminal Id'
        )->addColumn(
            'card_expiry',
            \Magento\Framework\DB\Ddl\Table::TYPE_TEXT,
            4,
            ['nullable' => false],
            'Card Expiry'
        )->addColumn(
            'card_type',
            \Magento\Framework\DB\Ddl\Table::TYPE_TEXT,
            10,
            ['nullable' => false],
            'Card Type'
        )->addColumn(
            'card_holder_name',
            \Magento\Framework\DB\Ddl\Table::TYPE_TEXT,
            255,
            ['nullable' => false],
            'Card Holder Name'
        )->addColumn(
            'card_reference',
            \Magento\Framework\DB\Ddl\Table::TYPE_TEXT,
            50,
            ['nullable' => false],
            'Card Reference'
        )->addColumn(
            'customer_id',
            \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER,
            null,
            ['nullable' => false],
            'Customer Id'
        )->addColumn(
            'obfuscated_card_number',
            \Magento\Framework\DB\Ddl\Table::TYPE_TEXT,
            16,
            ['nullable' => false],
            'Card Number'
        )->addColumn(
            'created_at',
            \Magento\Framework\DB\Ddl\Table::TYPE_TIMESTAMP,
            null,
            [],
            'Creation Time'
        )->addColumn(
            'update_time',
            \Magento\Framework\DB\Ddl\Table::TYPE_TIMESTAMP,
            null,
            [],
            'Modification Time'
        )->addIndex(
            $installer->getIdxName(
                'worldnettps_securecard_records',
                ['merchant_ref'],
                \Magento\Framework\DB\Adapter\AdapterInterface::INDEX_TYPE_UNIQUE
            ),
            'merchant_ref',
            ['type' => \Magento\Framework\DB\Adapter\AdapterInterface::INDEX_TYPE_UNIQUE]
        )->addIndex(
            $installer->getIdxName(
                'worldnettps_securecard_records',
                ['card_reference'],
                \Magento\Framework\DB\Adapter\AdapterInterface::INDEX_TYPE_UNIQUE
            ),
            'card_reference',
            ['type' => \Magento\Framework\DB\Adapter\AdapterInterface::INDEX_TYPE_UNIQUE]
        )->setComment(
            'Row Data Table'
        );

        $installer->getConnection()->createTable($table);
        $installer->endSetup();
    }
839276
public function upgrade(SchemaSetupInterface $setup, ModuleContextInterface $context)
    {
        $installer = $setup;
        $connection = $installer->getConnection();

        if (version_compare($context->getVersion(), '1.0.1') < 0) {
            $connection->dropTable($installer->getTable('mst_blog_author'));

            $table = $installer->getConnection()->newTable(
                $installer->getTable('mst_blog_author')
            )->addColumn(
                'author_id',
                Table::TYPE_INTEGER,
                null,
                ['unsigned' => true, 'nullable' => false, 'primary' => true, 'default' => '0'],
                'Author Id'
            )->addColumn(
                'user_id',
                Table::TYPE_INTEGER,
                null,
                ['unsigned' => true, 'nullable' => false, 'primary' => true, 'default' => '0'],
                'User Id'
            )->addColumn(
                'display_name',
                Table::TYPE_TEXT,
                255,
                ['nullable' => true],
                'Display name'
            )->addColumn(
                'image',
                Table::TYPE_TEXT,
                255,
                ['nullable' => true],
                'Image'
            )->addColumn(
                'bio',
                Table::TYPE_TEXT,
                null,
                ['nullable' => true],
                'Bio'
            )->addForeignKey(
                $installer->getFkName(
                    'mst_blog_author',
                    'user_id',
                    'admin_user',
                    'user_id'
                ),
                'user_id',
                $installer->getTable('admin_user'),
                'user_id',
                Table::ACTION_CASCADE
            )->setComment(
                'Authors'
            );

            $installer->getConnection()->createTable($table);
        }

        if (version_compare($context->getVersion(), '1.0.2') < 0) {
            $connection->dropTable($installer->getTable('mst_blog_post_product'));

            $table = $installer->getConnection()
                ->newTable($installer->getTable('mst_blog_post_product'))
                ->addColumn(
                    'post_id',
                    Table::TYPE_INTEGER,
                    null,
                    ['unsigned' => true, 'nullable' => false, 'primary' => true, 'default' => '0'],
                    'Post ID'
                )->addColumn(
                    'product_id',
                    Table::TYPE_INTEGER,
                    null,
                    ['unsigned' => true, 'nullable' => false, 'primary' => true, 'default' => '0'],
                    'Product ID'
                )->addColumn(
                    'position',
                    Table::TYPE_INTEGER,
                    null,
                    ['unsigned' => true, 'nullable' => true, 'default' => '0'],
                    'Position'
                )->addIndex(
                    $installer->getIdxName('mst_blog_post_product', ['post_id']),
                    ['post_id']
                )->addIndex(
                    $installer->getIdxName('mst_blog_post_product', ['product_id']),
                    ['product_id']
                )->addForeignKey(
                    $installer->getFkName(
                        'mst_blog_post_product',
                        'product_id',
                        'catalog_product_entity',
                        'entity_id'
                    ),
                    'product_id',
                    $installer->getTable('catalog_product_entity'),
                    'entity_id',
                    Table::ACTION_CASCADE
                )->addForeignKey(
                    $installer->getFkName(
                        'mst_blog_post_product',
                        '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 Product Linkage Table');
            $installer->getConnection()->createTable($table);
        }

        if (version_compare($context->getVersion(), '1.0.3') < 0) {
            $connection->dropTable($installer->getTable('mst_blog_store_post'));

            $table = $installer->getConnection()
                ->newTable($installer->getTable('mst_blog_store_post'))
                ->addColumn(
                    'store_id',
                    Table::TYPE_SMALLINT,
                    null,
                    ['unsigned' => true, 'nullable' => false, 'primary' => true, 'default' => '0'],
                    'Store ID'
                )->addColumn(
                    'post_id',
                    Table::TYPE_INTEGER,
                    null,
                    ['unsigned' => true, 'nullable' => false, 'primary' => true, 'default' => '0'],
                    'Post ID'
                )->addIndex(
                    $installer->getIdxName('mst_blog_store_post', ['post_id']),
                    ['post_id']
                )->addForeignKey(
                    $installer->getFkName(
                        'mst_blog_store_post',
                        'store_id',
                        'store',
                        'store_id'
                    ),
                    'store_id',
                    $installer->getTable('store'),
                    'store_id',
                    Table::ACTION_CASCADE
                )->addForeignKey(
                    $installer->getFkName(
                        'mst_blog_store_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 Store Linkage Table');
            $installer->getConnection()->createTable($table);
        }
        if (version_compare($context->getVersion(), '1.0.4') < 0) {
            include_once 'Upgrade_1_0_4.php';

            Upgrade_1_0_4::upgrade($installer, $context);
        }
    }
249596
public function initializeContext(Context $context)
    {
        if (!$context instanceof FixtureServiceAwareContextInterface && !$this->usesReferenceDictionary($context)) {
            return;
        }

        $context->setFixtureService($this->fixtureService);
    }
276285
private function initLayoutUpdates(ContextInterface $context)
    {
        $loadedLayoutUpdates = $this->loadLayoutUpdates($context);
        foreach ($loadedLayoutUpdates as $id => $layoutUpdates) {
            if (!is_string($id)) {
                throw new Exception\UnexpectedTypeException(
                    $id,
                    'string',
                    'layout item id'
                );
            }
            if (!is_array($layoutUpdates)) {
                throw new Exception\UnexpectedTypeException(
                    $layoutUpdates,
                    'array',
                    sprintf('layout updates for item "%s"', $id)
                );
            }
            foreach ($layoutUpdates as $layoutUpdate) {
                if (!$layoutUpdate instanceof LayoutUpdateInterface) {
                    throw new Exception\UnexpectedTypeException(
                        $layoutUpdate,
                        'Oro\Component\Layout\LayoutUpdateInterface'
                    );
                }
            }
        }
        $this->layoutUpdates = $loadedLayoutUpdates;
    }
858263
public function addBlacklistColumnToPositionTable(SchemaSetupInterface $setup)
    {
        $setup->getConnection()->addColumn(
            $setup->getTable('smile_virtualcategory_catalog_category_product_position'),
            'is_blacklisted',
            [
                'type'     => \Magento\Framework\DB\Ddl\Table::TYPE_BOOLEAN,
                'nullable' => false,
                'default'  => 0,
                'comment'  => 'If the product is blacklisted',
            ]
        );
    }
686333
public function setSchema($schema)
    {
        if ($schema === $this->schema) {
            return;
        }

        $this->schema = $schema;
        if ($schema && !$this->package && $this->getBuildProperty('schemaAutoPackage')) {
            $this->package = $schema;
            $this->packageOverridden = true;
        }

        if ($schema && !$this->namespace && $this->getBuildProperty('generator.schema.autoNamespace')) {
            $this->namespace = $schema;
        }
    }
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();
    }
1200124
private SFPair<String, String> applySessionContext(String catalog,
                                                     String schemaPattern)
  {
    if (catalog == null && metadataRequestUseConnectionCtx)
    {
      catalog = session.getDatabase();

      if (schemaPattern == null)
      {
        schemaPattern = session.getSchema();
      }
    }
    return SFPair.of(catalog, schemaPattern);
  }
492008
public function initializeContext(Context $context)
    {
        if (!$context instanceof CollectionAwareContextInterface) {
            return;
        }
        $context->setTerminalCollection($this->collection);
        $context->setTerminalDefaultAlias($this->defaultAlias);
    }
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
        );
    }
465854
protected function setUpDoctrineSchema()
    {
        if ($this->schemaSetUp) {
            // @codeCoverageIgnoreStart
            return;
            // @codeCoverageIgnoreEnd
        }

        DB::connection($this->connection)
            ->getDoctrineSchemaManager()
            ->getDatabasePlatform()
            ->registerDoctrineTypeMapping('enum', 'string');

        $this->schemaSetUp = true;
    }
1318356
public function assemble(ContextInterface $context)
    {
        $class = $context->getClass();
        $properties = $context->getType()->getProperties();
        $firstProperty = count($properties) ? current($properties) : null;

        try {
            $interfaceAssembler = new InterfaceAssembler(ResultProviderInterface::class);
            if ($interfaceAssembler->canAssemble($context)) {
                $interfaceAssembler->assemble($context);
            }

            if ($firstProperty) {
                $this->implementGetResult($context, $class, $firstProperty);
            }
        } catch (\Exception $e) {
            throw AssemblerException::fromException($e);
        }
    }
342740
protected function install(AbstractInstall $installScript, OutputInterface $output)
    {
        $dataPath = DATADIR;

        $output->writeln('  Installing App...');

        // Install the database structure
        $this->runSql(
            $dataPath.DIRECTORY_SEPARATOR.GenerateInstallCommand::STRUCTURE_FILE,
            '  Creating initial database schema',
            sprintf('  Database schema file %s not found', GenerateInstallCommand::STRUCTURE_FILE),
            $output
        );

        // Install the database data
        $this->runSql(
            $dataPath.DIRECTORY_SEPARATOR.GenerateInstallCommand::DATA_FILE,
            '  Inserting initial data',
            sprintf('  Database data file %s not found', GenerateInstallCommand::DATA_FILE),
            $output
        );

        $output->writeln('  Running install script');

        $installScript->execute($this->db);

        $output->write(['  Install completed!', ''], true);
    }