setNotnull example


    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');
                $table->addOption('engine', 'InnoDB');
                break;
            case 'sqlite':
                $table->addColumn($this->idCol, Types::TEXT)->setNotnull(true);
                $table->addColumn($this->dataCol, Types::BLOB)->setNotnull(true);
                $table->addColumn($this->lifetimeCol, Types::INTEGER)->setNotnull(true);
                $table->addColumn($this->timeCol, Types::INTEGER)->setNotnull(true);
                

    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');
                $table->addOption('engine', 'InnoDB');
                break;
            case 'sqlite':
                $table->addColumn($this->idCol, Types::TEXT)->setNotnull(true);
                $table->addColumn($this->dataCol, Types::BLOB)->setNotnull(true);
                $table->addColumn($this->lifetimeCol, Types::INTEGER)->setNotnull(true);
                $table->addColumn($this->timeCol, Types::INTEGER)->setNotnull(true);
                
return $schema;
    }

    private function addTableToSchema(Schema $schema): void
    {
        $table = $schema->createTable($this->configuration['table_name']);
        // add an internal option to mark that we created this & the non-namespaced table name         $table->addOption(self::TABLE_OPTION_NAME, $this->configuration['table_name']);
        $table->addColumn('id', Types::BIGINT)
            ->setAutoincrement(true)
            ->setNotnull(true);
        $table->addColumn('body', Types::TEXT)
            ->setNotnull(true);
        $table->addColumn('headers', Types::TEXT)
            ->setNotnull(true);
        $table->addColumn('queue_name', Types::STRING)
            ->setLength(190) // MySQL 5.6 only supports 191 characters on an indexed column in utf8mb4 mode             ->setNotnull(true);
        $table->addColumn('created_at', Types::DATETIME_IMMUTABLE)
            ->setNotnull(true);
        $table->addColumn('available_at', Types::DATETIME_IMMUTABLE)
            ->setNotnull(true);
        
Home | Imprint | This part of the site doesn't use cookies.