diff --git a/appinfo/database.xml b/appinfo/database.xml
deleted file mode 100644
index 75d117c7..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
-
-
-
- summary
- text
- 3000
- true
-
-
-
- public_key
- text
- 1000
-
-
-
- private_key
- text
- 2000
-
-
-
- avatar_version
- integer
- 2
- false
-
-
-
- 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/lib/Migration/Version0001Date20181204203147.php b/lib/Migration/Version0001Date20181204203147.php
new file mode 100644
index 00000000..46bf48eb
--- /dev/null
+++ b/lib/Migration/Version0001Date20181204203147.php
@@ -0,0 +1,353 @@
+
+ *
+ * @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 Version0001Date20181204203147 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('avatar_version', 'integer', [
+ 'notnull' => false,
+ 'length' => 2,
+ ]);
+ $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' => false
+ ]);
+ $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' => false
+ ]);
+ $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' => false
+ ]);
+ $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,
+ 'default' => false
+ ]);
+ $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;
+ }
+}