From 73321dc5b1b301b1f5ef176a299b1665d8c135e7 Mon Sep 17 00:00:00 2001 From: Maxence Lange Date: Sun, 2 Jun 2019 10:38:13 -0100 Subject: [PATCH 1/3] switching cc to text Signed-off-by: Maxence Lange --- .../Version0002Date20190506000001.php | 55 +++++++++++++------ 1 file changed, 39 insertions(+), 16 deletions(-) diff --git a/lib/Migration/Version0002Date20190506000001.php b/lib/Migration/Version0002Date20190506000001.php index bf32139f..8d2c65a6 100644 --- a/lib/Migration/Version0002Date20190506000001.php +++ b/lib/Migration/Version0002Date20190506000001.php @@ -94,6 +94,8 @@ class Version0002Date20190506000001 extends SimpleMigrationStep { * @param IOutput $output * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` * @param array $options + * + * @throws Exception */ public function postSchemaChange(IOutput $output, Closure $schemaClosure, array $options) { @@ -334,14 +336,13 @@ class Version0002Date20190506000001 extends SimpleMigrationStep { 'to_array', 'string', [ 'notnull' => true, - 'length' => 1000, + 'length' => 2000, ] ); $table->addColumn( - 'cc', 'string', + 'cc', 'text', [ - 'notnull' => true, - 'length' => 1000, + 'notnull' => true ] ); $table->addColumn( @@ -899,6 +900,8 @@ class Version0002Date20190506000001 extends SimpleMigrationStep { /** * @param ISchemaWrapper $schema + * + * @throws Exception */ private function fillActors(ISchemaWrapper $schema) { $this->duplicateTable( @@ -921,6 +924,8 @@ class Version0002Date20190506000001 extends SimpleMigrationStep { /** * @param ISchemaWrapper $schema + * + * @throws Exception */ private function fillFollows(ISchemaWrapper $schema) { $this->duplicateTable( @@ -940,6 +945,8 @@ class Version0002Date20190506000001 extends SimpleMigrationStep { /** * @param ISchemaWrapper $schema + * + * @throws Exception */ private function fillHashtags(ISchemaWrapper $schema) { $this->duplicateTable( @@ -980,6 +987,8 @@ class Version0002Date20190506000001 extends SimpleMigrationStep { /** * @param ISchemaWrapper $schema + * + * @throws Exception */ private function fillStreams(ISchemaWrapper $schema) { $this->duplicateTable( @@ -1014,6 +1023,8 @@ class Version0002Date20190506000001 extends SimpleMigrationStep { /** * @param ISchemaWrapper $schema + * + * @throws Exception */ private function fillCacheActors(ISchemaWrapper $schema) { $this->duplicateTable( @@ -1045,6 +1056,8 @@ class Version0002Date20190506000001 extends SimpleMigrationStep { /** * @param ISchemaWrapper $schema + * + * @throws Exception */ private function fillCacheDocuments(ISchemaWrapper $schema) { $this->duplicateTable( @@ -1070,6 +1083,8 @@ class Version0002Date20190506000001 extends SimpleMigrationStep { /** * @param ISchemaWrapper $schema + * + * @throws Exception */ private function fillRequestQueue(ISchemaWrapper $schema) { $this->duplicateTable( @@ -1089,6 +1104,11 @@ class Version0002Date20190506000001 extends SimpleMigrationStep { } + /** + * @param ISchemaWrapper $schema + * + * @throws Exception + */ private function fillStreamActions(ISchemaWrapper $schema) { $this->duplicateTable( $schema, 'social_stream_actions', CoreRequestBuilder::TABLE_STREAM_ACTIONS, @@ -1103,18 +1123,21 @@ class Version0002Date20190506000001 extends SimpleMigrationStep { private function fillStreamQueue(ISchemaWrapper $schema) { - $this->duplicateTable( - $schema, 'social_queue_stream', CoreRequestBuilder::TABLE_STREAM_QUEUE, - [ - 'id', - 'token', - 'stream_id', - 'type', - 'status', - 'tries', - 'last' - ] - ); + try { + $this->duplicateTable( + $schema, 'social_queue_stream', CoreRequestBuilder::TABLE_STREAM_QUEUE, + [ + 'id', + 'token', + 'stream_id', + 'type', + 'status', + 'tries', + 'last' + ] + ); + } catch (Exception $e) { + } } From d5f8f423af4761dd09777ff4cba290a050c9683d Mon Sep 17 00:00:00 2001 From: Maxence Lange Date: Sun, 2 Jun 2019 10:43:18 -0100 Subject: [PATCH 2/3] cleaning. Signed-off-by: Maxence Lange --- .../Version0002Date20190506000001.php | 34 ++++++++----------- 1 file changed, 15 insertions(+), 19 deletions(-) diff --git a/lib/Migration/Version0002Date20190506000001.php b/lib/Migration/Version0002Date20190506000001.php index 8d2c65a6..5dd7b237 100644 --- a/lib/Migration/Version0002Date20190506000001.php +++ b/lib/Migration/Version0002Date20190506000001.php @@ -32,8 +32,8 @@ namespace OCA\Social\Migration; use Closure; -use Doctrine\DBAL\Exception\UniqueConstraintViolationException; use DateTime; +use Doctrine\DBAL\Exception\UniqueConstraintViolationException; use Doctrine\DBAL\Types\Type; use Exception; use OCA\Social\Db\CoreRequestBuilder; @@ -333,23 +333,21 @@ class Version0002Date20190506000001 extends SimpleMigrationStep { ] ); $table->addColumn( - 'to_array', 'string', - [ - 'notnull' => true, - 'length' => 2000, - ] - ); - $table->addColumn( - 'cc', 'text', + 'to_array', Type::TEXT, [ 'notnull' => true ] ); $table->addColumn( - 'bcc', 'string', + 'cc', Type::TEXT, [ - 'notnull' => true, - 'length' => 1000, + 'notnull' => true + ] + ); + $table->addColumn( + 'bcc', Type::TEXT, + [ + 'notnull' => true ] ); $table->addColumn( @@ -590,15 +588,13 @@ class Version0002Date20190506000001 extends SimpleMigrationStep { $table->addColumn( 'source', Type::TEXT, [ - 'notnull' => true, - 'length' => 3000, + 'notnull' => true ] ); $table->addColumn( - 'details', 'string', + 'details', Type::TEXT, [ - 'notnull' => false, - 'length' => 3000, + 'notnull' => false ] ); $table->addColumn( @@ -1230,7 +1226,7 @@ class Version0002Date20190506000001 extends SimpleMigrationStep { && $this->get('id', $data, '') !== '') { $value = hash('sha512', $this->get('id', $data, '')); } - + if (in_array($field, $datetimeFields) && $value === '') { $insert->setValue( $field, @@ -1242,7 +1238,7 @@ class Version0002Date20190506000001 extends SimpleMigrationStep { ); } } - + try { $insert->execute(); } catch (UniqueConstraintViolationException $e) { From 3ebd8b8bd0cf4aa1b4c1073fa5f1843aa2971152 Mon Sep 17 00:00:00 2001 From: Maxence Lange Date: Sun, 2 Jun 2019 11:08:15 -0100 Subject: [PATCH 3/3] cleaning Signed-off-by: Maxence Lange --- .../Version0002Date20190506000001.php | 34 +++++++++++-------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/lib/Migration/Version0002Date20190506000001.php b/lib/Migration/Version0002Date20190506000001.php index 5dd7b237..2a96312c 100644 --- a/lib/Migration/Version0002Date20190506000001.php +++ b/lib/Migration/Version0002Date20190506000001.php @@ -1118,22 +1118,24 @@ class Version0002Date20190506000001 extends SimpleMigrationStep { } + /** + * @param ISchemaWrapper $schema + * + * @throws Exception + */ private function fillStreamQueue(ISchemaWrapper $schema) { - try { - $this->duplicateTable( - $schema, 'social_queue_stream', CoreRequestBuilder::TABLE_STREAM_QUEUE, - [ - 'id', - 'token', - 'stream_id', - 'type', - 'status', - 'tries', - 'last' - ] - ); - } catch (Exception $e) { - } + $this->duplicateTable( + $schema, 'social_queue_stream', CoreRequestBuilder::TABLE_STREAM_QUEUE, + [ + 'id', + 'token', + 'stream_id', + 'type', + 'status', + 'tries', + 'last' + ] + ); } @@ -1180,6 +1182,8 @@ class Version0002Date20190506000001 extends SimpleMigrationStep { * @param string $source * @param string $dest * @param array $fields + * + * @throws Exception */ private function duplicateTable( ISchemaWrapper $schema, string $source, string $dest, array $fields