-
Notifications
You must be signed in to change notification settings - Fork 31
Expand file tree
/
Copy pathVersion20210212160142.php
More file actions
46 lines (42 loc) · 1.17 KB
/
Version20210212160142.php
File metadata and controls
46 lines (42 loc) · 1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
<?php
/**
* Files_antivirus
*
* This file is licensed under the Affero General Public License version 3 or
* later. See the COPYING file.
*
* @author Viktar Dubiniuk <dubiniuk@owncloud.com>
*
* @copyright Viktar Dubiniuk 2021
* @license AGPL-3.0
*/
namespace OCA\Files_Antivirus\Migrations;
use Doctrine\DBAL\Schema\Schema;
use OCP\Migration\ISchemaMigration;
/**
* Moved here from preupdate.php. Migrates a long table name into a shorter one.
* Needs to be done for app versions below 0.6.1
*/
class Version20210212160142 implements ISchemaMigration {
/**
* @param Schema $schema
* @param array $options
*
* @return void
* @throws \Doctrine\DBAL\Exception
* @throws \Doctrine\DBAL\Schema\SchemaException
*/
public function changeSchema(Schema $schema, array $options) {
$prefix = $options['tablePrefix'];
if (
$schema->hasTable("{$prefix}files_antivirus_status")
&& $schema->hasTable("{$prefix}files_avir_status") === false
) {
$dbConn = \OC::$server->getDatabaseConnection();
$alterQuery = $dbConn->prepare(
'ALTER TABLE `*PREFIX*files_antivirus_status` RENAME TO `*PREFIX*files_avir_status`'
);
$alterQuery->executeStatement();
}
}
}