From 5d13b6a1676dbeb867aba62b977f90b35329d08a Mon Sep 17 00:00:00 2001 From: Matias De lellis Date: Fri, 27 May 2016 11:28:31 -0300 Subject: [PATCH] Fix database schema migration --- appinfo/info.xml | 2 +- appinfo/update.php | 24 ++++++++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 appinfo/update.php diff --git a/appinfo/info.xml b/appinfo/info.xml index 7adfc92..fac68c1 100644 --- a/appinfo/info.xml +++ b/appinfo/info.xml @@ -5,7 +5,7 @@ Quick notes with text, check lists and pictures AGPL Matias De lellis - 0.0.6 + 0.0.8 QuickNotes tool https://github.com/matiasdelellis diff --git a/appinfo/update.php b/appinfo/update.php new file mode 100644 index 0000000..64f14c4 --- /dev/null +++ b/appinfo/update.php @@ -0,0 +1,24 @@ + + * @copyright Matias De lellis 2016 + */ + +$installedVersion = \OCP\Config::getAppValue('quicknotes', 'installed_version'); + +if (version_compare($installedVersion, '0.0.8', '<')) { + $sqls = array( + "INSERT INTO `*PREFIX*quicknotes_colors` (color) VALUES ('#F7EB98');", // Other color the default no handle easy duplicate colors.. + "UPDATE `*PREFIX*quicknotes_notes` SET color_id = (SELECT DISTINCT id FROM `*PREFIX*quicknotes_colors` WHERE color = '#F7EB98');" + ); + foreach ($sqls as $sql) { + $query = \OCP\DB::prepare($sql); + $query->execute(); + } +} +