From c1e387c08fe63881d293266422ad2bcf0033566e Mon Sep 17 00:00:00 2001 From: Maxence Lange Date: Wed, 12 Dec 2018 08:50:54 -0100 Subject: [PATCH] varchar->text --- lib/Db/CacheActorsRequest.php | 7 +----- lib/Db/CoreRequestBuilder.php | 5 +--- lib/Db/NotesRequest.php | 7 +----- ....php => Version0001Date20181211222142.php} | 23 +++++++++++-------- 4 files changed, 17 insertions(+), 25 deletions(-) rename lib/Migration/{Version0001Date20181208185242.php => Version0001Date20181211222142.php} (80%) diff --git a/lib/Db/CacheActorsRequest.php b/lib/Db/CacheActorsRequest.php index e69afbc1..5d703098 100644 --- a/lib/Db/CacheActorsRequest.php +++ b/lib/Db/CacheActorsRequest.php @@ -64,11 +64,6 @@ class CacheActorsRequest extends CacheActorsRequestBuilder { * @param Person $actor */ public function save(Person $actor) { - $source = $actor->getSource(); - if (strlen($source) >= CoreRequestBuilder::SOURCE_LENGTH) { - $source = 'too_big'; - } - $qb = $this->getCacheActorsInsertSql(); $qb->setValue('id', $qb->createNamedParameter($actor->getId())) ->setValue('account', $qb->createNamedParameter($actor->getAccount())) @@ -87,7 +82,7 @@ class CacheActorsRequest extends CacheActorsRequestBuilder { ->setValue('name', $qb->createNamedParameter($actor->getName())) ->setValue('summary', $qb->createNamedParameter($actor->getSummary())) ->setValue('public_key', $qb->createNamedParameter($actor->getPublicKey())) - ->setValue('source', $qb->createNamedParameter($source)) + ->setValue('source', $qb->createNamedParameter($actor->getSource())) ->setValue('details', $qb->createNamedParameter(json_encode($actor->getDetails()))) ->setValue( 'creation', diff --git a/lib/Db/CoreRequestBuilder.php b/lib/Db/CoreRequestBuilder.php index 8f594ddd..0ca3e45e 100644 --- a/lib/Db/CoreRequestBuilder.php +++ b/lib/Db/CoreRequestBuilder.php @@ -63,10 +63,7 @@ class CoreRequestBuilder { const TABLE_CACHE_ACTORS = 'social_cache_actors'; const TABLE_CACHE_DOCUMENTS = 'social_cache_documents'; - - const SOURCE_LENGTH = 10000; - - + /** @var IDBConnection */ protected $dbConnection; diff --git a/lib/Db/NotesRequest.php b/lib/Db/NotesRequest.php index fdd1313b..891c7f91 100644 --- a/lib/Db/NotesRequest.php +++ b/lib/Db/NotesRequest.php @@ -66,11 +66,6 @@ class NotesRequest extends NotesRequestBuilder { $dTime = new DateTime(); $dTime->setTimestamp($note->getPublishedTime()); - $source = $note->getSource(); - if (strlen($source) >= CoreRequestBuilder::SOURCE_LENGTH) { - $source = 'too_big'; - } - $qb = $this->getNotesInsertSql(); $qb->setValue('id', $qb->createNamedParameter($note->getId())) ->setValue('type', $qb->createNamedParameter($note->getType())) @@ -98,7 +93,7 @@ class NotesRequest extends NotesRequestBuilder { ) ->setValue('attributed_to', $qb->createNamedParameter($note->getAttributedTo())) ->setValue('in_reply_to', $qb->createNamedParameter($note->getInReplyTo())) - ->setValue('source', $qb->createNamedParameter($source)) + ->setValue('source', $qb->createNamedParameter($note->getSource())) ->setValue( 'instances', $qb->createNamedParameter( json_encode($note->getInstancePaths(), JSON_UNESCAPED_SLASHES) diff --git a/lib/Migration/Version0001Date20181208185242.php b/lib/Migration/Version0001Date20181211222142.php similarity index 80% rename from lib/Migration/Version0001Date20181208185242.php rename to lib/Migration/Version0001Date20181211222142.php index 3194f2ee..93f1d59e 100644 --- a/lib/Migration/Version0001Date20181208185242.php +++ b/lib/Migration/Version0001Date20181211222142.php @@ -32,6 +32,9 @@ namespace OCA\Social\Migration; use Closure; +use Doctrine\DBAL\DBALException; +use Doctrine\DBAL\Schema\SchemaException; +use Doctrine\DBAL\Types\Type; use OCA\Social\Db\CoreRequestBuilder; use OCP\DB\ISchemaWrapper; use OCP\Migration\IOutput; @@ -39,11 +42,11 @@ use OCP\Migration\SimpleMigrationStep; /** - * Class Version0001Date20181208185242 + * Class Version0001Date20181211222142 * * @package OCA\Social\Migration */ -class Version0001Date20181208185242 extends SimpleMigrationStep { +class Version0001Date20181211222142 extends SimpleMigrationStep { /** @@ -52,7 +55,8 @@ class Version0001Date20181208185242 extends SimpleMigrationStep { * @param array $options * * @return ISchemaWrapper - * @throws \Doctrine\DBAL\Schema\SchemaException + * @throws SchemaException + * @throws DBALException */ public function changeSchema(IOutput $output, Closure $schemaClosure, array $options ): ISchemaWrapper { @@ -62,27 +66,28 @@ class Version0001Date20181208185242 extends SimpleMigrationStep { $table = $schema->getTable(CoreRequestBuilder::TABLE_CACHE_ACTORS); $table->changeColumn( 'source', [ - 'notnull' => true, - 'length' => CoreRequestBuilder::SOURCE_LENGTH, + 'notnull' => false, + 'type' => Type::getType(Type::TEXT) ] ); $table = $schema->getTable(CoreRequestBuilder::TABLE_SERVER_NOTES); $table->changeColumn( 'source', [ - 'notnull' => true, - 'length' => CoreRequestBuilder::SOURCE_LENGTH, + 'notnull' => false, + 'type' => Type::getType(Type::TEXT) ] ); $table = $schema->getTable(CoreRequestBuilder::TABLE_REQUEST_QUEUE); $table->changeColumn( 'activity', [ - 'notnull' => true, - 'length' => CoreRequestBuilder::SOURCE_LENGTH, + 'notnull' => false, + 'type' => Type::getType(Type::TEXT) ] ); return $schema; } } +