Create customer link table.

@param SchemaSetupInterface $setup Setup
773182
private function createCustomerLinkTable(SchemaSetupInterface $setup)
    {
        $logTable = $setup->getConnection()->newTable($setup->getTable('elasticsuite_tracker_log_customer_link'))
            ->addColumn(
                'customer_id',
                \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER,
                null,
                ['unsigned' => true, 'nullable' => false, 'primary' => true],
                'Customer ID'
            )
            ->addColumn(
                'session_id',
                \Magento\Framework\DB\Ddl\Table::TYPE_TEXT,
                255,
                ['unsigned' => true, 'nullable' => false, 'primary' => true],
                'Session ID'
            )
            ->addColumn(
                'visitor_id',
                \Magento\Framework\DB\Ddl\Table::TYPE_TEXT,
                255,
                ['unsigned' => true, 'nullable' => false, 'primary' => true],
                'Visitor ID'
            )
            ->addColumn(
                'delete_after',
                \Magento\Framework\DB\Ddl\Table::TYPE_DATETIME,
                null,
                ['nullable' => true, 'default' => null],
                'Delete after'
            )->addForeignKey(
                $setup->getFkName('elasticsuite_tracker_log_customer_link', 'customer_id', 'customer_entity', 'entity_id'),
                'customer_id',
                $setup->getTable('customer_entity'),
                'entity_id',
                \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
            )->setComment('Smile ElasticSuite Tracker customer link Table');

        $setup->getConnection()->createTable($logTable);
    }
356478
public function setup_table() {
        $readers = $this->get_readers();

        $filter = new \stdClass();
        if (!empty($this->course)) {
            $filter->courseid = $this->course->id;
        } else {
            $filter->courseid = 0;
        }

        $filter->userid = $this->userid;
        $filter->modid = $this->modid;
        $filter->groupid = $this->get_selected_group();
        $filter->logreader = $readers[$this->selectedlogreader];
        $filter->edulevel = $this->edulevel;
        $filter->action = $this->action;
        $filter->date = $this->date;
        $filter->orderby = $this->order;
        $filter->origin = $this->origin;
        // If showing site_errors.
        if ('site_errors' === $this->modid) {
            $filter->siteerrors = true;
            $filter->modid = 0;
        }

        $this->tablelog = new report_log_table_log('report_log', $filter);
        $this->tablelog->define_baseurl($this->url);
        $this->tablelog->is_downloadable(true);
        $this->tablelog->show_download_buttons_at(array(TABLE_P_BOTTOM));
    }
695777
public function createTable(): void
    {
        // connect if we are not yet
        $conn = $this->getConnection();
        $driver = $this->getDriver();

        if ($conn instanceof Connection) {
            $schema = new Schema();
            $table = $schema->createTable($this->table);
            $table->addColumn($this->idCol, 'string', ['length' => 64]);
            $table->addColumn($this->tokenCol, 'string', ['length' => 44]);
            $table->addColumn($this->expirationCol, 'integer', ['unsigned' => true]);
            $table->setPrimaryKey([$this->idCol]);

            foreach ($schema->toSql($conn->getDatabasePlatform()) as $sql) {
                $conn->exec($sql);
            }

            return;
        }

        switch ($driver) {
            case 'mysql':
                $sql = "CREATE TABLE $this->table ($this->idCol VARCHAR(64) NOT NULL PRIMARY KEY, $this->tokenCol VARCHAR(44) NOT NULL, $this->expirationCol INTEGER UNSIGNED NOT NULL) COLLATE utf8_bin, ENGINE = InnoDB";
                break;
            case 'sqlite':
                $sql = "CREATE TABLE $this->table ($this->idCol TEXT NOT NULL PRIMARY KEY, $this->tokenCol TEXT NOT NULL, $this->expirationCol INTEGER)";
                break;
            case 'pgsql':
                $sql = "CREATE TABLE $this->table ($this->idCol VARCHAR(64) NOT NULL PRIMARY KEY, $this->tokenCol VARCHAR(64) NOT NULL, $this->expirationCol INTEGER)";
                break;
            case 'oci':
                $sql = "CREATE TABLE $this->table ($this->idCol VARCHAR2(64) NOT NULL PRIMARY KEY, $this->tokenCol VARCHAR2(64) NOT NULL, $this->expirationCol INTEGER)";
                break;
            case 'sqlsrv':
                $sql = "CREATE TABLE $this->table ($this->idCol VARCHAR(64) NOT NULL PRIMARY KEY, $this->tokenCol VARCHAR(64) NOT NULL, $this->expirationCol INTEGER)";
                break;
            default:
                throw new \DomainException(sprintf('Creating the lock table is currently not implemented for PDO driver "%s".', $driver));
        }

        $conn->exec($sql);
    }
1225919
protected function registerSetupCommand($binding)
    {
        $this->app->singleton($binding, function ($app) {
            return new Setup($app['config'], $app['db']);
        });
    }
721695
public function addEavCatalogFields(SchemaSetupInterface $setup)
    {
        $connection = $setup->getConnection();
        $table      = $setup->getTable('catalog_eav_attribute');

        // Append a column 'is_displayed_in_autocomplete' into the db.
        $connection->addColumn(
            $table,
            'is_displayed_in_autocomplete',
            [
                'type'     => \Magento\Framework\DB\Ddl\Table::TYPE_BOOLEAN,
                'nullable' => false,
                'default'  => '0',
                'comment'  => 'If attribute is displayed in autocomplete',
            ]
        );

        // Append a column 'is_used_in_spellcheck' to the table.
        $connection->addColumn(
            $table,
            'is_used_in_spellcheck',
            [
                'type'     => \Magento\Framework\DB\Ddl\Table::TYPE_BOOLEAN,
                'nullable' => false,
                'default'  => '1',
                'comment'  => 'If fuzziness is used on attribute',
            ]
        );

        // Append facet_min_coverage_rate to the table.
        $connection->addColumn(
            $table,
            'facet_min_coverage_rate',
            [
                'type'     => \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER,
                'unsigned' => true,
                'nullable' => false,
                'default'  => 90,
                'comment'  => 'Facet min coverage rate',
            ]
        );

        // Append facet_max_size to the table.
        $connection->addColumn(
            $table,
            'facet_max_size',
            [
                'type'     => \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER,
                'unsigned' => true,
                'nullable' => false,
                'default'  => '10',
                'comment'  => 'Facet max size',
            ]
        );

        // Append facet_sort_order to the table.
        $connection->addColumn(
            $table,
            'facet_sort_order',
            [
                'type'     => \Magento\Framework\DB\Ddl\Table::TYPE_TEXT,
                'nullable' => false,
                'default'  => \Smile\ElasticsuiteCore\Search\Request\BucketInterface::SORT_ORDER_COUNT,
                'length'   => 25,
                'comment'  => 'The sort order for facet values',
            ]
        );
    }
131674
private function setupConnection()
    {
        $requiredMode = $this->options->quoteIdentifier;
        if ( $requiredMode == ezcDbMssqlOptions::QUOTES_GUESS )
        {
            $result = parent::query( "SELECT sessionproperty('QUOTED_IDENTIFIER')" );
            $rows = $result->fetchAll();
            $mode = (int)$rows[0][0];
            if ( $mode == 0 )
            {
                $this->identifierQuoteChars = array( 'start' => '[', 'end' => ']' );
            }
            else
            {
                $this->identifierQuoteChars = array( 'start' => '"', 'end' => '"' );
            }
        }
        else if ( $requiredMode == ezcDbMssqlOptions::QUOTES_COMPLIANT )
        {
            parent::exec( 'SET QUOTED_IDENTIFIER ON' );
            $this->identifierQuoteChars = array( 'start' => '"', 'end' => '"' );
        }
        else if ( $requiredMode == ezcDbMssqlOptions::QUOTES_LEGACY )
        {
            parent::exec( 'SET QUOTED_IDENTIFIER OFF' );
            $this->identifierQuoteChars = array( 'start' => '[', 'end' => ']' );
        }
    }
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();
    }
527230
public function updateOptimizerSearchContainerTable(SchemaSetupInterface $setup)
    {
        $setup->getConnection()
            ->addColumn(
                $setup->getTable(OptimizerInterface::TABLE_NAME_SEARCH_CONTAINER),
                'apply_to',
                [
                    'type'     => \Magento\Framework\DB\Ddl\Table::TYPE_BOOLEAN,
                    'nullable' => false,
                    'default'  => '0',
                    'comment'  => 'If this optimizer applies to specific entities or not.',
                ]
            );
    }
476782
public function upgrade(SchemaSetupInterface $setup, ModuleContextInterface $context)
    {
        $setup->startSetup();

        if (version_compare($context->getVersion(), '0.0.2', '<')) {
            $this->thesaurusSetup->createThesaurusTable($setup);
            $this->thesaurusSetup->createThesaurusStoreTable($setup);
            $this->thesaurusSetup->createExpandedTermsTable($setup);
            $this->thesaurusSetup->createExpansionReferenceTable($setup);
        }

        if (version_compare($context->getVersion(), '1.0.0', '<')) {
            $this->thesaurusSetup->appendIsActiveColumn($setup);
        }

        $setup->endSetup();
    }
763403
protected function createTable($schema)
    {
        /** @var \DreamFactory\Core\Contracts\ServiceResponseInterface $rs */
        $rs = ServiceManager::handleRequest(
            $this->service->getName(),
            Verbs::POST,
            '_schema',
            [],
            [],
            ResourcesWrapper::wrapResources($schema)
        );

        if (in_array($rs->getStatusCode(), [HttpStatusCodes::HTTP_OK, HttpStatusCodes::HTTP_CREATED])) {
            return true;
        }

        $content = $rs->getContent();
        Log::error(
            'Failed to create table for importing CSV data: ' .
            (is_array($content) ? print_r($content, true) : $content)
        );
        throw new InternalServerErrorException('Failed to create table for importing CSV data. See log for details.');
    }
916577
public function setUp($serial)
    {

        // load the available category path => row ID mappings
        foreach ($this->getCategoryBunchProcessor()->getCategoriesWithResolvedPath() as $resolvedPath => $category) {
            $this->pathRowIdMapping[$resolvedPath] = $category[MemberNames::ROW_ID];
        }

        // prepare the callbacks
        parent::setUp($serial);
    }
606080
private function addIndexKeyForOrder(
        SchemaSetupInterface $setup,
        \Magento\Framework\DB\Adapter\AdapterInterface $connection
    ) {
        //Only add foreign key if table exist in default connection
        if ($connection->isTableExists($setup->getTable('sales_order'))) {
            $connection->addForeignKey(
                $setup->getFkName(
                    Schema::EMAIL_ORDER_TABLE,
                    'order_id',
                    'sales_order',
                    'entity_id'
                ),
                $setup->getTable(Schema::EMAIL_ORDER_TABLE),
                'order_id',
                $setup->getTable('sales_order'),
                'entity_id',
                \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
            );
        }
    }
1311635
final protected function process(FSetup $setup, IModuleContext $context) {
		$setup->startSetup();
		$this->_context = $context;
		$this->_setup = $setup;
		$this->_process();
		$setup->endSetup();
	}
1284857
public function install(SchemaSetupInterface $setup, ModuleContextInterface $context)
    {
        $installer = $setup;

        $installer->startSetup();

        $table = $installer->getConnection()
            ->newTable($installer->getTable('shopgate_order'))
            ->addColumn(
                'shopgate_order_id',
                Table::TYPE_INTEGER,
                null,
                ['identity' => true, 'nullable' => false, 'primary' => true],
                'Entity ID'
            )->addColumn(
                'order_id',
                 Table::TYPE_INTEGER,
                 null,
                 ['unsigned' => true, 'nullable' => false, 'default' => '0'],
                 'Order Id'
            )->addColumn(
                'store_id',
                 Table::TYPE_SMALLINT,
                 null,
                 ['unsigned' => true],
                 'Store Id'
            )->addColumn(
                'shopgate_order_number',
                Table::TYPE_TEXT,
                20,
                ['nullable' => false]
            )->addColumn(
                'is_shipping_blocked',
                Table::TYPE_INTEGER,
                1,
                ['nullable' => false]
            )->addColumn(
                'is_paid',
                Table::TYPE_INTEGER,
                1,
                ['nullable' => false]
            )->addColumn(
                'is_sent_to_shopgate',
                Table::TYPE_INTEGER,
                1,
                ['nullable' => false]
            )->addColumn(
                'is_cancellation_sent_to_shopgate',
                Table::TYPE_INTEGER,
                1,
                ['nullable' => false]
            )->addColumn(
                'is_test',
                Table::TYPE_INTEGER,
                1,
                ['nullable' => false]
            )->addColumn(
                'is_customer_invoice_blocked',
                Table::TYPE_INTEGER,
                1,
                ['nullable' => false]
            )->addColumn(
                'reported_shipping_collections',
                Table::TYPE_TEXT
            )->addColumn(
                'received_data',
                Table::TYPE_TEXT
            )->addIndex(
                $installer->getIdxName('shopgate_order', ['order_id']),
                    ['order_id']
            )->addIndex(
                $installer->getIdxName('shopgate_order', ['store_id']),
                    ['store_id']
            )->addForeignKey(
                $installer->getFkName('shopgate_order', 'order_id', 'sales_order', 'entity_id'),
                'order_id',
                $installer->getTable('sales_order'),
                'entity_id',
                Table::ACTION_CASCADE
            )->addForeignKey(
                $installer->getFkName('shopgate_order', 'store_id', 'store', 'store_id'),
                'store_id',
                $installer->getTable('store'),
                'store_id',
                Table::ACTION_SET_NULL
            )->setComment('Shopgate Orders');

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

        $table = $installer->getConnection()
            ->newTable($installer->getTable('shopgate_customer'))
            ->addColumn(
                'id',
                Table::TYPE_INTEGER,
                null,
                ['identity' => true, 'nullable' => false, 'primary' => true]
            )->addColumn(
                'customer_id',
                Table::TYPE_INTEGER,
                null,
                ['unsigned' => true],
                'Customer ID'
            )->addColumn(
                'token',
                Table::TYPE_TEXT,
                255,
                ['nullable' => false]
            )->addIndex(
                $installer->getIdxName('shopgate_customer', ['customer_id']),
                ['customer_id']
            )->addForeignKey(
                $installer->getFkName('shopgate_customer', 'customer_id', 'customer_entity', 'entity_id'),
                'customer_id',
                $installer->getTable('customer_entity'),
                'entity_id',
                Table::ACTION_CASCADE
            )->setComment('Shopgate Customer');

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

        $installer->endSetup();
    }
139973
private function createCampaignTable($installer)
    {
        $tableName = $installer->getTable(Schema::EMAIL_CAMPAIGN_TABLE);
        $this->dropTableIfExists($installer, $tableName);

        $campaignTable = $installer->getConnection()->newTable($tableName);
        $campaignTable = $this->addColumnsToCampaignTable($campaignTable);
        $campaignTable = $this->addIndexesToCampaignTable($installer, $campaignTable);
        $campaignTable->addForeignKey(
            $installer->getFkName(
                $installer->getTable(Schema::EMAIL_CAMPAIGN_TABLE),
                'store_id',
                'core/store',
                'store_id'
            ),
            'store_id',
            $installer->getTable('store'),
            'store_id',
            \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
            \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
        );

        $campaignTable->setComment('Connector Campaigns');
        $installer->getConnection()->createTable($campaignTable);
    }
607873
private function attachAgent(): void
    {
        $this->agentName = strtolower((string) $this->config['agent']);
        switch ($this->agentName) {
            case self::AGENT_MYSQL:
                $this->agent = new Mysql($this->config);
                break;
            case self::AGENT_PGSQL:
                $this->agent = new Pgsql($this->config);
                break;
            default:
                throw new LinkException("Sorry, but '{$this->agentName}' agent not implemented!");
        }
    }
732388
public function uninstall(SchemaSetupInterface $setup, ModuleContextInterface $context)
    {
        $defaultConnection = $setup->getConnection();

        $this->dropTable($setup, Schema::EMAIL_CONTACT_CONSENT_TABLE);
        $this->dropTable($setup, Schema::EMAIL_CONTACT_TABLE);
        $this->dropTable($setup, Schema::EMAIL_ORDER_TABLE);
        $this->dropTable($setup, Schema::EMAIL_CAMPAIGN_TABLE);
        $this->dropTable($setup, Schema::EMAIL_REVIEW_TABLE);
        $this->dropTable($setup, Schema::EMAIL_WISHLIST_TABLE);
        $this->dropTable($setup, Schema::EMAIL_CATALOG_TABLE);
        $this->dropTable($setup, Schema::EMAIL_RULES_TABLE);
        $this->dropTable($setup, Schema::EMAIL_IMPORTER_TABLE);
        $this->dropTable($setup, Schema::EMAIL_AUTOMATION_TABLE);
        $this->dropTable($setup, Schema::EMAIL_ABANDONED_CART_TABLE);
        $this->dropTable($setup, Schema::EMAIL_FAILED_AUTH_TABLE);

        $defaultConnection->dropColumn(
            $this->getTableNameWithPrefix($setup, 'admin_user'),
            'refresh_token'
        );

        $defaultConnection->delete(
            $this->getTableNameWithPrefix($setup, 'core_config_data'),
            "path LIKE 'connector_api_credentials/%'"
        );
    }