Passed
Push — master ( 7c0a29...64a75f )
by Pauli
02:52
created

fixInconsistentIdTypes()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 5
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 6
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace OCA\Music\Migration;
6
7
use Closure;
8
use OCP\DB\ISchemaWrapper;
9
use OCP\Migration\SimpleMigrationStep;
10
use OCP\Migration\IOutput;
11
12
/**
13
 * Migrate the DB schema to Music v1.9.0 level from the v1.4.0 level
14
 */
15
class Version010900Date20230720133000 extends SimpleMigrationStep {
16
17
	/**
18
	 * @param IOutput $output
19
	 * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
20
	 * @param array $options
21
	 */
22
	public function preSchemaChange(IOutput $output, Closure $schemaClosure, array $options) {
23
	}
24
25
	/**
26
	 * @param IOutput $output
27
	 * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
28
	 * @param array $options
29
	 * @return null|ISchemaWrapper
30
	 */
31
	public function changeSchema(IOutput $output, Closure $schemaClosure, array $options) {
32
		/** @var ISchemaWrapper $schema */
33
		$schema = $schemaClosure();
34
		$this->fixInconsistentIdTypes($schema);
35
		return $schema;
36
	}
37
38
	/**
39
	 * @param IOutput $output
40
	 * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
41
	 * @param array $options
42
	 */
43
	public function postSchemaChange(IOutput $output, Closure $schemaClosure, array $options) {
44
	}
45
46
	/**
47
	 * Some of the foreign keys referring to entity IDs have been previously defined as signed
48
	 * although the referred primary key has always been unsigned.
49
	 */
50
	private function fixInconsistentIdTypes(ISchemaWrapper $schema) {
51
		$schema->getTable('music_albums')->changeColumn('album_artist_id', ['unsigned' => true]);
0 ignored issues
show
Deprecated Code introduced by
The function Doctrine\DBAL\Schema\Table::changeColumn() has been deprecated: Use {@link modifyColumn()} instead. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

51
		/** @scrutinizer ignore-deprecated */ $schema->getTable('music_albums')->changeColumn('album_artist_id', ['unsigned' => true]);

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
52
		$schema->getTable('music_tracks')->changeColumn('artist_id', ['unsigned' => true])
0 ignored issues
show
Deprecated Code introduced by
The function Doctrine\DBAL\Schema\Table::changeColumn() has been deprecated: Use {@link modifyColumn()} instead. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

52
		/** @scrutinizer ignore-deprecated */ $schema->getTable('music_tracks')->changeColumn('artist_id', ['unsigned' => true])

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
53
										->changeColumn('album_id', ['unsigned' => true]);
54
		$schema->getTable('music_bookmarks')->changeColumn('entry_id', ['unsigned' => true]);
0 ignored issues
show
Deprecated Code introduced by
The function Doctrine\DBAL\Schema\Table::changeColumn() has been deprecated: Use {@link modifyColumn()} instead. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

54
		/** @scrutinizer ignore-deprecated */ $schema->getTable('music_bookmarks')->changeColumn('entry_id', ['unsigned' => true]);

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
55
		$schema->getTable('music_ampache_users')->changeColumn('id', ['unsigned' => true]);
0 ignored issues
show
Deprecated Code introduced by
The function Doctrine\DBAL\Schema\Table::changeColumn() has been deprecated: Use {@link modifyColumn()} instead. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

55
		/** @scrutinizer ignore-deprecated */ $schema->getTable('music_ampache_users')->changeColumn('id', ['unsigned' => true]);

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
56
	}
57
58
}
59