Passed
Push — index-migration ( cc3fb4 )
by
unknown
14:49
created

Version20240528083322::down()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 7
c 1
b 0
f 0
dl 0
loc 8
ccs 0
cts 8
cp 0
rs 10
cc 1
nc 1
nop 1
crap 2
1
<?php
2
3
declare( strict_types = 1 );
4
5
namespace WMDE\Fundraising\AddressChangeContext\DataAccess\Migrations;
6
7
use Doctrine\DBAL\Schema\Schema;
8
use Doctrine\Migrations\AbstractMigration;
9
10
final class Version20240528083322 extends AbstractMigration {
11
12
	public function getDescription(): string {
13
		return 'Add indexes for full text search on the Address table';
14
	}
15
16
	public function up( Schema $schema ): void {
17
		$table = $schema->getTable( 'address' );
18
		$table->addIndex( [ 'first_name' ], 'idx_first_name_address_change' );
19
		$table->addIndex( [ 'last_name' ], 'idx_last_name_address_change' );
20
		$table->addIndex( [ 'street' ], 'idx_street_address_change' );
21
		$table->addIndex( [ 'postcode' ], 'idx_postcode_address_change' );
22
		$table->addIndex( [ 'city' ], 'idx_city_address_change' );
23
		$table->addIndex( [ 'country' ], 'idx_country_address_change' );
24
	}
25
26
	public function down( Schema $schema ): void {
27
		$table = $schema->getTable( 'address' );
28
		$table->dropIndex( 'idx_first_name_address_change' );
29
		$table->dropIndex( 'idx_last_name_address_change' );
30
		$table->dropIndex( 'idx_street_address_change' );
31
		$table->dropIndex( 'idx_postcode_address_change' );
32
		$table->dropIndex( 'idx_city_address_change' );
33
		$table->dropIndex( 'idx_country_address_change' );
34
	}
35
}
36