]> source.dussan.org Git - nextcloud-server.git/commitdiff
Create cards if none
authorJohn Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
Sat, 27 Oct 2018 11:39:10 +0000 (13:39 +0200)
committerMorris Jobke <hey@morrisjobke.de>
Thu, 1 Nov 2018 14:00:49 +0000 (15:00 +0100)
Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
core/Migrations/Version15000Date20180927120000.php

index 5636811baa6fbd5ae5a505499761ffae47178e40..d38914314fffeecd07937b5302541e5730c4f7e6 100644 (file)
@@ -36,11 +36,51 @@ class Version15000Date20180927120000 extends SimpleMigrationStep {
                /** @var ISchemaWrapper $schema */
                $schema = $schemaClosure();
 
-               $table = $schema->getTable('cards');
-               $table->addColumn('uid', Type::STRING, [
-                       'notnull' => false,
-                       'length' => 255
-               ]);
+               if ($schema->hasTable('cards')) {
+                       $table = $schema->getTable('cards');
+                       $table->addColumn('uid', Type::STRING, [
+                               'notnull' => false,
+                               'length' => 255
+                       ]);
+               } else {
+                       $table = $schema->createTable('cards');
+                       $table->addColumn('id', 'bigint', [
+                               'autoincrement' => true,
+                               'notnull' => true,
+                               'length' => 11,
+                               'unsigned' => true,
+                       ]);
+                       $table->addColumn('addressbookid', 'integer', [
+                               'notnull' => true,
+                               'default' => 0,
+                       ]);
+                       $table->addColumn('carddata', 'blob', [
+                               'notnull' => false,
+                       ]);
+                       $table->addColumn('uri', 'string', [
+                               'notnull' => false,
+                               'length' => 255,
+                       ]);
+                       $table->addColumn('lastmodified', 'bigint', [
+                               'notnull' => false,
+                               'length' => 11,
+                               'unsigned' => true,
+                       ]);
+                       $table->addColumn('etag', 'string', [
+                               'notnull' => false,
+                               'length' => 32,
+                       ]);
+                       $table->addColumn('size', 'bigint', [
+                               'notnull' => true,
+                               'length' => 11,
+                               'unsigned' => true,
+                       ]);
+                       $table->addColumn('uid', Type::STRING, [
+                               'notnull' => false,
+                               'length' => 255
+                       ]);
+                       $table->setPrimaryKey(['id']);
+               }
 
                return $schema;
        }