MediaWiki master
DatabaseCreator.php
Go to the documentation of this file.
1<?php
2
3namespace MediaWiki\Installer;
4
9
15abstract class DatabaseCreator {
17 protected $context;
18
26 $type = $context->getConfigVar( MainConfigNames::DBtype );
27
28 switch ( $type ) {
29 case 'mysql':
30 return new MysqlDatabaseCreator( $context );
31 case 'postgres':
33 case 'sqlite':
34 return new SqliteDatabaseCreator( $context );
35 default:
36 throw new \InvalidArgumentException( "Unknown DBMS type \"$type\"" );
37 }
38 }
39
43 protected function __construct( ITaskContext $context ) {
44 $this->context = $context;
45 }
46
53 abstract public function existsLocally( $database );
54
63 abstract public function existsInLoadBalancer( ILoadBalancer $loadBalancer, $database );
64
71 abstract public function createLocally( $database ): Status;
72
81 abstract public function createInLoadBalancer( ILoadBalancer $loadBalancer, $database ): Status;
82}
Helper for creating databases.
static createInstance(ITaskContext $context)
createInLoadBalancer(ILoadBalancer $loadBalancer, $database)
Create a database in the specified LoadBalancer which may be for an external cluster.
existsInLoadBalancer(ILoadBalancer $loadBalancer, $database)
Check if a database exists in the specified LoadBalancer which may be for an external cluster.
existsLocally( $database)
Check if a database exists on the local cluster or context.
createLocally( $database)
Create a database in the local cluster or install context.
A class containing constants representing the names of configuration variables.
Generic operation result class Has warning/error list, boolean status and arbitrary value.
Definition Status.php:54
Dependency bundle and execution context for installer tasks.
This class is a delegate to ILBFactory for a given database cluster.