function PdoSessionHandler::configureSchema
Adds the Table to the Schema if it doesn't exist.
File
-
vendor/
symfony/ http-foundation/ Session/ Storage/ Handler/ PdoSessionHandler.php, line 184
Class
- PdoSessionHandler
- Session handler using a PDO connection to read and write data.
Namespace
Symfony\Component\HttpFoundation\Session\Storage\HandlerCode
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);
break;
case 'pgsql':
$table->addColumn($this->idCol, Types::STRING)
->setLength(128)
->setNotnull(true);
$table->addColumn($this->dataCol, Types::BINARY)
->setNotnull(true);
$table->addColumn($this->lifetimeCol, Types::INTEGER)
->setNotnull(true);
$table->addColumn($this->timeCol, Types::INTEGER)
->setNotnull(true);
break;
case 'oci':
$table->addColumn($this->idCol, Types::STRING)
->setLength(128)
->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);
break;
case 'sqlsrv':
$table->addColumn($this->idCol, Types::TEXT)
->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);
break;
default:
throw new \DomainException(\sprintf('Creating the session table is currently not implemented for PDO driver "%s".', $this->driver));
}
$table->setPrimaryKey([
$this->idCol,
]);
$table->addIndex([
$this->lifetimeCol,
], $this->lifetimeCol . '_idx');
}