From 1175af37525fa75e5de18913d0c110f77604b9ff Mon Sep 17 00:00:00 2001
From: ByteHamster <ByteHamster@users.noreply.github.com>
Date: Sat, 15 Jul 2023 16:17:34 +0200
Subject: [PATCH] Fix difference in database scheme between MySQL and SQLite
 (#1190)

---
 Core/Frameworks/Baikal/Model/Calendar.php      | 18 ++++++++++--------
 .../Controller/Install/VersionUpgrade.php      |  5 +++++
 2 files changed, 15 insertions(+), 8 deletions(-)

diff --git a/Core/Frameworks/Baikal/Model/Calendar.php b/Core/Frameworks/Baikal/Model/Calendar.php
index 1a94671..d90af60 100644
--- a/Core/Frameworks/Baikal/Model/Calendar.php
+++ b/Core/Frameworks/Baikal/Model/Calendar.php
@@ -35,14 +35,16 @@ class Calendar extends \Flake\Core\Model\Db {
     const LABELFIELD = "displayname";
 
     protected $aData = [
-        "principaluri"  => "",
-        "displayname"   => "",
-        "uri"           => "",
-        "description"   => "",
-        "calendarorder" => 0,
-        "calendarcolor" => "",
-        "timezone"      => null,
-        "calendarid"    => 0,
+        "principaluri"       => "",
+        "displayname"        => "",
+        "uri"                => "",
+        "description"        => "",
+        "calendarorder"      => 0,
+        "calendarcolor"      => "",
+        "timezone"           => null,
+        "calendarid"         => 0,
+        "access"             => 1,
+        "share_invitestatus" => 2,
     ];
     protected $oCalendar; # Baikal\Model\Calendar\Calendar
 
diff --git a/Core/Frameworks/BaikalAdmin/Controller/Install/VersionUpgrade.php b/Core/Frameworks/BaikalAdmin/Controller/Install/VersionUpgrade.php
index bbc2266..92281a1 100644
--- a/Core/Frameworks/BaikalAdmin/Controller/Install/VersionUpgrade.php
+++ b/Core/Frameworks/BaikalAdmin/Controller/Install/VersionUpgrade.php
@@ -499,6 +499,11 @@ SQL
     );
             $this->aSuccess[] = 'Migrated calendars table';
         }
+        if (version_compare($sVersionFrom, '0.9.4', '<')) {
+            $pdo->exec("UPDATE calendarinstances SET access = 1 WHERE access IS NULL");
+            $pdo->exec("UPDATE calendarinstances SET share_invitestatus = 2 WHERE share_invitestatus IS NULL");
+            $this->aSuccess[] = 'Updated default values in calendarinstances table';
+        }
 
         $this->updateConfiguredVersion($sVersionTo);