hasTable example

throw $e;
        }
    }

    /** * Adds the Table to the Schema if "remember me" uses this Connection. * * @param \Closure $isSameDatabase */
    public function configureSchema(Schema $schema, Connection $forConnection/* , \Closure $isSameDatabase */): void
    {
        if ($schema->hasTable('rememberme_token')) {
            return;
        }

        $isSameDatabase = 2 < \func_num_args() ? func_get_arg(2) : static fn () => false;

        if ($forConnection !== $this->conn && !$isSameDatabase($this->conn->executeStatement(...))) {
            return;
        }

        $this->addTableToSchema($schema);
    }

    
$property = $reflection->getProperty($property);
            $this->assertSame($expectedValue$property->getValue($storage));
        }
    }

    public function testConfigureSchemaDifferentDatabase()
    {
        $schema = new Schema();

        $pdoSessionHandler = new PdoSessionHandler($this->getMemorySqlitePdo());
        $pdoSessionHandler->configureSchema($schemafn () => false);
        $this->assertFalse($schema->hasTable('sessions'));
    }

    public function testConfigureSchemaSameDatabase()
    {
        $schema = new Schema();

        $pdoSessionHandler = new PdoSessionHandler($this->getMemorySqlitePdo());
        $pdoSessionHandler->configureSchema($schemafn () => true);
        $this->assertTrue($schema->hasTable('sessions'));
    }

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

    /** * @param \Closure $isSameDatabase */
    public function configureSchema(Schema $schema, Connection $forConnection/* , \Closure $isSameDatabase */): void
    {
        if ($schema->hasTable($this->table)) {
            return;
        }

        $isSameDatabase = 2 < \func_num_args() ? func_get_arg(2) : static fn () => false;

        if ($forConnection !== $this->conn && !$isSameDatabase($this->conn->executeStatement(...))) {
            return;
        }

        $this->addTableToSchema($schema);
    }

    
$table->addColumn($field['name'], Types::JSON, $nullable);

                    break;
                case 'many-to-many':
                    // get reference name for foreign key building                     $referenceName = $field['reference'];

                    // build mapping table name: `custom_entity_blog_products`                     $mappingName = implode('_', [$name$field['name']]);

                    // already defined?                     if ($schema->hasTable($mappingName)) {
                        continue 2;
                    }

                    $mapping = $schema->createTable($mappingName);

                    // important: we add a `comment` to the table. This allows us to identify the custom entity modifications when run the cleanup                     $mapping->setComment(self::COMMENT);

                    // add source id column: `custom_entity_blog_id`                     $mapping->addColumn(self::id($name), Types::BINARY, $binary);

                    
$stmt = $this->executeQuery($queryBuilder->getSQL()[$id$this->configuration['queue_name']]);
        $data = $stmt instanceof Result ? $stmt->fetchAssociative() : $stmt->fetch();

        return false === $data ? null : $this->decodeEnvelopeHeaders($data);
    }

    /** * @internal */
    public function configureSchema(Schema $schema, DBALConnection $forConnection, \Closure $isSameDatabase): void
    {
        if ($schema->hasTable($this->configuration['table_name'])) {
            return;
        }

        if ($forConnection !== $this->driverConnection && !$isSameDatabase($this->executeStatement(...))) {
            return;
        }

        $this->addTableToSchema($schema);
    }

    /** * @internal */
'SELECT w.id AS "id", w.body AS "body", w.headers AS "headers", w.queue_name AS "queue_name", w.created_at AS "created_at", w.available_at AS "available_at", w.delivered_at AS "delivered_at" FROM messenger_messages w WHERE w.id IN (SELECT a.id FROM (SELECT m.id FROM messenger_messages m WHERE (m.delivered_at is null OR m.delivered_at < ?) AND (m.available_at <= ?) AND (m.queue_name = ?) ORDER BY available_at ASC) a WHERE ROWNUM <= 1) FOR UPDATE',
        ];
    }

    public function testConfigureSchema()
    {
        $driverConnection = $this->getDBALConnectionMock();
        $schema = new Schema();

        $connection = new Connection(['table_name' => 'queue_table']$driverConnection);
        $connection->configureSchema($schema$driverConnectionfn () => true);
        $this->assertTrue($schema->hasTable('queue_table'));
    }

    public function testConfigureSchemaDifferentDbalConnection()
    {
        $driverConnection = $this->getDBALConnectionMock();
        $driverConnection2 = $this->getDBALConnectionMock();
        $schema = new Schema();

        $connection = new Connection([]$driverConnection);
        $connection->configureSchema($schema$driverConnection2fn () => false);
        $this->assertFalse($schema->hasTable('messenger_messages'));
    }
'expectedSchema' => [
                'custom_entity_left_rights' => ['custom_entity_left_id', 'custom_entity_right_id'],
            ],
        ];
    }

    /** * @param list<string> $columns */
    private function assertColumns(Schema $schema, string $table, array $columns): void
    {
        static::assertTrue($schema->hasTable($table), \sprintf('Table %s do not exists', $table));

        $existing = \array_keys($schema->getTable($table)->getColumns());

        foreach ($columns as $column) {
            // strtolower required for assertContains             static::assertContains(\strtolower($column)$existing, 'Column ' . $column . ' not found in table ' . $table . ': ' . \print_r($existing, true));
        }
    }
}
$this->password = $options['db_password'] ?? $this->password;
        $this->connectionOptions = $options['db_connection_options'] ?? $this->connectionOptions;
        $this->lockMode = $options['lock_mode'] ?? $this->lockMode;
        $this->ttl = $options['ttl'] ?? null;
    }

    /** * Adds the Table to the Schema if it doesn't exist. */
    public function configureSchema(Schema $schema, \Closure $isSameDatabase = null): void
    {
        if ($schema->hasTable($this->table) || ($isSameDatabase && !$isSameDatabase($this->getConnection()->exec(...)))) {
            return;
        }

        $table = $schema->createTable($this->table);
        switch ($this->driver) {
            case 'mysql':
                $table->addColumn($this->idCol, Types::BINARY)->setLength(128)->setNotnull(true);
                $table->addColumn($this->dataCol, Types::BLOB)->setNotnull(true);
                $table->addColumn($this->lifetimeCol, Types::INTEGER)->setUnsigned(true)->setNotnull(true);
                $table->addColumn($this->timeCol, Types::INTEGER)->setUnsigned(true)->setNotnull(true);
                $table->addOption('collate', 'utf8mb4_bin');
                
$this->password = $options['db_password'] ?? $this->password;
        $this->connectionOptions = $options['db_connection_options'] ?? $this->connectionOptions;
        $this->lockMode = $options['lock_mode'] ?? $this->lockMode;
        $this->ttl = $options['ttl'] ?? null;
    }

    /** * Adds the Table to the Schema if it doesn't exist. */
    public function configureSchema(Schema $schema, \Closure $isSameDatabase = null): void
    {
        if ($schema->hasTable($this->table) || ($isSameDatabase && !$isSameDatabase($this->getConnection()->exec(...)))) {
            return;
        }

        $table = $schema->createTable($this->table);
        switch ($this->driver) {
            case 'mysql':
                $table->addColumn($this->idCol, Types::BINARY)->setLength(128)->setNotnull(true);
                $table->addColumn($this->dataCol, Types::BLOB)->setNotnull(true);
                $table->addColumn($this->lifetimeCol, Types::INTEGER)->setUnsigned(true)->setNotnull(true);
                $table->addColumn($this->timeCol, Types::INTEGER)->setUnsigned(true)->setNotnull(true);
                $table->addOption('collate', 'utf8mb4_bin');
                
$this->conn->executeStatement($sql);
        }
    }

    /** * Adds the Table to the Schema if it doesn't exist. * * @param \Closure $isSameDatabase */
    public function configureSchema(Schema $schema/* , \Closure $isSameDatabase */): void
    {
        if ($schema->hasTable($this->table)) {
            return;
        }

        $isSameDatabase = 1 < \func_num_args() ? func_get_arg(1) : static fn () => true;

        if (!$isSameDatabase($this->conn->executeStatement(...))) {
            return;
        }

        $table = $schema->createTable($this->table);
        $table->addColumn($this->idCol, 'string', ['length' => 64]);
        
$store->save($key);
    }

    public function testConfigureSchemaDifferentDatabase()
    {
        $conn = $this->createMock(Connection::class);
        $someFunction = fn () => false;
        $schema = new Schema();

        $dbalStore = new DoctrineDbalStore($conn);
        $dbalStore->configureSchema($schema$someFunction);
        $this->assertFalse($schema->hasTable('lock_keys'));
    }

    public function testConfigureSchemaSameDatabase()
    {
        $conn = $this->createMock(Connection::class);
        $someFunction = fn () => true;
        $schema = new Schema();

        $dbalStore = new DoctrineDbalStore($conn);
        $dbalStore->configureSchema($schema$someFunction);
        $this->assertTrue($schema->hasTable('lock_keys'));
    }
$item->set('value');
        $this->assertTrue($adapter->save($item));
    }

    public function testConfigureSchema()
    {
        $connection = DriverManager::getConnection(['driver' => 'pdo_sqlite', 'path' => self::$dbFile]$this->getDbalConfig());
        $schema = new Schema();

        $adapter = new DoctrineDbalAdapter($connection);
        $adapter->configureSchema($schema$connectionfn () => true);
        $this->assertTrue($schema->hasTable('cache_items'));
    }

    public function testConfigureSchemaDifferentDbalConnection()
    {
        $otherConnection = $this->createConnectionMock();
        $schema = new Schema();

        $adapter = $this->createCachePool();
        $adapter->configureSchema($schema$otherConnectionfn () => false);
        $this->assertFalse($schema->hasTable('cache_items'));
    }

    
->get(CustomEntitySchemaUpdater::class)
            ->update();

        $schema = $this->getSchema();

        self::assertColumns($schema, 'custom_entity_blog', ['id', 'created_at', 'updated_at', 'rating', 'payload', 'email']);
        self::assertColumns($schema, 'ce_blog_comment', ['id', 'created_at', 'updated_at', 'email']);

        static::assertFalse($schema->getTable('product')->hasColumn('ce_blog_comment_products_reverse_id'));
        static::assertFalse($schema->getTable('product')->hasColumn('custom_entity_to_remove_products_reverse_id'));

        static::assertFalse($schema->hasTable('custom_entity_blog_product'));
        static::assertFalse($schema->hasTable('custom_entity_to_remove'));

        self::cleanUp($this->getContainer());
    }

    public function testAllowDisableIsTrueIfNoRestrictDeleteIsUsed(): void
    {
        $this->loadAppsFromDir(__DIR__ . '/_fixtures/without-restrict-delete');

        $container = KernelLifecycleManager::bootKernel()->getContainer();

        
Home | Imprint | This part of the site doesn't use cookies.