This allows us to abstract away schemas into one json file. Bug: T230419 Change-Id: Ic8a658c97150e4c248bdbc9a5cf5d947b8c71036
32 lines
842 B
PHP
32 lines
842 B
PHP
<?php
|
|
namespace Wikimedia\Rdbms;
|
|
|
|
use Doctrine\DBAL\Platforms\MySqlPlatform;
|
|
use Doctrine\DBAL\Platforms\PostgreSqlPlatform;
|
|
use Doctrine\DBAL\Platforms\SqlitePlatform;
|
|
use InvalidArgumentException;
|
|
|
|
/**
|
|
* @experimental
|
|
* @unstable
|
|
*/
|
|
class DoctrineSchemaBuilderFactory {
|
|
|
|
/**
|
|
* @param string $platform one of strings 'mysql', 'postgres' or 'sqlite'
|
|
* @return DoctrineSchemaBuilder
|
|
*/
|
|
public function getSchemaBuilder( $platform ) {
|
|
if ( $platform === 'mysql' ) {
|
|
$platformObject = new MySqlPlatform();
|
|
} elseif ( $platform === 'postgres' ) {
|
|
$platformObject = new PostgreSqlPlatform();
|
|
} elseif ( $platform === 'sqlite' ) {
|
|
$platformObject = new SqlitePlatform();
|
|
} else {
|
|
throw new InvalidArgumentException( 'Unknown platform: ' . $platform );
|
|
}
|
|
|
|
return new DoctrineSchemaBuilder( $platformObject );
|
|
}
|
|
}
|