Code Duplication    Length = 12-12 lines in 2 locations

apps/files_sharing/appinfo/Migrations/Version20170830112305.php 1 location

@@ 28-39 (lines=12) @@
25
use OCP\Migration\ISchemaMigration;
26
27
/** add index to costly query */
28
class Version20170830112305 implements ISchemaMigration {
29
	public function changeSchema(Schema $schema, array $options) {
30
		$prefix = $options['tablePrefix'];
31
32
		if ($schema->hasTable("${prefix}share")) {
33
			$table = $schema->getTable("${prefix}share");
34
			if (!$table->hasIndex('share_with_index')) {
35
				$table->addIndex(['share_with'], 'share_with_index');
36
			}
37
		}
38
	}
39
}
40

apps/files_sharing/appinfo/Migrations/Version20171115154900.php 1 location

@@ 28-39 (lines=12) @@
25
use OCP\Migration\ISchemaMigration;
26
27
/** add another index for listing shares */
28
class Version20171115154900 implements ISchemaMigration {
29
	public function changeSchema(Schema $schema, array $options) {
30
		$prefix = $options['tablePrefix'];
31
32
		if ($schema->hasTable("${prefix}share")) {
33
			$table = $schema->getTable("${prefix}share");
34
			if (!$table->hasIndex('item_source_index')) {
35
				$table->addIndex(['item_source'], 'item_source_index');
36
			}
37
		}
38
	}
39
}
40