Skip to content

Commit

Permalink
Add new migrations to dav app
Browse files Browse the repository at this point in the history
New migrations have been added to the dav app to
acheive the following:
1. Delete the existing entries in properties table
   which have null fileid entries
2. Restrict null value entry for fileid in properties table.

Signed-off-by: Sujith H <sharidasan@owncloud.com>
  • Loading branch information
sharidas committed Aug 23, 2019
1 parent 95e7aa0 commit eb68943
Show file tree
Hide file tree
Showing 3 changed files with 79 additions and 1 deletion.
38 changes: 38 additions & 0 deletions apps/dav/appinfo/Migrations/Version20190822150226.php
@@ -0,0 +1,38 @@
<?php
/**
* @author Sujith Haridasan <sharidasan@owncloud.com>
*
* @copyright Copyright (c) 2019, ownCloud GmbH
* @license AGPL-3.0
*
* This code is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License, version 3,
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License, version 3,
* along with this program. If not, see <http://www.gnu.org/licenses/>
*
*/

namespace OCA\dav\Migrations;

use OCP\IDBConnection;
use OCP\Migration\ISqlMigration;

/**
* Remove null fileid's from the properties table.
*/
class Version20190822150226 implements ISqlMigration {

public function sql(IDBConnection $connection) {
$qb = $connection->getQueryBuilder();
$qb->delete('properties')
->where($qb->expr()->isNull('fileid'));
$qb->execute();
}
}
40 changes: 40 additions & 0 deletions apps/dav/appinfo/Migrations/Version20190823065724.php
@@ -0,0 +1,40 @@
<?php
/**
* @author Sujith Haridasan <sharidasan@owncloud.com>
*
* @copyright Copyright (c) 2019, ownCloud GmbH
* @license AGPL-3.0
*
* This code is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License, version 3,
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License, version 3,
* along with this program. If not, see <http://www.gnu.org/licenses/>
*
*/

namespace OCA\dav\Migrations;

use Doctrine\DBAL\Schema\Schema;
use OCP\Migration\ISchemaMigration;

/**
* Add NULL constraint to fileid column for properties table.
*/
class Version20190823065724 implements ISchemaMigration {

public function changeSchema(Schema $schema, array $options) {
$prefix = $options['tablePrefix'];

$table = $schema->getTable("${prefix}properties");
$table->changeColumn('fileid', [
'notnull' => true,
]);
}
}
2 changes: 1 addition & 1 deletion apps/dav/appinfo/info.xml
Expand Up @@ -5,7 +5,7 @@
<description>ownCloud WebDAV endpoint</description>
<licence>AGPL</licence>
<author>owncloud.org</author>
<version>0.4.0</version>
<version>0.5.0</version>
<default_enable/>
<use-migrations>true</use-migrations>
<types>
Expand Down

0 comments on commit eb68943

Please sign in to comment.