From 1b00287cb4bc7ed47d07ee48e2cf857727f45c9e Mon Sep 17 00:00:00 2001 From: Roeland Jago Douma Date: Tue, 4 Dec 2018 21:34:25 +0100 Subject: [PATCH 1/3] Move over to Migrations Signed-off-by: Roeland Jago Douma --- appinfo/database.xml | 532 ------------------ appinfo/info.xml | 2 +- .../Version000063Date20181204203147.php | 348 ++++++++++++ 3 files changed, 349 insertions(+), 533 deletions(-) delete mode 100644 appinfo/database.xml create mode 100644 lib/Migration/Version000063Date20181204203147.php diff --git a/appinfo/database.xml b/appinfo/database.xml deleted file mode 100644 index d2783dc0..00000000 --- a/appinfo/database.xml +++ /dev/null @@ -1,532 +0,0 @@ - - - *dbname* - true - false - utf8 - - - *dbprefix*social_server_actors - - - - id - text - 127 - true - true - - - - user_id - text - 63 - true - - - - preferred_username - text - 127 - true - - - - name - text - 127 - true - - - - summary - text - 3000 - true - - - - public_key - text - 1000 - - - - private_key - text - 2000 - - - - creation - timestamp - - - -
- - - *dbprefix*social_server_follows - - - - id - text - 127 - true - true - - - - type - text - 31 - false - - - - actor_id - text - 127 - true - - - - object_id - text - 127 - true - - - - follow_id - text - 127 - true - - - - accepted - boolean - false - true - - - - creation - timestamp - - - -
- - - *dbprefix*social_server_notes - - - - id - text - 127 - true - true - - - - type - text - 31 - true - - - - to - text - 127 - true - - - - to_array - text - 2000 - true - - - - cc - text - 127 - true - - - - bcc - text - 127 - true - - - - content - text - 3000 - true - - - - summary - text - 3000 - true - - - - published - text - 31 - true - - - - published_time - timestamp - 0 - - - - attributed_to - text - 127 - - - - in_reply_to - text - 127 - - - - source - text - 3000 - true - - - - instances - text - 3000 - true - - - - creation - timestamp - - - - local - boolean - false - true - - - -
- - - *dbprefix*social_cache_actors - - - - id - string - 127 - true - true - - - - type - text - 31 - true - - - - account - text - 127 - true - - - - local - boolean - false - true - - - - following - text - 127 - true - - - - followers - text - 127 - true - - - - inbox - text - 127 - true - - - - shared_inbox - text - 127 - true - - - - outbox - text - 127 - true - - - - featured - text - 127 - true - - - - url - text - 127 - true - - - - preferred_username - text - 127 - true - - - - name - text - 127 - true - - - - icon_id - text - 127 - false - - - - summary - text - 3000 - true - - - - public_key - text - 500 - true - - - - source - text - 3000 - true - - - - details - text - 3000 - false - - - - creation - timestamp - - - -
- - - *dbprefix*social_cache_documents - - - - id - string - 127 - true - true - - - - type - text - 31 - true - - - - media_type - text - 63 - true - - - - mime_type - text - 63 - true - - - - url - text - 127 - true - - - - local_copy - text - 127 - true - - - - public - boolean - true - - - - error - integer - 1 - true - - - - creation - timestamp - - - - caching - timestamp - - - - unique_url - true - - url - - - -
- - - *dbprefix*social_request_queue - - - - id - integer - 11 - true - true - true - true - - - - token - text - 63 - true - - - - author - text - 1270 - true - - - - activity - text - 6000 - true - - - - instance - text - 500 - false - - - - priority - integer - 1 - 0 - false - - - - status - integer - 1 - 0 - false - - - - tries - integer - 2 - 0 - false - - - - last - timestamp - - - -
- -
- diff --git a/appinfo/info.xml b/appinfo/info.xml index 452e8938..ebcd90a5 100644 --- a/appinfo/info.xml +++ b/appinfo/info.xml @@ -15,7 +15,7 @@ **🕸 Open standards:** We use the established ActivityPub standard! ]]> - 0.0.62 + 0.0.63 agpl Maxence Lange Julius Härtl diff --git a/lib/Migration/Version000063Date20181204203147.php b/lib/Migration/Version000063Date20181204203147.php new file mode 100644 index 00000000..13e4ba51 --- /dev/null +++ b/lib/Migration/Version000063Date20181204203147.php @@ -0,0 +1,348 @@ + + * + * @author Roeland Jago Douma + * + * @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 . + * + */ + +namespace OCA\Social\Migration; + +use Closure; +use OCP\DB\ISchemaWrapper; +use OCP\Migration\SimpleMigrationStep; +use OCP\Migration\IOutput; + +class Version000063Date20181204203147 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('social_server_actors')) { + $table = $schema->createTable('social_server_actors'); + $table->addColumn('id', 'string', [ + 'notnull' => true, + 'length' => 127, + ]); + $table->addColumn('user_id', 'string', [ + 'notnull' => true, + 'length' => 63, + ]); + $table->addColumn('preferred_username', 'string', [ + 'notnull' => true, + 'length' => 127, + ]); + $table->addColumn('name', 'string', [ + 'notnull' => true, + 'length' => 127, + ]); + $table->addColumn('summary', 'string', [ + 'notnull' => true, + 'length' => 3000, + ]); + $table->addColumn('public_key', 'string', [ + 'notnull' => false, + 'length' => 1000, + ]); + $table->addColumn('private_key', 'string', [ + 'notnull' => false, + 'length' => 2000, + ]); + $table->addColumn('creation', 'datetime', [ + 'notnull' => false, + ]); + $table->setPrimaryKey(['id']); + } + + if (!$schema->hasTable('social_server_follows')) { + $table = $schema->createTable('social_server_follows'); + $table->addColumn('id', 'string', [ + 'notnull' => true, + 'length' => 127, + ]); + $table->addColumn('type', 'string', [ + 'notnull' => false, + 'length' => 31, + ]); + $table->addColumn('actor_id', 'string', [ + 'notnull' => true, + 'length' => 127, + ]); + $table->addColumn('object_id', 'string', [ + 'notnull' => true, + 'length' => 127, + ]); + $table->addColumn('follow_id', 'string', [ + 'notnull' => true, + 'length' => 127, + ]); + $table->addColumn('accepted', 'boolean', [ + 'notnull' => true, + 'default' => '', + ]); + $table->addColumn('creation', 'datetime', [ + 'notnull' => false, + ]); + $table->setPrimaryKey(['id']); + } + + if (!$schema->hasTable('social_server_notes')) { + $table = $schema->createTable('social_server_notes'); + $table->addColumn('id', 'string', [ + 'notnull' => true, + 'length' => 127, + ]); + $table->addColumn('type', 'string', [ + 'notnull' => true, + 'length' => 31, + ]); + $table->addColumn('to', 'string', [ + 'notnull' => true, + 'length' => 127, + ]); + $table->addColumn('to_array', 'string', [ + 'notnull' => true, + 'length' => 2000, + ]); + $table->addColumn('cc', 'string', [ + 'notnull' => true, + 'length' => 127, + ]); + $table->addColumn('bcc', 'string', [ + 'notnull' => true, + 'length' => 127, + ]); + $table->addColumn('content', 'string', [ + 'notnull' => true, + 'length' => 3000, + ]); + $table->addColumn('summary', 'string', [ + 'notnull' => true, + 'length' => 3000, + ]); + $table->addColumn('published', 'string', [ + 'notnull' => true, + 'length' => 31, + ]); + $table->addColumn('published_time', 'datetime', [ + 'notnull' => false, + ]); + $table->addColumn('attributed_to', 'string', [ + 'notnull' => false, + 'length' => 127, + ]); + $table->addColumn('in_reply_to', 'string', [ + 'notnull' => false, + 'length' => 127, + ]); + $table->addColumn('source', 'string', [ + 'notnull' => true, + 'length' => 3000, + ]); + $table->addColumn('instances', 'string', [ + 'notnull' => true, + 'length' => 3000, + ]); + $table->addColumn('creation', 'datetime', [ + 'notnull' => false, + ]); + $table->addColumn('local', 'boolean', [ + 'notnull' => true, + 'default' => '', + ]); + $table->setPrimaryKey(['id']); + } + + if (!$schema->hasTable('social_cache_actors')) { + $table = $schema->createTable('social_cache_actors'); + $table->addColumn('id', 'string', [ + 'notnull' => true, + 'length' => 127, + ]); + $table->addColumn('type', 'string', [ + 'notnull' => true, + 'length' => 31, + ]); + $table->addColumn('account', 'string', [ + 'notnull' => true, + 'length' => 127, + ]); + $table->addColumn('local', 'boolean', [ + 'notnull' => true, + 'default' => '', + ]); + $table->addColumn('following', 'string', [ + 'notnull' => true, + 'length' => 127, + ]); + $table->addColumn('followers', 'string', [ + 'notnull' => true, + 'length' => 127, + ]); + $table->addColumn('inbox', 'string', [ + 'notnull' => true, + 'length' => 127, + ]); + $table->addColumn('shared_inbox', 'string', [ + 'notnull' => true, + 'length' => 127, + ]); + $table->addColumn('outbox', 'string', [ + 'notnull' => true, + 'length' => 127, + ]); + $table->addColumn('featured', 'string', [ + 'notnull' => true, + 'length' => 127, + ]); + $table->addColumn('url', 'string', [ + 'notnull' => true, + 'length' => 127, + ]); + $table->addColumn('preferred_username', 'string', [ + 'notnull' => true, + 'length' => 127, + ]); + $table->addColumn('name', 'string', [ + 'notnull' => true, + 'length' => 127, + ]); + $table->addColumn('icon_id', 'string', [ + 'notnull' => false, + 'length' => 127, + ]); + $table->addColumn('summary', 'string', [ + 'notnull' => true, + 'length' => 3000, + ]); + $table->addColumn('public_key', 'string', [ + 'notnull' => true, + 'length' => 500, + ]); + $table->addColumn('source', 'string', [ + 'notnull' => true, + 'length' => 3000, + ]); + $table->addColumn('details', 'string', [ + 'notnull' => false, + 'length' => 3000, + ]); + $table->addColumn('creation', 'datetime', [ + 'notnull' => false, + ]); + $table->setPrimaryKey(['id']); + } + + if (!$schema->hasTable('social_cache_documents')) { + $table = $schema->createTable('social_cache_documents'); + $table->addColumn('id', 'string', [ + 'notnull' => true, + 'length' => 127, + ]); + $table->addColumn('type', 'string', [ + 'notnull' => true, + 'length' => 31, + ]); + $table->addColumn('media_type', 'string', [ + 'notnull' => true, + 'length' => 63, + ]); + $table->addColumn('mime_type', 'string', [ + 'notnull' => true, + 'length' => 63, + ]); + $table->addColumn('url', 'string', [ + 'notnull' => true, + 'length' => 127, + ]); + $table->addColumn('local_copy', 'string', [ + 'notnull' => true, + 'length' => 127, + ]); + $table->addColumn('public', 'boolean', [ + 'notnull' => true, + ]); + $table->addColumn('error', 'smallint', [ + 'notnull' => true, + 'length' => 1, + ]); + $table->addColumn('creation', 'datetime', [ + 'notnull' => false, + ]); + $table->addColumn('caching', 'datetime', [ + 'notnull' => false, + ]); + $table->setPrimaryKey(['id']); + $table->addUniqueIndex(['url'], 'unique_url'); + } + + if (!$schema->hasTable('social_request_queue')) { + $table = $schema->createTable('social_request_queue'); + $table->addColumn('id', 'bigint', [ + 'autoincrement' => true, + 'notnull' => true, + 'length' => 11, + 'unsigned' => true, + ]); + $table->addColumn('token', 'string', [ + 'notnull' => true, + 'length' => 63, + ]); + $table->addColumn('author', 'string', [ + 'notnull' => true, + 'length' => 1270, + ]); + $table->addColumn('activity', 'string', [ + 'notnull' => true, + 'length' => 6000, + ]); + $table->addColumn('instance', 'string', [ + 'notnull' => false, + 'length' => 500, + ]); + $table->addColumn('priority', 'smallint', [ + 'notnull' => false, + 'length' => 1, + 'default' => 0, + ]); + $table->addColumn('status', 'smallint', [ + 'notnull' => false, + 'length' => 1, + 'default' => 0, + ]); + $table->addColumn('tries', 'smallint', [ + 'notnull' => false, + 'length' => 2, + 'default' => 0, + ]); + $table->addColumn('last', 'datetime', [ + 'notnull' => false, + ]); + $table->setPrimaryKey(['id']); + } + return $schema; + } +} From d1b8b283f29e6050cdf682822d1b3ddcc4922847 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Wed, 5 Dec 2018 13:17:33 +0100 Subject: [PATCH 2/3] fixup! Move over to Migrations --- ...Date20181204203147.php => Version0001Date20181204203147.php} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename lib/Migration/{Version000063Date20181204203147.php => Version0001Date20181204203147.php} (99%) diff --git a/lib/Migration/Version000063Date20181204203147.php b/lib/Migration/Version0001Date20181204203147.php similarity index 99% rename from lib/Migration/Version000063Date20181204203147.php rename to lib/Migration/Version0001Date20181204203147.php index 13e4ba51..76c2bf55 100644 --- a/lib/Migration/Version000063Date20181204203147.php +++ b/lib/Migration/Version0001Date20181204203147.php @@ -29,7 +29,7 @@ use OCP\DB\ISchemaWrapper; use OCP\Migration\SimpleMigrationStep; use OCP\Migration\IOutput; -class Version000063Date20181204203147 extends SimpleMigrationStep { +class Version0001Date20181204203147 extends SimpleMigrationStep { /** * @param IOutput $output From f08e7f29b10f4b2f68ba1526ac35a08b1aed603c Mon Sep 17 00:00:00 2001 From: Maxence Lange Date: Thu, 6 Dec 2018 19:36:03 -0100 Subject: [PATCH 3/3] fixing boolean and +avatar_version Signed-off-by: Maxence Lange --- lib/Migration/Version0001Date20181204203147.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/lib/Migration/Version0001Date20181204203147.php b/lib/Migration/Version0001Date20181204203147.php index 76c2bf55..46bf48eb 100644 --- a/lib/Migration/Version0001Date20181204203147.php +++ b/lib/Migration/Version0001Date20181204203147.php @@ -71,6 +71,10 @@ class Version0001Date20181204203147 extends SimpleMigrationStep { 'notnull' => false, 'length' => 2000, ]); + $table->addColumn('avatar_version', 'integer', [ + 'notnull' => false, + 'length' => 2, + ]); $table->addColumn('creation', 'datetime', [ 'notnull' => false, ]); @@ -101,7 +105,7 @@ class Version0001Date20181204203147 extends SimpleMigrationStep { ]); $table->addColumn('accepted', 'boolean', [ 'notnull' => true, - 'default' => '', + 'default' => false ]); $table->addColumn('creation', 'datetime', [ 'notnull' => false, @@ -171,7 +175,7 @@ class Version0001Date20181204203147 extends SimpleMigrationStep { ]); $table->addColumn('local', 'boolean', [ 'notnull' => true, - 'default' => '', + 'default' => false ]); $table->setPrimaryKey(['id']); } @@ -192,7 +196,7 @@ class Version0001Date20181204203147 extends SimpleMigrationStep { ]); $table->addColumn('local', 'boolean', [ 'notnull' => true, - 'default' => '', + 'default' => false ]); $table->addColumn('following', 'string', [ 'notnull' => true, @@ -284,6 +288,7 @@ class Version0001Date20181204203147 extends SimpleMigrationStep { ]); $table->addColumn('public', 'boolean', [ 'notnull' => true, + 'default' => false ]); $table->addColumn('error', 'smallint', [ 'notnull' => true,