DumpSqlCommand::getQueries()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 0
1
<?php
2
3
namespace Wikibase\QueryEngine\Console;
4
5
use Doctrine\DBAL\Platforms\AbstractPlatform;
6
use Doctrine\DBAL\Schema\Schema;
7
use Symfony\Component\Console\Command\Command;
8
use Symfony\Component\Console\Input\InputInterface;
9
use Symfony\Component\Console\Output\OutputInterface;
10
use Wikibase\QueryEngine\SQLStore\StoreSchema;
11
12
/**
13
 * @licence GNU GPL v2+
14
 * @author Jeroen De Dauw < [email protected] >
15
 */
16
class DumpSqlCommand extends Command {
17
18
	/**
19
	 * @var StoreSchema
20
	 */
21
	private $storeSchema;
22
23
	/**
24
	 * @var AbstractPlatform
25
	 */
26
	private $platform;
27
28
	public function setDependencies( StoreSchema $storeSchema, AbstractPlatform $platform ) {
29
		$this->storeSchema = $storeSchema;
30
		$this->platform = $platform;
31
	}
32
33
	protected function configure() {
34
		$this->setName( 'dump-sql' );
35
		$this->setDescription( 'Dumps the SQL for creating the QueryEngine SQL store schema' );
36
	}
37
38
	protected function execute( InputInterface $input, OutputInterface $output ) {
39
		foreach ( $this->getQueries() as $query ) {
40
			$output->writeln( $query );
41
		}
42
	}
43
44
	private function getQueries() {
45
		$schema = new Schema( $this->storeSchema->getTables() );
46
		return $schema->toSql( $this->platform );
47
	}
48
49
}
50