From 317921e51c676bf8bdc688bb9c819b34cb958ce8 Mon Sep 17 00:00:00 2001 From: Michael Date: Tue, 17 Nov 2020 23:45:16 +0000 Subject: [PATCH] Changed order --- src/Database/DBStructure.php | 44 +++++++++++++++++------------------ static/dbstructure.config.php | 1 + 2 files changed, 23 insertions(+), 22 deletions(-) diff --git a/src/Database/DBStructure.php b/src/Database/DBStructure.php index 5d0749c583..a59376e0ca 100644 --- a/src/Database/DBStructure.php +++ b/src/Database/DBStructure.php @@ -1054,6 +1054,28 @@ class DBStructure } } + if (self::existsTable('user') && !DBA::exists('user', ['uid' => 0])) { + $system = User::getSystemAccount(); + $user = [ + "username" => $system['name'], + "nickname" => $system['nick'], + "register_date" => $system['created'], + "pubkey" => $system['pubkey'], + "prvkey" => $system['prvkey'], + "spubkey" => $system['spubkey'], + "sprvkey" => $system['sprvkey'], + "verified" => true, + "page-flags" => User::PAGE_FLAGS_SOAPBOX, + "account-type" => User::ACCOUNT_TYPE_RELAY, + ]; + + DBA::insert('user', $user); + $lastid = DBA::lastInsertId(); + if ($lastid != 0) { + DBA::update('user', ['uid' => 0], ['uid' => $lastid]); + } + } + if (self::existsTable('contact') && !DBA::exists('contact', ['id' => 0])) { DBA::insert('contact', ['nurl' => '']); $lastid = DBA::lastInsertId(); @@ -1101,28 +1123,6 @@ class DBStructure } } - if (self::existsTable('user') && !DBA::exists('user', ['uid' => 0])) { - $system = User::getSystemAccount(); - $user = [ - "username" => $system['name'], - "nickname" => $system['nick'], - "register_date" => $system['created'], - "pubkey" => $system['pubkey'], - "prvkey" => $system['prvkey'], - "spubkey" => $system['spubkey'], - "sprvkey" => $system['sprvkey'], - "verified" => true, - "page-flags" => User::PAGE_FLAGS_SOAPBOX, - "account-type" => User::ACCOUNT_TYPE_RELAY, - ]; - - DBA::insert('user', $user); - $lastid = DBA::lastInsertId(); - if ($lastid != 0) { - DBA::update('user', ['uid' => 0], ['uid' => $lastid]); - } - } - if (!self::existsForeignKeyForField('tokens', 'client_id')) { $tokens = DBA::p("SELECT `tokens`.`id` FROM `tokens` LEFT JOIN `clients` ON `clients`.`client_id` = `tokens`.`client_id` diff --git a/static/dbstructure.config.php b/static/dbstructure.config.php index 65d7ce7817..cabb48c58f 100644 --- a/static/dbstructure.config.php +++ b/static/dbstructure.config.php @@ -20,6 +20,7 @@ * Main database structure configuration file. * * Here are described all the tables, fields and indexes Friendica needs to work. + * The entry order is mostly alphabetic - with the exception of tables that are used in foreign keys. * * Syntax (braces indicate optionale values): * "" => [