Skip to content

Commit

Permalink
Merge pull request #1156 from nextcloud/fix/del_old_tables
Browse files Browse the repository at this point in the history
Remove old forms tables
  • Loading branch information
jotoeri authored Apr 11, 2022
2 parents fbc28f8 + d53aa30 commit 19d77a8
Showing 1 changed file with 66 additions and 0 deletions.
66 changes: 66 additions & 0 deletions lib/Migration/Version030000Date20220402151229.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
<?php

declare(strict_types=1);
/**
* @copyright Copyright (c) 2022 Jonas Rittershofer <jotoeri@users.noreply.github.com>
*
* @author Jonas Rittershofer <jotoeri@users.noreply.github.com>
*
* @license AGPL-3.0-or-later
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* 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
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OCA\Forms\Migration;

use Closure;
use OCP\DB\ISchemaWrapper;
use OCP\Migration\IOutput;
use OCP\Migration\SimpleMigrationStep;

class Version030000Date20220402151229 extends SimpleMigrationStep {
/**
* @param IOutput $output
* @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
* @param array $options
* @return null|ISchemaWrapper
*/
public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper {
/** @var ISchemaWrapper $schema */
$schema = $schemaClosure();
$update_necessary = false;

/*
* Remove old (Forms < v2) DB-Tables
*/
if ($schema->hasTable('forms_events')) {
$schema->dropTable('forms_events');
$update_necessary = true;
}
if ($schema->hasTable('forms_questions')) {
$schema->dropTable('forms_questions');
$update_necessary = true;
}
if ($schema->hasTable('forms_answers')) {
$schema->dropTable('forms_answers');
$update_necessary = true;
}
if ($schema->hasTable('forms_votes')) {
$schema->dropTable('forms_votes');
$update_necessary = true;
}

return $update_necesssary ? $schema : null;
}
}

0 comments on commit 19d77a8

Please sign in to comment.