Skip to content

[FEATURE] Allow other adapters for Phinx configuration#29

Open
bmoex wants to merge 2 commits intopagemachine:masterfrom
bmoex:feature/supported-adapters
Open

[FEATURE] Allow other adapters for Phinx configuration#29
bmoex wants to merge 2 commits intopagemachine:masterfrom
bmoex:feature/supported-adapters

Conversation

@bmoex
Copy link
Copy Markdown

@bmoex bmoex commented Jul 11, 2022

See: https://book.cakephp.org/phinx/0/en/configuration.html#supported-adapters

My instance crashes as i use sqlite. This PR checks per connection configured configuration and returns the environment array for phinx.

Copy link
Copy Markdown
Member

@mbrodala mbrodala left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the late response, please have a look at my remarks.

private function getEnvironment(Connection $connection): array
{
return $GLOBALS['TYPO3_CONF_VARS']['DB']['Connections']['Default'];
switch ($connection->getDatabasePlatform()->getName()) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like we could put this directly in $adapter instead.

Also what's the reason from using a connection instead of the raw TYPO3 config?

Comment on lines +44 to +46
$pathInfo = pathinfo($connection->getDatabase());
$name = $pathInfo['dirname'] . '/' . $pathInfo['filename'];
$suffix = '.' . $pathInfo['extension'];
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There seems to be a lot of magic / hidden knowledge going on here. Is there no Doctrine DBAL API for this?


return [
'adapter' => $adapter,
'host' => $connection->getParams()['host'] ?? null,
Copy link
Copy Markdown
Member

@mbrodala mbrodala Mar 22, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd at least call getParams() only once. Also it seems like we can basically return that $params then.

Finally getParams() is marked as @internal so we should not rely on it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants