Changeset:
4b175e59a81b
https://sourceforge.net/p/mrbs/hg-code/ci/4b175e59a81b3726a8f5dc2bc21865dc7d3fe59b
Author:
Campbell Morrison <[email protected]>
Date:
Wed Apr 12 10:59:52 2017 +0100
Log message:
Fixed a problem with null values in the periods column (and at the same time
discovered that upgrade 50 had never been added).
diffstat:
tables.my.sql | 2 +-
tables.pg.sql | 2 +-
web/dbsys.inc | 2 +-
web/upgrade/50/mysql.sql | 5 +++++
web/upgrade/50/pgsql.sql | 4 ++++
web/upgrade/50/post.inc | 13 +++++++++++++
web/upgrade/51/mysql.sql | 1 +
web/upgrade/51/post.inc | 16 ++++++++++++++++
8 files changed, 42 insertions(+), 3 deletions(-)
diffs (94 lines):
diff -r 51691c542d73 -r 4b175e59a81b tables.my.sql
--- a/tables.my.sql Wed Apr 12 08:32:53 2017 +0100
+++ b/tables.my.sql Wed Apr 12 10:59:52 2017 +0100
@@ -190,6 +190,6 @@
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
INSERT INTO mrbs_variables (variable_name, variable_content)
- VALUES ( 'db_version', '50');
+ VALUES ( 'db_version', '51');
INSERT INTO mrbs_variables (variable_name, variable_content)
VALUES ( 'local_db_version', '1');
diff -r 51691c542d73 -r 4b175e59a81b tables.pg.sql
--- a/tables.pg.sql Wed Apr 12 08:32:53 2017 +0100
+++ b/tables.pg.sql Wed Apr 12 10:59:52 2017 +0100
@@ -182,6 +182,6 @@
);
INSERT INTO mrbs_variables (variable_name, variable_content)
- VALUES ('db_version', '50');
+ VALUES ('db_version', '51');
INSERT INTO mrbs_variables (variable_name, variable_content)
VALUES ('local_db_version', '1');
diff -r 51691c542d73 -r 4b175e59a81b web/dbsys.inc
--- a/web/dbsys.inc Wed Apr 12 08:32:53 2017 +0100
+++ b/web/dbsys.inc Wed Apr 12 10:59:52 2017 +0100
@@ -22,7 +22,7 @@
}
-$db_schema_version = 50;
+$db_schema_version = 51;
$local_db_schema_version = 1;
// Convenience wrapper function to provide access to a DB object for
diff -r 51691c542d73 -r 4b175e59a81b web/upgrade/50/mysql.sql
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/web/upgrade/50/mysql.sql Wed Apr 12 10:59:52 2017 +0100
@@ -0,0 +1,5 @@
+-- Add a field for the period names
+
+ALTER TABLE %DB_TBL_PREFIX%area
+ ADD COLUMN `periods` text CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT
NULL AFTER `enable_periods`;
+
\ No newline at end of file
diff -r 51691c542d73 -r 4b175e59a81b web/upgrade/50/pgsql.sql
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/web/upgrade/50/pgsql.sql Wed Apr 12 10:59:52 2017 +0100
@@ -0,0 +1,4 @@
+-- Add a field for the period names
+
+ALTER TABLE %DB_TBL_PREFIX%area
+ ADD COLUMN periods text DEFAULT NULL;
diff -r 51691c542d73 -r 4b175e59a81b web/upgrade/50/post.inc
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/web/upgrade/50/post.inc Wed Apr 12 10:59:52 2017 +0100
@@ -0,0 +1,13 @@
+<?php
+namespace MRBS;
+
+// Populate the new periods column in the area table with the default values
taken
+// from the config file.
+
+global $tbl_area;
+global $periods;
+global $admin_handle;
+
+$sql = "UPDATE $tbl_area SET periods = ?";
+
+$admin_handle->command($sql, array(json_encode($periods)));
diff -r 51691c542d73 -r 4b175e59a81b web/upgrade/51/mysql.sql
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/web/upgrade/51/mysql.sql Wed Apr 12 10:59:52 2017 +0100
@@ -0,0 +1,1 @@
+#
diff -r 51691c542d73 -r 4b175e59a81b web/upgrade/51/post.inc
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/web/upgrade/51/post.inc Wed Apr 12 10:59:52 2017 +0100
@@ -0,0 +1,16 @@
+<?php
+namespace MRBS;
+
+// Make sure that any null values for the periods column are replaced with
+// the config default. (It's possible that somebody working from the latest
+// default branch could have created a new area with a null value. That has
+// now been fixed, so won't happen again, but we need to clean up the area
+// table just in case).
+
+global $tbl_area;
+global $periods;
+global $admin_handle;
+
+$sql = "UPDATE $tbl_area SET periods = ? WHERE periods IS NULL";
+
+$admin_handle->command($sql, array(json_encode($periods)));
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Mrbs-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mrbs-commits