Changeset:
18c071f63175
https://sourceforge.net/p/mrbs/hg-code/ci/18c071f631756aa7093e0e101ca7f2eef22233e6
Author:
Campbell Morrison <[email protected]>
Date:
Thu Oct 22 18:45:42 2015 +0100
Log message:
Fixed problems with upgrade 17 when using PostgreSQL (datetime data type)
diffstat:
web/upgrade/17/post.inc | 87 ++++++++----------------------------------------
1 files changed, 15 insertions(+), 72 deletions(-)
diffs (138 lines):
diff -r 1efcbb4bca6b -r 18c071f63175 web/upgrade/17/post.inc
--- a/web/upgrade/17/post.inc Thu Oct 22 18:44:42 2015 +0100
+++ b/web/upgrade/17/post.inc Thu Oct 22 18:45:42 2015 +0100
@@ -19,6 +19,9 @@
// This means that the existing status field has to be inverted (previously 1
or TRUE
// meant confirmed) and shifted one place to the left.
+// In these queries we set timestamp=timestamp to prevent it being
automatically set
+// to the current time (only applies to MySQL - PostgreSQL timestamps don't
update,
+// but we'll do it anyway)
// First of all update the entry table
@@ -31,24 +34,9 @@
fatal_error(1, get_vocab("failed_to_acquire"));
}
-$sql = "ALTER TABLE $tbl_entry ADD COLUMN saved_ts DATETIME";
-$res = sql_command($sql);
-if ($res == -1)
-{
- trigger_error(sql_error(), E_USER_WARNING);
- // No need to localise, should never happen
- print "<span class=\"error\">Failed to add saved_ts column in entry
table.</span>";
-}
-$sql = "UPDATE $tbl_entry SET saved_ts=timestamp";
-$res = sql_command($sql);
-if ($res == -1)
-{
- trigger_error(sql_error(), E_USER_WARNING);
- // No need to localise, should never happen
- print "<span class=\"error\">Failed to set saved_ts column in entry
table.</span>";
-}
-
-$sql = "UPDATE $tbl_entry SET status=(((~status)&1)<<1)|(private&1)";
+$sql = "UPDATE $tbl_entry
+ SET status=(((~status)&1)<<1)|(private&1),
+ timestamp=timestamp";
$res = sql_command($sql);
if ($res == -1)
{
@@ -57,23 +45,6 @@
print "<span class=\"error\">Failed to update status column in entry
table.</span>";
}
-$sql = "UPDATE $tbl_entry SET timestamp=saved_ts";
-$res = sql_command($sql);
-if ($res == -1)
-{
- trigger_error(sql_error(), E_USER_WARNING);
- // No need to localise, should never happen
- print "<span class=\"error\">Failed to update timestamp column in entry
table.</span>";
-}
-$sql = "ALTER TABLE $tbl_entry DROP COLUMN saved_ts";
-$res = sql_command($sql);
-if ($res == -1)
-{
- trigger_error(sql_error(), E_USER_WARNING);
- // No need to localise, should never happen
- print "<span class=\"error\">Failed to delete saved_ts column in entry
table.</span>";
-}
-
sql_mutex_unlock("$tbl_entry");
@@ -90,24 +61,9 @@
fatal_error(1, get_vocab("failed_to_acquire"));
}
-$sql = "ALTER TABLE $tbl_repeat ADD COLUMN saved_ts DATETIME";
-$res = sql_command($sql);
-if ($res == -1)
-{
- trigger_error(sql_error(), E_USER_WARNING);
- // No need to localise, should never happen
- print "<span class=\"error\">Failed to add saved_ts column in repeat
table.</span>";
-}
-$sql = "UPDATE $tbl_repeat SET saved_ts=timestamp";
-$res = sql_command($sql);
-if ($res == -1)
-{
- trigger_error(sql_error(), E_USER_WARNING);
- // No need to localise, should never happen
- print "<span class=\"error\">Failed to set saved_ts column in repeat
table.</span>";
-}
-
-$sql = "UPDATE $tbl_repeat SET status=private&1";
+$sql = "UPDATE $tbl_repeat
+ SET status=private&1,
+ timestamp=timestamp";
$res = sql_command($sql);
if ($res == -1)
@@ -121,7 +77,10 @@
// awaiting approval if any one of its individual members is awaiting approval.
// Find all the rows in the entry table that are members of a series and are
awaiting approval
-$sql = "SELECT DISTINCT repeat_id FROM $tbl_entry WHERE repeat_id!=0 AND
(status&" . STATUS_AWAITING_APPROVAL . " != 0)";
+$sql = "SELECT DISTINCT repeat_id
+ FROM $tbl_entry
+ WHERE repeat_id!=0
+ AND (status&" . STATUS_AWAITING_APPROVAL . " != 0)";
$res = sql_query($sql);
if ($res === FALSE)
{
@@ -133,7 +92,8 @@
{
// Set the approval status for each one
$sql = "UPDATE $tbl_repeat
- SET status=status|" . STATUS_AWAITING_APPROVAL . "
+ SET status=status|" . STATUS_AWAITING_APPROVAL . ",
+ timestamp=timestamp
WHERE id=" . $row['repeat_id'];
$result = sql_command($sql);
if ($result == -1)
@@ -149,22 +109,5 @@
}
}
-$sql = "UPDATE $tbl_repeat SET timestamp=saved_ts";
-$res = sql_command($sql);
-if ($res == -1)
-{
- trigger_error(sql_error(), E_USER_WARNING);
- // No need to localise, should never happen
- print "<span class=\"error\">Failed to update timestamp column in repeat
table.</span>";
-}
-$sql = "ALTER TABLE $tbl_repeat DROP COLUMN saved_ts";
-$res = sql_command($sql);
-if ($res == -1)
-{
- trigger_error(sql_error(), E_USER_WARNING);
- // No need to localise, should never happen
- print "<span class=\"error\">Failed to delete saved_ts column in repeat
table.</span>";
-}
-
sql_mutex_unlock("$tbl_repeat");
------------------------------------------------------------------------------
_______________________________________________
Mrbs-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mrbs-commits