From 1f1de386b09e48a02fccd62aa82ff319533969cc Mon Sep 17 00:00:00 2001
From: Thomas Lange <code@nerdmind.de>
Date: Sun, 21 May 2017 07:37:58 +0200
Subject: Bugfixes: There were two problems with the internal sorting of items
 which have been fixed. This results in version 2.1.2 (database update
 recommended):

+ Bugfix [core]: If the insertion date of a newly created item has been placed to a datetime in the past after which other items have already appeared, the sorting of the forward and backward functionality has been interrupted because the WHERE clause in the database query had the condition that the next item must have a higher ID and the previous item must have a lower ID than the current one. If this newly created item was the last one and the insertion date had been placed to a datetime in the past, no next item could be fetched because THIS is already the item with the highest ID and the correct sorting by time_insert for this item has stopped working.

+ Bugfix [core]: If one or more items had exactly the same insertion time, the items with the exact same time has been appeard within the overview list in an order which did not correspond to the insertion sequence. There were several ways to fix this problem, but this would result in more complicated database queries and more code. To fix the problem in the simplest way, the column "time_insert" now has a UNIQUE index to prevent two or more items from having the exactly same insertion time.

Database update to version 2.1.2 (no existing data will be lost or changed):

ALTER TABLE `page` ADD UNIQUE KEY `time_insert` (`time_insert`);
ALTER TABLE `post` ADD UNIQUE KEY `time_insert` (`time_insert`);
ALTER TABLE `user` ADD UNIQUE KEY `time_insert` (`time_insert`);
---
 database.sql | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

(limited to 'database.sql')

diff --git a/database.sql b/database.sql
index d85089a..9669280 100644
--- a/database.sql
+++ b/database.sql
@@ -55,10 +55,10 @@ INSERT INTO `user` (`id`, `time_insert`, `time_update`, `slug`, `username`, `pas
 -- =============================================================================
 -- Add keys for tables
 -- =============================================================================
-ALTER TABLE `page` ADD PRIMARY KEY (`id`), ADD UNIQUE KEY `slug` (`slug`), ADD KEY `page_user` (`user`);
-ALTER TABLE `post` ADD PRIMARY KEY (`id`), ADD UNIQUE KEY `slug` (`slug`), ADD KEY `post_user` (`user`);
+ALTER TABLE `page` ADD PRIMARY KEY (`id`), ADD UNIQUE KEY `time_insert` (`time_insert`), ADD UNIQUE KEY `slug` (`slug`), ADD KEY `page_user` (`user`);
+ALTER TABLE `post` ADD PRIMARY KEY (`id`), ADD UNIQUE KEY `time_insert` (`time_insert`), ADD UNIQUE KEY `slug` (`slug`), ADD KEY `post_user` (`user`);
 ALTER TABLE `post` ADD FULLTEXT KEY `body` (`body`);
-ALTER TABLE `user` ADD PRIMARY KEY (`id`), ADD UNIQUE KEY `username` (`username`), ADD UNIQUE KEY `slug` (`slug`);
+ALTER TABLE `user` ADD PRIMARY KEY (`id`), ADD UNIQUE KEY `time_insert` (`time_insert`), ADD UNIQUE KEY `username` (`username`), ADD UNIQUE KEY `slug` (`slug`);
 
 -- =============================================================================
 -- Add AUTO_INCREMENT for tables
-- 
cgit v1.2.3

