lp: reduce liveid size to 128

Signed-off-by: Varun Patil <radialapps@gmail.com>
pull/803/head
Varun Patil 2023-08-31 13:32:52 -07:00
parent 5ad9092928
commit deef94f7cd
2 changed files with 83 additions and 2 deletions

View File

@ -53,7 +53,7 @@ class Version400800Date20221122105007 extends SimpleMigrationStep
if (!$table->hasColumn('liveid')) {
$table->addColumn('liveid', 'string', [
'notnull' => false,
'length' => 256,
'length' => 128, // Version505002Date20230831201833
'default' => '',
]);
}
@ -69,7 +69,7 @@ class Version400800Date20221122105007 extends SimpleMigrationStep
$table->addColumn('liveid', 'string', [
'notnull' => true,
'length' => 256,
'length' => 128, // Version505002Date20230831201833
]);
$table->addColumn('fileid', Types::BIGINT, [

View File

@ -0,0 +1,81 @@
<?php
declare(strict_types=1);
/**
* @copyright Copyright (c) 2022 Varun Patil <radialapps@gmail.com>
* @author Varun Patil <radialapps@gmail.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\Memories\Migration;
use OCP\DB\ISchemaWrapper;
use OCP\Migration\IOutput;
use OCP\Migration\SimpleMigrationStep;
class Version505002Date20230831201833 extends SimpleMigrationStep
{
/**
* @param \Closure(): ISchemaWrapper $schemaClosure
*/
public function preSchemaChange(IOutput $output, \Closure $schemaClosure, array $options): void
{
}
/**
* @param \Closure(): ISchemaWrapper $schemaClosure
*/
public function changeSchema(IOutput $output, \Closure $schemaClosure, array $options): ?ISchemaWrapper
{
/** @var ISchemaWrapper $schema */
$schema = $schemaClosure();
/*/
* This migration step resizes VARCHAR columns to be smaller.
* The older migrations are already updated to use the new size
* for newly created databases.
*/
if ($schema->hasTable('memories')) {
$table = $schema->getTable('memories');
$table->getColumn('liveid')->setOptions([
'notnull' => false,
'length' => 128,
'default' => '',
]);
}
if ($schema->hasTable('memories_livephoto')) {
$table = $schema->getTable('memories_livephoto');
$table->getColumn('liveid')->setOptions([
'notnull' => true,
'length' => 128,
]);
}
return $schema;
}
/**
* @param \Closure(): ISchemaWrapper $schemaClosure
*/
public function postSchemaChange(IOutput $output, \Closure $schemaClosure, array $options): void
{
}
}