-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
108 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
doctrine: | ||
dbal: | ||
url: '%env(stripschema:DATABASE_URL)%' | ||
server_version: 'mariadb-0.0.0' | ||
driver_class: App\Doctrine\Driver |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the mangel.io project. | ||
* | ||
* (c) Florian Moser <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace App\Doctrine; | ||
|
||
use Doctrine\DBAL\Driver\PDOMySql; | ||
|
||
class Driver extends PDOMySql\Driver | ||
{ | ||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function getDatabasePlatform() | ||
{ | ||
return new Platform(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the mangel.io project. | ||
* | ||
* (c) Florian Moser <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace App\Doctrine; | ||
|
||
use Doctrine\DBAL\Platforms\Keywords\MariaDb102Keywords; | ||
use Doctrine\DBAL\Platforms\MySqlPlatform; | ||
use Doctrine\DBAL\Types\Types; | ||
|
||
class Platform extends MySqlPlatform | ||
{ | ||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function getTruncateTableSQL($tableName, $cascade = false) | ||
{ | ||
$truncateSql = parent::getTruncateTableSQL($tableName, $cascade); | ||
|
||
return 'SET foreign_key_checks = 0;'.$truncateSql.';SET foreign_key_checks = 1;'; | ||
} | ||
|
||
// methods copied out of MariaDb1027Platform | ||
public function getJsonTypeDeclarationSQL(array $column): string | ||
{ | ||
return 'LONGTEXT'; | ||
} | ||
|
||
protected function getReservedKeywordsClass(): string | ||
{ | ||
return MariaDb102Keywords::class; | ||
} | ||
|
||
protected function initializeDoctrineTypeMappings(): void | ||
{ | ||
parent::initializeDoctrineTypeMappings(); | ||
|
||
$this->doctrineTypeMapping['json'] = Types::JSON; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the mangel.io project. | ||
* | ||
* (c) Florian Moser <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace App\Doctrine; | ||
|
||
use Symfony\Component\DependencyInjection\EnvVarProcessorInterface; | ||
|
||
class TrimSchemaEnvVarProcessor implements EnvVarProcessorInterface | ||
{ | ||
public function getEnv(string $prefix, string $name, \Closure $getEnv) | ||
{ | ||
$env = $getEnv($name); | ||
|
||
return substr($env, strpos($env, '://') + 3); | ||
} | ||
|
||
public static function getProvidedTypes() | ||
{ | ||
return [ | ||
'stripschema' => 'string', | ||
]; | ||
} | ||
} |