From 1b00287cb4bc7ed47d07ee48e2cf857727f45c9e Mon Sep 17 00:00:00 2001 From: Roeland Jago Douma <roeland@famdouma.nl> Date: Tue, 4 Dec 2018 21:34:25 +0100 Subject: [PATCH 1/3] Move over to Migrations Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl> --- 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 @@ -<?xml version="1.0" encoding="UTF-8"?> -<database> - <name>*dbname*</name> - <create>true</create> - <overwrite>false</overwrite> - <charset>utf8</charset> - - <table> - <name>*dbprefix*social_server_actors</name> - <declaration> - - <field> - <name>id</name> - <type>text</type> - <length>127</length> - <notnull>true</notnull> - <primary>true</primary> - </field> - - <field> - <name>user_id</name> - <type>text</type> - <length>63</length> - <notnull>true</notnull> - </field> - - <field> - <name>preferred_username</name> - <type>text</type> - <length>127</length> - <notnull>true</notnull> - </field> - - <field> - <name>name</name> - <type>text</type> - <length>127</length> - <notnull>true</notnull> - </field> - - <field> - <name>summary</name> - <type>text</type> - <length>3000</length> - <notnull>true</notnull> - </field> - - <field> - <name>public_key</name> - <type>text</type> - <length>1000</length> - </field> - - <field> - <name>private_key</name> - <type>text</type> - <length>2000</length> - </field> - - <field> - <name>creation</name> - <type>timestamp</type> - </field> - - </declaration> - </table> - - <table> - <name>*dbprefix*social_server_follows</name> - <declaration> - - <field> - <name>id</name> - <type>text</type> - <length>127</length> - <notnull>true</notnull> - <primary>true</primary> - </field> - - <field> - <name>type</name> - <type>text</type> - <length>31</length> - <notnull>false</notnull> - </field> - - <field> - <name>actor_id</name> - <type>text</type> - <length>127</length> - <notnull>true</notnull> - </field> - - <field> - <name>object_id</name> - <type>text</type> - <length>127</length> - <notnull>true</notnull> - </field> - - <field> - <name>follow_id</name> - <type>text</type> - <length>127</length> - <notnull>true</notnull> - </field> - - <field> - <name>accepted</name> - <type>boolean</type> - <default>false</default> - <notnull>true</notnull> - </field> - - <field> - <name>creation</name> - <type>timestamp</type> - </field> - - </declaration> - </table> - - <table> - <name>*dbprefix*social_server_notes</name> - <declaration> - - <field> - <name>id</name> - <type>text</type> - <length>127</length> - <notnull>true</notnull> - <primary>true</primary> - </field> - - <field> - <name>type</name> - <type>text</type> - <length>31</length> - <notnull>true</notnull> - </field> - - <field> - <name>to</name> - <type>text</type> - <length>127</length> - <notnull>true</notnull> - </field> - - <field> - <name>to_array</name> - <type>text</type> - <length>2000</length> - <notnull>true</notnull> - </field> - - <field> - <name>cc</name> - <type>text</type> - <length>127</length> - <notnull>true</notnull> - </field> - - <field> - <name>bcc</name> - <type>text</type> - <length>127</length> - <notnull>true</notnull> - </field> - - <field> - <name>content</name> - <type>text</type> - <length>3000</length> - <notnull>true</notnull> - </field> - - <field> - <name>summary</name> - <type>text</type> - <length>3000</length> - <notnull>true</notnull> - </field> - - <field> - <name>published</name> - <type>text</type> - <length>31</length> - <notnull>true</notnull> - </field> - - <field> - <name>published_time</name> - <type>timestamp</type> - <default>0</default> - </field> - - <field> - <name>attributed_to</name> - <type>text</type> - <length>127</length> - </field> - - <field> - <name>in_reply_to</name> - <type>text</type> - <length>127</length> - </field> - - <field> - <name>source</name> - <type>text</type> - <length>3000</length> - <notnull>true</notnull> - </field> - - <field> - <name>instances</name> - <type>text</type> - <length>3000</length> - <notnull>true</notnull> - </field> - - <field> - <name>creation</name> - <type>timestamp</type> - </field> - - <field> - <name>local</name> - <type>boolean</type> - <default>false</default> - <notnull>true</notnull> - </field> - - </declaration> - </table> - - <table> - <name>*dbprefix*social_cache_actors</name> - <declaration> - - <field> - <name>id</name> - <type>string</type> - <length>127</length> - <notnull>true</notnull> - <primary>true</primary> - </field> - - <field> - <name>type</name> - <type>text</type> - <length>31</length> - <notnull>true</notnull> - </field> - - <field> - <name>account</name> - <type>text</type> - <length>127</length> - <notnull>true</notnull> - </field> - - <field> - <name>local</name> - <type>boolean</type> - <default>false</default> - <notnull>true</notnull> - </field> - - <field> - <name>following</name> - <type>text</type> - <length>127</length> - <notnull>true</notnull> - </field> - - <field> - <name>followers</name> - <type>text</type> - <length>127</length> - <notnull>true</notnull> - </field> - - <field> - <name>inbox</name> - <type>text</type> - <length>127</length> - <notnull>true</notnull> - </field> - - <field> - <name>shared_inbox</name> - <type>text</type> - <length>127</length> - <notnull>true</notnull> - </field> - - <field> - <name>outbox</name> - <type>text</type> - <length>127</length> - <notnull>true</notnull> - </field> - - <field> - <name>featured</name> - <type>text</type> - <length>127</length> - <notnull>true</notnull> - </field> - - <field> - <name>url</name> - <type>text</type> - <length>127</length> - <notnull>true</notnull> - </field> - - <field> - <name>preferred_username</name> - <type>text</type> - <length>127</length> - <notnull>true</notnull> - </field> - - <field> - <name>name</name> - <type>text</type> - <length>127</length> - <notnull>true</notnull> - </field> - - <field> - <name>icon_id</name> - <type>text</type> - <length>127</length> - <notnull>false</notnull> - </field> - - <field> - <name>summary</name> - <type>text</type> - <length>3000</length> - <notnull>true</notnull> - </field> - - <field> - <name>public_key</name> - <type>text</type> - <length>500</length> - <notnull>true</notnull> - </field> - - <field> - <name>source</name> - <type>text</type> - <length>3000</length> - <notnull>true</notnull> - </field> - - <field> - <name>details</name> - <type>text</type> - <length>3000</length> - <notnull>false</notnull> - </field> - - <field> - <name>creation</name> - <type>timestamp</type> - </field> - - </declaration> - </table> - - <table> - <name>*dbprefix*social_cache_documents</name> - <declaration> - - <field> - <name>id</name> - <type>string</type> - <length>127</length> - <notnull>true</notnull> - <primary>true</primary> - </field> - - <field> - <name>type</name> - <type>text</type> - <length>31</length> - <notnull>true</notnull> - </field> - - <field> - <name>media_type</name> - <type>text</type> - <length>63</length> - <notnull>true</notnull> - </field> - - <field> - <name>mime_type</name> - <type>text</type> - <length>63</length> - <notnull>true</notnull> - </field> - - <field> - <name>url</name> - <type>text</type> - <length>127</length> - <notnull>true</notnull> - </field> - - <field> - <name>local_copy</name> - <type>text</type> - <length>127</length> - <notnull>true</notnull> - </field> - - <field> - <name>public</name> - <type>boolean</type> - <notnull>true</notnull> - </field> - - <field> - <name>error</name> - <type>integer</type> - <length>1</length> - <notnull>true</notnull> - </field> - - <field> - <name>creation</name> - <type>timestamp</type> - </field> - - <field> - <name>caching</name> - <type>timestamp</type> - </field> - - <index> - <name>unique_url</name> - <unique>true</unique> - <field> - <name>url</name> - </field> - </index> - </declaration> - </table> - - <table> - <name>*dbprefix*social_request_queue</name> - <declaration> - - <field> - <name>id</name> - <type>integer</type> - <length>11</length> - <unsigned>true</unsigned> - <notnull>true</notnull> - <autoincrement>true</autoincrement> - <primary>true</primary> - </field> - - <field> - <name>token</name> - <type>text</type> - <length>63</length> - <notnull>true</notnull> - </field> - - <field> - <name>author</name> - <type>text</type> - <length>1270</length> - <notnull>true</notnull> - </field> - - <field> - <name>activity</name> - <type>text</type> - <length>6000</length> - <notnull>true</notnull> - </field> - - <field> - <name>instance</name> - <type>text</type> - <length>500</length> - <notnull>false</notnull> - </field> - - <field> - <name>priority</name> - <type>integer</type> - <length>1</length> - <default>0</default> - <notnull>false</notnull> - </field> - - <field> - <name>status</name> - <type>integer</type> - <length>1</length> - <default>0</default> - <notnull>false</notnull> - </field> - - <field> - <name>tries</name> - <type>integer</type> - <length>2</length> - <default>0</default> - <notnull>false</notnull> - </field> - - <field> - <name>last</name> - <type>timestamp</type> - </field> - - </declaration> - </table> - -</database> - 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! ]]></description> - <version>0.0.62</version> + <version>0.0.63</version> <licence>agpl</licence> <author mail="maxence@artificial-owl.com">Maxence Lange</author> <author mail="jus@bitgrid.net">Julius Härtl</author> 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 @@ +<?php +declare(strict_types=1); +/** + * @copyright Copyright (c) 2018, Roeland Jago Douma <roeland@famdouma.nl> + * + * @author Roeland Jago Douma <roeland@famdouma.nl> + * + * @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\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 <coding@schilljs.com> 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 <maxence@artificial-owl.com> Date: Thu, 6 Dec 2018 19:36:03 -0100 Subject: [PATCH 3/3] fixing boolean and +avatar_version Signed-off-by: Maxence Lange <maxence@artificial-owl.com> --- 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,