-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Create an easy way to extend the schema manager #5812
Comments
Is it easy enough? DriverManager::getConnection(
[
'driver' => ...
'wrapperClass' => SchemaOverriddenConnection::class,
]
);
class SchemaOverriddenConnection extends Connection
{
public function createSchemaManager(): AbstractSchemaManager
{
return new OverriddenSchemaManager($this, $this->getDatabasePlatform());
}
} |
Good one, but maybe we can manage to do that without providing our own wrapper class. It's possible for the driver and the platform, why shouldn't it be for the schema manager? |
|
So, what you're saying is, extending the wrapper class is the way to go? In that case, this would be a pure documentation issue. |
Another way is using |
class \Doctrine\DBAL\Configuration
{
// ....
private ?AbstractSchemaManager $schemaManager = null;
public function getSchemaManager(): ?AbstractSchemaManager
{
return $this->schemaManager;
}
public function setSchemaManager(AbstractSchemaManager $schemaManager): void
{
$this->schemaManager = $schemaManager;
}
// ....
}
class \Doctrine\DBAL\Connection
{
// ...
public function createSchemaManager(): AbstractSchemaManager
{
return $this->_config->getSchemaManager() ??
$this->_driver->getSchemaManager($this, $this->getDatabasePlatform());
}
// ...
} |
It looks like a more correct way to override schema manager is using |
Would an implementation of a custom Schema manager like as in the suggested example (of an overridden schema manager as OverriddenSchemaManager) be able to let a developer place a table prefix as it can be done with current dbal deprecated event system? |
I've worked on an implementation in #5876. |
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Feature Request
Summary
In #5784, the event system of the DBAL has been deprecated. One of the current use-cases is to modify the SQL emitted by the schema manager after a schema comparison. Instead, developers should extend the schema manager directly now. However, it is not really easy to do that at the moment because it involves overriding the driver as well.
My idea would be to allow a developer to pass a callable to
DriverManager
that constructs a schema manager instance and thus overrides the schema manager created by the driver/platform.The text was updated successfully, but these errors were encountered: