Increase description length

Signed-off-by: Jonas Rittershofer <jotoeri@users.noreply.github.com>
This commit is contained in:
Jonas Rittershofer 2020-07-29 23:42:41 +02:00
parent 6ebd1927b2
commit 726a405d2f
3 changed files with 67 additions and 6 deletions

View file

@ -86,10 +86,10 @@ class PageController extends Controller {
*/
private $maxStringLengths = [
'formTitle' => 256,
'formDescription' => 2048,
'formDescription' => 8192,
'questionText' => 2048,
'optionText' => 1024,
'answerText' => 2048,
'answerText' => 4096,
];
public function __construct(string $appName,

View file

@ -91,7 +91,7 @@ class Version010200Date20200323141300 extends SimpleMigrationStep {
]);
$table->addColumn('description', Type::STRING, [
'notnull' => false,
'length' => 2048,
'length' => 8192,
]);
$table->addColumn('owner_id', Type::STRING, [
'notnull' => true,
@ -199,7 +199,7 @@ class Version010200Date20200323141300 extends SimpleMigrationStep {
]);
$table->addColumn('text', Type::STRING, [
'notnull' => true,
'length' => 2048,
'length' => 4096,
]);
$table->setPrimaryKey(['id']);
}
@ -350,9 +350,9 @@ class Version010200Date20200323141300 extends SimpleMigrationStep {
$last_vote = $vote;
//In case the old Answer would have been longer than current possible length, create a warning and shorten text to avoid Error on upgrade.
if (strlen($vote['vote_answer']) > 2048) {
if (strlen($vote['vote_answer']) > 4096) {
$output->warning("Answer-text is too long for new Database: '" . $vote['vote_answer'] . "'");
$vote['vote_answer'] = mb_substr($vote['vote_answer'], 0, 2048);
$vote['vote_answer'] = mb_substr($vote['vote_answer'], 0, 4096);
}
/* Due to the unconventional storing fo vote_option_ids, the vote_option_id needs to get mapped onto old question-id and from there to new question-id.

View file

@ -0,0 +1,61 @@
<?php
declare(strict_types=1);
/**
* @copyright Copyright (c) 2020 Jonas Rittershofer <jotoeri@users.noreply.github.com>
*
* @author Jonas Rittershofer <jotoeri@users.noreply.github.com>
*
* @license GNU AGPL version 3 or any later version
*
* 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 Version020002Date20200729205932 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) {
/** @var ISchemaWrapper $schema */
$schema = $schemaClosure();
if ($schema->hasTable('forms_v2_forms')) {
$schema->getTable('forms_v2_forms')
->changeColumn('description', [
'length' => 8192,
]);
}
if ($schema->hasTable('forms_v2_answers')) {
$schema->getTable('forms_v2_answers')
->changeColumn('text', [
'length' => 4096,
]);
}
return $schema;
}
}