Revision: 1753
          http://mrbs.svn.sourceforge.net/mrbs/?rev=1753&view=rev
Author:   jberanek
Date:     2011-01-26 16:04:51 +0000 (Wed, 26 Jan 2011)

Log Message:
-----------
* Updated the MySQL table installation SQL files to utilise
 MySQL 4.1 features. A version for older versions of MySQL is
 retained tables.my.pre41.sql.

* Added a warning when upgrading the database, to inform adninistrators
 that they may need to update their database to UTF-8 encoding, using
 the convert_db_to_utf8.php script.

* Updated the INSTALL and UPGRADE documentation to match the new
 Unicode-only behaviour of MRBS, and to mention the new MySQL installation
 SQL files.

* Improved the convert_db_to_utf8.php quite a bit. Updated the list of
 columns that need converting to UTF-8. Added support for converting the
 database collation in a MySQL MRBS database.

Modified Paths:
--------------
    mrbs/trunk/INSTALL
    mrbs/trunk/UPGRADE
    mrbs/trunk/convert_db_to_utf8.php
    mrbs/trunk/tables.my.sql
    mrbs/trunk/tables.pg.pre73.sql
    mrbs/trunk/tables.pg.sql
    mrbs/trunk/web/dbsys.inc

Added Paths:
-----------
    mrbs/trunk/tables.my.pre41.sql
    mrbs/trunk/web/upgrade/26/
    mrbs/trunk/web/upgrade/26/mysql.sql
    mrbs/trunk/web/upgrade/26/pgsql.sql
    mrbs/trunk/web/upgrade/26/post.inc

Modified: mrbs/trunk/INSTALL
===================================================================
--- mrbs/trunk/INSTALL  2011-01-26 12:37:51 UTC (rev 1752)
+++ mrbs/trunk/INSTALL  2011-01-26 16:04:51 UTC (rev 1753)
@@ -94,14 +94,14 @@
 
 Create the MRBS tables using the supplied tables.*.sql file:
 
-[MySQL]         $ mysql mrbs < tables.my.sql
-[PostgreSQL]    $ psql -a -f tables.pg.sql mrbs
+[MySQL]             $ mysql mrbs < tables.my.sql
+[MySQL < 4.1]       $ mysql mrbs < tables.my.pre41.sql
+[PostgreSQL]        $ psql -a -f tables.pg.sql mrbs
+[PostgreSQL < 7.3]  $ psql -a -f tables.pg.sql mrbs
 
 where "mrbs" is the name of your database (mentioned above).
 This will create all the needed tables.
 You may need to set rights on the tables; for PostgreSQL see "grant.pg.sql".
-If you use a PHP version less than 4.2, you will also need to replace the pgsql
-driver file pgsql.inc with pgsql.before_php42.inc, and rename it to pgsql.inc.
 If you need to delete the tables, for PostgreSQL see "destroy.pg.sql".
 
 The tables are now empty and ready for use. If you want to add a few sample
@@ -120,7 +120,7 @@
 If you are upgrading from MRBS 1.2-pre3 or later, your database will be
 upgraded automatically if necessary when you first run MRBS.   You will
 be prompted for a database (not MRBS) username and password with rights
-to create and alter tables.     Otherwise, please se the UPGRADE file.
+to create and alter tables.     Otherwise, please see the UPGRADE file.
 
 For a second installation or to use different table names:
 
@@ -412,11 +412,11 @@
 INTERNATIONALISATION
 ---------------------------------------------------------------------------
 
-From MRBS 1.4.7, MRBS is internationalised and uses UTF-8 throughout.
+From MRBS 1.4.6, MRBS is internationalised and uses UTF-8 throughout.
 MRBS will serve all of its pages in UTF-8 and stores everything in the
 database in UTF-8. This means that all languages work together.
 
-To use Unicode, php should be built with 'iconv' support ('--with-iconv'
+To use Unicode, PHP should be built with 'iconv' support ('--with-iconv'
 directive), or have the iconv extension installed and enabled. On Windows,
 if you are using PHP 5, iconv support is built-in.
 
@@ -431,7 +431,7 @@
   \%phpdir%\extensions\
 
 
-Note: Upgrading mysql database from previous charsets to Unicode :
+Note: Upgrading MySQL database from previous charsets to Unicode :
 
   You can use convert_db_to_utf8.php script to convert text in the
   database to UTF8. The administrator should copy this file into the web

Modified: mrbs/trunk/UPGRADE
===================================================================
--- mrbs/trunk/UPGRADE  2011-01-26 12:37:51 UTC (rev 1752)
+++ mrbs/trunk/UPGRADE  2011-01-26 16:04:51 UTC (rev 1753)
@@ -29,6 +29,30 @@
 
 Upgrading from prior MRBS 1.4.6
 ===============================
+
+If you were previously using MRBS with $unicode_encoding set to 0, when
+you upgrade to 1.4.6 you _MUST_ upgrade the MySQL database from the
+previously used character set to Unicode :
+
+         You need to use the convert_db_to_utf8.php script to convert text
+         in the database to UTF8. The administrator should copy the file
+          into the web directory, run it (choosing the encoding to convert
+          from) ONCE, and then move it back out of the web directory. We
+          recommend you backup your database before running this script if
+          you are at all worried.
+         Running it more than once will make a right mess of any non-ASCII 
+         text in the database. 
+
+          Additionally, this script can correct an MRBS database that used
+          to run on an old version of MySQL (earlier than 4.1), but that
+          now run on a newer version of MySQL. In this case, the database
+          contains UTF-8 text, but the tables are considered to be in some
+          other encoding by MySQL, generally Latin-1. The
+          convert_db_to_utf8.php detects this condition, and offers
+          the administrator the chance to correct the database 'collation'.
+
+===
+
 The following configuration variables are now deprecated.   Their use is
 supported for the moment but you should change your config file now to
 use the new variables as support for the old variables may be dropped in the

Modified: mrbs/trunk/convert_db_to_utf8.php
===================================================================
--- mrbs/trunk/convert_db_to_utf8.php   2011-01-26 12:37:51 UTC (rev 1752)
+++ mrbs/trunk/convert_db_to_utf8.php   2011-01-26 16:04:51 UTC (rev 1753)
@@ -7,9 +7,17 @@
 
 require_once "defaultincludes.inc";
 
+// Configuration for the database collation conversion code
+$printonly=false; //change this to false to alter on the fly
+$charset="utf8";
+$collate="utf8_general_ci";
+$altertablecharset=true;
+$alterdatabasecharset=true;
+
+
 $encoding = get_form_var('encoding', 'string');
 
-header("Content-Type: text/html; charset=\"utf-8\"");
+header('Content-Type: text/html; charset="utf-8"');
 
 ?>
 
@@ -24,21 +32,26 @@
 
 <?php
 
-
 if (!isset($encoding))
 {
-echo '
-
+?>
     <p>
-      This script will convert all the text in the database from a selected 
encoding to
-      UTF-8, to use with MRBS\'s new Unicode feature ($unicode_encoding in 
config.inc.php
-      set to 1).<br>
-      <b>NOTE: Only run this script <u>once</u>. Running it more than once will
-      make a right mess of any non-ASCII text in the database. I\'d recommend 
you
-      backup your database before running this script if you\'re at all 
worried.</b>
+      This script will convert all the text in the database from a selected
+      encoding to UTF-8, to use with MRBS's default encoding.
     </p>
+    <p>
+      If you are only running this script to change your MySQL
+      database's collation to UTF-8, and the data in your database is
+      already in UTF-8, you can specify the "from" encoding as UTF-8.
+    </p>
+    <p>
+      <b>NOTE: Only run this script <u>once</u>. Running it more than once
+      will make a right mess of any non-ASCII text in the database. I'd
+      recommend you backup your database before running this script if
+      you're at all worried.</b>
+    </p>
 
-    <form method="get" action="'.$PHP_SELF.'">
+    <form method="post" action="convert_db_to_utf8.php">
       Encoding to convert from:<br>
       <select name="encoding">
         <option value="iso-8859-1">Latin 1 
(English/French/German/Italian/Norwegian etc.)</option>
@@ -47,104 +60,352 @@
         <option value="iso-8859-15">Latin 9 (European)</option>
         <option value="Big-5">Big 5 (Chinese Traditional)</option>
         <option value="Shift-JIS">Shift-JIS (Japanese)</option>
+        <option value="utf-8">UTF-8 (No conversion)</option>
       </select>
+
+<?php
+  if ($dbsys == 'mysql' || $dbsys == 'mysqli')
+  {
+    $ver = sql_version();
+    // Sanitise the output to contain just the version number, hopefully
+    $ver = preg_replace('/[^0-9.]/', '', $ver);
+    // Pull out the floating point version number
+    sscanf($ver, "%f", $version);
+    if ($version >= 4.1)
+    {
+      $not_unicode = FALSE;
+      $res = sql_query("SHOW FULL COLUMNS FROM $tbl_entry");
+      for ($i = 0; ($row = sql_row_keyed($res, $i)); $i++)
+      {
+        if (!is_null($row['Collation']) &&
+            !preg_match('/utf8/', $row['Collation']))
+        {
+          $not_unicode = TRUE;
+        }
+      }
+      if ($not_unicode)
+      {
+?>
+      <div style="margin-top: 1em; padding: 0.5em; border: solid 2px; 
background-color: #FFF1A3">
+        Your database appears to be MySQL &gt;= 4.1 but the table/column
+        collations are not specified as UTF-8. You should tick the box
+        below to change the database collation<br>
+        <input type="checkbox" name="change_collation" value="1">
+        Change database collation to UTF-8
+      </div>
+
+<?php
+      } // end of if ($not_unicode)
+    } // end of if ($version >= 4.1)
+  } // end of if ($dbsys)
+?>
+      <div style="margin-top: 1em; padding: 0.5em; border: solid 2px; 
background-color: #75C7FF">
+        Optionally, you may specify an alternate database username and
+        password that has permissions to modify the MRBS table definitions.
+        If these are not specified the script will use your normal MRBS
+        database credentials:<br>
+        Database admin username: <input type="text" name="admin_username"><br>
+        Database admin password: <input type="password" 
name="admin_password"><br>
+      </div>
       <br>
       <input type="submit" value="Do it">
     </form>
-';
+
+<?php
 }
 else
 {
+  # A 2D array listing the columns that need to be converted to UTF-8
+  $update_columns = array
+  (
+    $tbl_area => array('area_name', 'custom_html'),
+    $tbl_room => array('room_name', 'description', 'room_admin_email',
+                       'custom_html'),
+    $tbl_entry => array('create_by', 'name', 'description', 'info_user',
+                        'info_text'),
+    $tbl_repeat => array('create_by', 'name', 'description', 'info_user',
+                         'info_text'),
+    $tbl_users => array('name', 'password', 'email')
+  );
+
+  $admin_username = get_form_var('admin_username', 'string');
+  $admin_password = get_form_var('admin_password', 'string');
+  $change_collation = get_form_var('change_collation', 'int');
+  if (is_null($change_collation))
+  {
+    $change_collation = 0;
+  }
+
+  if (is_null($admin_username) || ($admin_username == ''))
+  {
+    $admin_username = $db_login;
+    $admin_password = $db_password;
+  }
+  $db_handle = sql_connect($dbsys, $db_host,
+                           $admin_username, $admin_password, $db_database);
   echo '
     <p>
       Starting update, this could take a while...
     </p>
 
-    <p>
-      Updating areas:
 ';
 
-  $sql = "SELECT id,area_name FROM mrbs_area";
-  $areas_res = sql_query($sql);
-
-  for ($i = 0; ($row = sql_row($areas_res, $i)); $i++)
+  if ($encoding != 'utf-8')
   {
-    $id = $row[0];
-    $name = addslashes(iconv($encoding,"utf-8",$row[1]));
+    foreach ($update_columns as $table => $columns)
+    {
+      print "
+    <p>
+      Updating '$table' table...
+";
+      $sql = "SELECT id,".implode(',',$columns)." FROM $table";
+      $res = sql_query($sql, $db_handle);
 
-    $upd_sql = "UPDATE mrbs_area SET area_name='$name' WHERE id=$id";
-    sql_query($upd_sql);
+      for ($i = 0; ($row = sql_row_keyed($res, $i)); $i++)
+      {
+        $updates = array();
+        $id = $row['id'];
+        foreach ($columns as $col)
+        {
+          $updates[] = "$col='".
+            addslashes(iconv($encoding,"utf-8",$row[$col]))."'";
+        }
+        $upd_sql = "UPDATE $table SET ".
+          implode(',', $updates)." WHERE id=$id";
 
-    echo ".";
+        sql_query($upd_sql, $db_handle);
+        print "<!-- $upd_sql -->\n";
+      }
+      print "
+      done.
+    </p>
+";
+    } // end of foreach
   }
-  echo " done.<br>Updating rooms: ";
+  else
+  {
+    print '
+    <p style="color: #2f80b5">
+      Skipping text conversion, as UTF-8 was specified.
+    </p>
+';
+  } // end of if ($encoding)
 
-  $sql = "SELECT id,room_name,description,capacity FROM mrbs_room";
-  $rooms_res = sql_query($sql);
-
-  for ($i = 0; ($row = sql_row($rooms_res, $i)); $i++)
+  if ($change_collation)
   {
-    $id = $row[0];
-    $name = addslashes(iconv($encoding,"utf-8",$row[1]));
-    $desc = addslashes(iconv($encoding,"utf-8",$row[2]));
-    $capa = addslashes(iconv($encoding,"utf-8",$row[3]));
+    print '
+    <p>
+      Converting your database\'s collation to UTF-8...
+    </p>
+';
+    convert_one_db($db_database);
+  } // end of if ($change_collation)
 
-    $upd_sql = "UPDATE mrbs_room SET 
room_name='$name',description='$desc',capacity='$capa' WHERE id=$id";
-    sql_command($upd_sql);
+  echo '
+    <p>
+      Database conversion finished.
+    </p>
+';
+} // end of if (!isset($encoding))
+?>
+  </body>
+</html>
 
-    echo ".";
-  }
-  echo " done.<br>Updating repeating entries: ";
+<?php
 
-  $sql = "SELECT id,name,description FROM mrbs_repeat";
-  $repeats_res = sql_query($sql);
+// Code adapted from a script found on the web written by
+// Shimon Doodkin [email protected]
 
-  for ($i = 0; ($row = sql_row($repeats_res, $i)); $i++)
+function PMA_getDbCollation($db)
+{
+  global $db_handle;
+
+  $sq='SHOW CREATE DATABASE `'.$db.'`;';
+  $res = sql_query($sq, $db_handle);
+  if(!$res)
   {
-    $id = $row[0];
-    $name = addslashes(iconv($encoding,"utf-8",$row[1]));
-    $desc = addslashes(iconv($encoding,"utf-8",$row[2]));
+    echo "\n\n".$sq."\n".sql_error($db_handle)."\n\n";
+  }
+  else
+  {
+    for ($i = 0; ($row = sql_row_keyed($res, $i, $db_handle)); $i++)
+    {
+      $tokenized = explode(' ', $row[1]);
 
-    $upd_sql = "UPDATE mrbs_repeat SET name='$name',description='$desc' WHERE 
id=$id";
-    sql_command($upd_sql);
+      for ($i = 1; $i + 3 < count($tokenized); $i++)
+      {
+        if (($tokenized[$i] == 'DEFAULT') &&
+            ($tokenized[$i + 1] == 'CHARACTER') &&
+            ($tokenized[$i + 2] == 'SET'))
+        {
+          if (isset($tokenized[$i + 5]) &&
+              ($tokenized[$i + 4] == 'COLLATE'))
+          {
+            return array($tokenized [$i + 3],
+                         $tokenized[$i + 5]); // We found the collation!
+          }
+          else
+          {
+            return array($tokenized [$i + 3]);
+          }
+        }
+      }
+    }
+  }
+  return '';
+}
 
-    echo ".";
+//
+function convert_one_db($db)
+{
+  global $alterdatabasecharset;
+  global $altertablecharset;
+  global $charset;
+  global $collate;
+  global $printonly;
+  global $db_handle;
+
+  $db_cha = PMA_getDbCollation($db);
+
+  if ( substr($db_cha[0],0,4) == 'utf8' ) // only convert unconverted db
+  {
+    // This doesn't work for me, but isn't a big deal, as the table
+    // check below works
+    echo "Skipping utf8 database '$db'\n";
+    return;
   }
-  echo " done.<br>Updating normal entries: ";
 
-  $sql = "SELECT id,name,description FROM mrbs_entry";
-  $entries_res = sql_query($sql);
+  sql_command("USE $db", $db_handle);
+  $rs = sql_query("SHOW TABLES", $db_handle);
+  if(!$rs)
+  {
+    echo "\n\n".sql_error($db_handle)."\n\n";
+  }
+  else
+  {
+    for ($i = 0; ($data = sql_row($rs, $i, $db_handle)); $i++)
+    {
+      echo "Converting '$data[0]' table...\n";
+      $rs1 = sql_query("show FULL columns from $data[0]", $db_handle);
+      if(!$rs1)
+      {
+        echo "\n\n".sql_error($db_handle)."\n\n";
+      }
+      else
+      {
+        for ($j = 0; ($data1 = sql_row_keyed($rs1, $j, $db_handle)); $j++)
+        {
+          if (in_array(array_shift(split("\\(",
+                                         $data1['Type'],2)),
+                       array(
+                             //'national char',
+                             //'nchar',
+                             //'national varchar',
+                             //'nvarchar',
+                             'char',
+                             'varchar',
+                             'tinytext',
+                             'text',
+                             'mediumtext',
+                             'longtext',
+                             'enum',
+                             'set'
+                            )
+                ))
+          {
+            if (substr($data1['Collation'],0,4) != 'utf8') // limit to charset
+            {
+              $sq="ALTER TABLE `$data[0]` CHANGE `".
+                $data1['Field'].'` `'.$data1['Field'].'` '.
+                $data1['Type'].' CHARACTER SET binary '.
+                (($data1['Default'] == '') ?
+                 '' :
+                 (($data1['Default'] == 'NULL') ?
+                  ' DEFAULT NULL' :
+                  ' DEFAULT \''.addslashes($data1['Default']).'\'')).
+                (($data1['Null'] == 'YES') ? ' NULL ' : ' NOT NULL');
 
-  for ($i = 0; ($row = sql_row($entries_res, $i)); $i++)
+              if (!$printonly &&
+                  !sql_query($sq, $db_handle))
+              {
+                echo "\n\n".$sq."\n".sql_error($db_handle)."\n\n";
+              }
+              else
+              {
+                if ($printonly)
+                {
+                  echo ($sq."\n") ;
+                }
+                $sq="ALTER TABLE `$data[0]` CHANGE `".
+                  $data1['Field'].'` `'.$data1['Field'].'` '.
+                  $data1['Type']." CHARACTER SET $charset ".
+                  (($collate == '') ? '' : "COLLATE $collate").
+                  (($data1['Default'] == '') ?
+                   '' :
+                   (($data1['Default'] == 'NULL') ?
+                    ' DEFAULT NULL' :
+                    ' DEFAULT \''.addslashes($data1['Default']).'\'')).
+                  (($data1['Null'] == 'YES') ?
+                   ' NULL ' :
+                   ' NOT NULL').
+                  (($data1['Comment'] == '') ?
+                    '' :
+                    ' COMMENT \''.addslashes($data1['Comment']).'\'');
+
+                if (!$printonly &&
+                    !sql_query($sq, $db_handle))
+                {
+                  echo "\n\n".$sq."\n".sql_error($db_handle)."\n\n";
+                }
+                else if ($printonly)
+                {
+                  echo ($sq."\n") ;
+                }
+              } // end of if (!$printonly)
+            } // end of if (substr)
+          } // end of if (in_array)
+        } // end of inner for
+      } // end of if ($rs1)
+
+      if ($altertablecharset)
+      {
+        $sq='ALTER TABLE `'.$data[0]."` ".
+          "DEFAULT CHARACTER SET $charset ".
+          (($collate == '') ? '' : "COLLATE $collate");
+
+        if ($printonly)
+        {
+          echo ($sq."\n") ;
+        }
+        else
+        {
+          if (!sql_query($sq, $db_handle))
+          {
+            echo "\n\n".$sq."\n".sql_error($db_handle)."\n\n";
+          }
+        }
+      } // end of if ($altertablecharset)
+         print "done.<br>\n";
+    } // end of outer for
+  } // end of if (!$rs)
+  if ($alterdatabasecharset)
   {
-    $id = $row[0];
-    $name = addslashes(iconv($encoding,"utf-8",$row[1]));
-    $desc = addslashes(iconv($encoding,"utf-8",$row[2]));
+    $sq='ALTER DATABASE `'.$db."` ".
+      "DEFAULT CHARACTER SET $charset ".
+      (($collate == '') ? '' : "COLLATE $collate");
 
-    $upd_sql = "UPDATE mrbs_entry SET name='$name',description='$desc' WHERE 
id=$id";
-    sql_command($upd_sql);
+    if ($printonly)
+    {
+      echo ($sq."\n") ;
+    }
+    else
+    {
+      if (!sql_query($sq, $db_handle))
+      {
+        echo "\n\n".$sq."\n".sql_error($db_handle)."\n\n";
+      }
+    }
+  } // end of if ($alterdatabasecharset)
+} // end of function convert_one_db()
 
-    echo ".";
-  }
-  echo '
-      done.
-    </p>
-
-    <p>
-      Finished everything that I can do.
-    </p>
-    
-    <p>
-      If you are using MySQL >= 4 you may still you need to modify
-      the database charset for textual columns. e.g.:
-    </p>
-    <pre>
-ALTER TABLE mrbs_area
-CHANGE area_name VARCHAR(30) CHARACTER SET utf8 COLLATE utf8_general_ci 
DEFAULT NULL
-</pre>
-';
-}
 ?>
-  </body>
-</html>
- 
\ No newline at end of file

Added: mrbs/trunk/tables.my.pre41.sql
===================================================================
--- mrbs/trunk/tables.my.pre41.sql                              (rev 0)
+++ mrbs/trunk/tables.my.pre41.sql      2011-01-26 16:04:51 UTC (rev 1753)
@@ -0,0 +1,143 @@
+#
+# MySQL MRBS table creation script
+#
+# $Id$
+#
+# Notes:
+# (1) If you have decided to change the prefix of your tables from 'mrbs_'
+#     to something else using $db_tbl_prefix then you must edit each
+#     'CREATE TABLE' and 'INSERT INTO' line below to replace 'mrbs_' with
+#     your new table prefix.
+#
+# (2) If you change the varchar lengths here, then you should check
+#     to see whether a corresponding length has been defined in the config file
+#     in the array $maxlength.
+#
+# (3) If you add new fields then you should also change the global variable
+#     $standard_fields.   Note that if you are just adding custom fields for
+#     a single site then this is not necessary.
+
+CREATE TABLE mrbs_area
+(
+  id                     int NOT NULL auto_increment,
+  disabled               tinyint(1) DEFAULT 0 NOT NULL,
+  area_name              varchar(30),
+  area_admin_email       text,
+  resolution             int,
+  default_duration       int,
+  morningstarts          int,
+  morningstarts_minutes  int,
+  eveningends            int,
+  eveningends_minutes    int,
+  private_enabled        tinyint(1),
+  private_default        tinyint(1),
+  private_mandatory      tinyint(1),
+  private_override       varchar(32),
+  min_book_ahead_enabled tinyint(1),
+  min_book_ahead_secs    int,
+  max_book_ahead_enabled tinyint(1),
+  max_book_ahead_secs    int,
+  custom_html            text,
+  approval_enabled       tinyint(1),
+  reminders_enabled      tinyint(1),
+  enable_periods         tinyint(1),
+  confirmation_enabled   tinyint(1),
+  confirmed_default      tinyint(1),
+
+  PRIMARY KEY (id)
+);
+
+CREATE TABLE mrbs_room
+(
+  id               int NOT NULL auto_increment,
+  disabled         tinyint(1) DEFAULT 0 NOT NULL,
+  area_id          int DEFAULT '0' NOT NULL,
+  room_name        varchar(25) DEFAULT '' NOT NULL,
+  sort_key         varchar(25) DEFAULT '' NOT NULL,
+  description      varchar(60),
+  capacity         int DEFAULT '0' NOT NULL,
+  room_admin_email text,
+  custom_html      text,
+
+  PRIMARY KEY (id),
+  KEY idxSortKey (sort_key)
+);
+
+CREATE TABLE mrbs_entry
+(
+  id             int NOT NULL auto_increment,
+  start_time     int DEFAULT '0' NOT NULL,
+  end_time       int DEFAULT '0' NOT NULL,
+  entry_type     int DEFAULT '0' NOT NULL,
+  repeat_id      int DEFAULT '0' NOT NULL,
+  room_id        int DEFAULT '1' NOT NULL,
+  timestamp      timestamp,
+  create_by      varchar(80) DEFAULT '' NOT NULL,
+  name           varchar(80) DEFAULT '' NOT NULL,
+  type           char DEFAULT 'E' NOT NULL,
+  description    text,
+  status         tinyint unsigned NOT NULL DEFAULT 0,
+  reminded       int,
+  info_time      int,
+  info_user      varchar(80),
+  info_text      text,
+  ical_uid       varchar(255) DEFAULT '' NOT NULL,
+  ical_sequence  smallint DEFAULT 0 NOT NULL,
+  ical_recur_id  varchar(16) DEFAULT '' NOT NULL,
+
+  PRIMARY KEY (id),
+  KEY idxStartTime (start_time),
+  KEY idxEndTime   (end_time)
+);
+
+CREATE TABLE mrbs_repeat
+(
+  id             int NOT NULL auto_increment,
+  start_time     int DEFAULT '0' NOT NULL,
+  end_time       int DEFAULT '0' NOT NULL,
+  rep_type       int DEFAULT '0' NOT NULL,
+  end_date       int DEFAULT '0' NOT NULL,
+  rep_opt        varchar(32) DEFAULT '' NOT NULL,
+  room_id        int DEFAULT '1' NOT NULL,
+  timestamp      timestamp,
+  create_by      varchar(80) DEFAULT '' NOT NULL,
+  name           varchar(80) DEFAULT '' NOT NULL,
+  type           char DEFAULT 'E' NOT NULL,
+  description    text,
+  rep_num_weeks  smallint NULL, 
+  status         tinyint unsigned NOT NULL DEFAULT 0,
+  reminded       int,
+  info_time      int,
+  info_user      varchar(80),
+  info_text      text,
+  ical_uid       varchar(255) DEFAULT '' NOT NULL,
+  ical_sequence  smallint DEFAULT 0 NOT NULL,
+  
+  PRIMARY KEY (id)
+);
+
+CREATE TABLE mrbs_variables
+(
+  id               int NOT NULL auto_increment,
+  variable_name    varchar(80),
+  variable_content text,
+      
+  PRIMARY KEY (id)
+);
+
+CREATE TABLE mrbs_users
+(
+  /* The first four fields are required. Don't remove. */
+  id        int NOT NULL auto_increment,
+  level     smallint DEFAULT '0' NOT NULL,  /* play safe and give no rights */
+  name      varchar(30),
+  password  varchar(40),
+  email     varchar(75),
+
+  PRIMARY KEY (id)
+);
+
+INSERT INTO mrbs_variables (variable_name, variable_content)
+  VALUES ( 'db_version', '26');
+INSERT INTO mrbs_variables (variable_name, variable_content)
+  VALUES ( 'local_db_version', '1');


Property changes on: mrbs/trunk/tables.my.pre41.sql
___________________________________________________________________
Added: svn:mime-type
   + text/x-sql
Added: svn:keywords
   + Id
Added: svn:eol-style
   + native

Modified: mrbs/trunk/tables.my.sql
===================================================================
--- mrbs/trunk/tables.my.sql    2011-01-26 12:37:51 UTC (rev 1752)
+++ mrbs/trunk/tables.my.sql    2011-01-26 16:04:51 UTC (rev 1753)
@@ -21,8 +21,8 @@
 (
   id                     int NOT NULL auto_increment,
   disabled               tinyint(1) DEFAULT 0 NOT NULL,
-  area_name              varchar(30),
-  area_admin_email       text,
+  area_name              varchar(30) CHARACTER SET utf8 COLLATE 
utf8_general_ci,
+  area_admin_email       text CHARACTER SET utf8 COLLATE utf8_general_ci,
   resolution             int,
   default_duration       int,
   morningstarts          int,
@@ -32,12 +32,12 @@
   private_enabled        tinyint(1),
   private_default        tinyint(1),
   private_mandatory      tinyint(1),
-  private_override       varchar(32),
+  private_override       varchar(32) CHARACTER SET utf8 COLLATE 
utf8_general_ci,
   min_book_ahead_enabled tinyint(1),
   min_book_ahead_secs    int,
   max_book_ahead_enabled tinyint(1),
   max_book_ahead_secs    int,
-  custom_html            text,
+  custom_html            text CHARACTER SET utf8 COLLATE utf8_general_ci,
   approval_enabled       tinyint(1),
   reminders_enabled      tinyint(1),
   enable_periods         tinyint(1),
@@ -45,23 +45,23 @@
   confirmed_default      tinyint(1),
 
   PRIMARY KEY (id)
-);
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
 
 CREATE TABLE mrbs_room
 (
   id               int NOT NULL auto_increment,
   disabled         tinyint(1) DEFAULT 0 NOT NULL,
   area_id          int DEFAULT '0' NOT NULL,
-  room_name        varchar(25) DEFAULT '' NOT NULL,
-  sort_key         varchar(25) DEFAULT '' NOT NULL,
-  description      varchar(60),
+  room_name        varchar(25) CHARACTER SET utf8 COLLATE utf8_general_ci 
DEFAULT '' NOT NULL,
+  sort_key         varchar(25) CHARACTER SET utf8 COLLATE utf8_general_ci 
DEFAULT '' NOT NULL,
+  description      varchar(60) CHARACTER SET utf8 COLLATE utf8_general_ci,
   capacity         int DEFAULT '0' NOT NULL,
-  room_admin_email text,
-  custom_html      text,
+  room_admin_email text CHARACTER SET utf8 COLLATE utf8_general_ci,
+  custom_html      text CHARACTER SET utf8 COLLATE utf8_general_ci,
 
   PRIMARY KEY (id),
   KEY idxSortKey (sort_key)
-);
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
 
 CREATE TABLE mrbs_entry
 (
@@ -72,23 +72,23 @@
   repeat_id      int DEFAULT '0' NOT NULL,
   room_id        int DEFAULT '1' NOT NULL,
   timestamp      timestamp,
-  create_by      varchar(80) DEFAULT '' NOT NULL,
-  name           varchar(80) DEFAULT '' NOT NULL,
+  create_by      varchar(80) CHARACTER SET utf8 COLLATE utf8_general_ci 
DEFAULT '' NOT NULL,
+  name           varchar(80) CHARACTER SET utf8 COLLATE utf8_general_ci 
DEFAULT '' NOT NULL,
   type           char DEFAULT 'E' NOT NULL,
-  description    text,
+  description    text CHARACTER SET utf8 COLLATE utf8_general_ci,
   status         tinyint unsigned NOT NULL DEFAULT 0,
   reminded       int,
   info_time      int,
-  info_user      varchar(80),
-  info_text      text,
-  ical_uid       varchar(255) DEFAULT '' NOT NULL,
+  info_user      varchar(80) CHARACTER SET utf8 COLLATE utf8_general_ci,
+  info_text      text CHARACTER SET utf8 COLLATE utf8_general_ci,
+  ical_uid       varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci 
DEFAULT '' NOT NULL,
   ical_sequence  smallint DEFAULT 0 NOT NULL,
-  ical_recur_id  varchar(16) DEFAULT '' NOT NULL,
+  ical_recur_id  varchar(16) CHARACTER SET utf8 COLLATE utf8_general_ci 
DEFAULT '' NOT NULL,
 
   PRIMARY KEY (id),
   KEY idxStartTime (start_time),
   KEY idxEndTime   (end_time)
-);
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
 
 CREATE TABLE mrbs_repeat
 (
@@ -97,47 +97,47 @@
   end_time       int DEFAULT '0' NOT NULL,
   rep_type       int DEFAULT '0' NOT NULL,
   end_date       int DEFAULT '0' NOT NULL,
-  rep_opt        varchar(32) DEFAULT '' NOT NULL,
+  rep_opt        varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci 
DEFAULT '' NOT NULL,
   room_id        int DEFAULT '1' NOT NULL,
   timestamp      timestamp,
-  create_by      varchar(80) DEFAULT '' NOT NULL,
-  name           varchar(80) DEFAULT '' NOT NULL,
+  create_by      varchar(80) CHARACTER SET utf8 COLLATE utf8_general_ci 
DEFAULT '' NOT NULL,
+  name           varchar(80) CHARACTER SET utf8 COLLATE utf8_general_ci 
DEFAULT '' NOT NULL,
   type           char DEFAULT 'E' NOT NULL,
-  description    text,
+  description    text CHARACTER SET utf8 COLLATE utf8_general_ci,
   rep_num_weeks  smallint NULL, 
   status         tinyint unsigned NOT NULL DEFAULT 0,
   reminded       int,
   info_time      int,
-  info_user      varchar(80),
-  info_text      text,
-  ical_uid       varchar(255) DEFAULT '' NOT NULL,
+  info_user      varchar(80) CHARACTER SET utf8 COLLATE utf8_general_ci,
+  info_text      text CHARACTER SET utf8 COLLATE utf8_general_ci,
+  ical_uid       varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci 
DEFAULT '' NOT NULL,
   ical_sequence  smallint DEFAULT 0 NOT NULL,
   
   PRIMARY KEY (id)
-);
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
 
 CREATE TABLE mrbs_variables
 (
   id               int NOT NULL auto_increment,
-  variable_name    varchar(80),
-  variable_content text,
+  variable_name    varchar(80) CHARACTER SET utf8 COLLATE utf8_general_ci,
+  variable_content text CHARACTER SET utf8 COLLATE utf8_general_ci,
       
   PRIMARY KEY (id)
-);
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
 
 CREATE TABLE mrbs_users
 (
   /* The first four fields are required. Don't remove. */
   id        int NOT NULL auto_increment,
   level     smallint DEFAULT '0' NOT NULL,  /* play safe and give no rights */
-  name      varchar(30),
-  password  varchar(40),
-  email     varchar(75),
+  name      varchar(30) CHARACTER SET utf8 COLLATE utf8_general_ci,
+  password  varchar(40) CHARACTER SET utf8 COLLATE utf8_general_ci,
+  email     varchar(75) CHARACTER SET utf8 COLLATE utf8_general_ci,
 
   PRIMARY KEY (id)
-);
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
 
 INSERT INTO mrbs_variables (variable_name, variable_content)
-  VALUES ( 'db_version', '25');
+  VALUES ( 'db_version', '26');
 INSERT INTO mrbs_variables (variable_name, variable_content)
   VALUES ( 'local_db_version', '1');

Modified: mrbs/trunk/tables.pg.pre73.sql
===================================================================
--- mrbs/trunk/tables.pg.pre73.sql      2011-01-26 12:37:51 UTC (rev 1752)
+++ mrbs/trunk/tables.pg.pre73.sql      2011-01-26 16:04:51 UTC (rev 1753)
@@ -129,6 +129,6 @@
 );
 
 INSERT INTO mrbs_variables (variable_name, variable_content)
-  VALUES ('db_version', '25');
+  VALUES ('db_version', '26');
 INSERT INTO mrbs_variables (variable_name, variable_content)
   VALUES ('local_db_version', '1');

Modified: mrbs/trunk/tables.pg.sql
===================================================================
--- mrbs/trunk/tables.pg.sql    2011-01-26 12:37:51 UTC (rev 1752)
+++ mrbs/trunk/tables.pg.sql    2011-01-26 16:04:51 UTC (rev 1753)
@@ -142,6 +142,6 @@
 );
 
 INSERT INTO mrbs_variables (variable_name, variable_content)
-  VALUES ('db_version', '25');
+  VALUES ('db_version', '26');
 INSERT INTO mrbs_variables (variable_name, variable_content)
   VALUES ('local_db_version', '1');

Modified: mrbs/trunk/web/dbsys.inc
===================================================================
--- mrbs/trunk/web/dbsys.inc    2011-01-26 12:37:51 UTC (rev 1752)
+++ mrbs/trunk/web/dbsys.inc    2011-01-26 16:04:51 UTC (rev 1753)
@@ -15,7 +15,7 @@
 $tbl_variables = $db_tbl_prefix . "variables";
 
 
-$db_schema_version = 25;
+$db_schema_version = 26;
 $local_db_schema_version = 1;
 
 

Added: mrbs/trunk/web/upgrade/26/mysql.sql
===================================================================
--- mrbs/trunk/web/upgrade/26/mysql.sql                         (rev 0)
+++ mrbs/trunk/web/upgrade/26/mysql.sql 2011-01-26 16:04:51 UTC (rev 1753)
@@ -0,0 +1 @@
+# $Id$


Property changes on: mrbs/trunk/web/upgrade/26/mysql.sql
___________________________________________________________________
Added: svn:keywords
   + Id
Added: svn:eol-style
   + native


Property changes on: mrbs/trunk/web/upgrade/26/pgsql.sql
___________________________________________________________________
Added: svn:keywords
   + Id
Added: svn:eol-style
   + native

Added: mrbs/trunk/web/upgrade/26/post.inc
===================================================================
--- mrbs/trunk/web/upgrade/26/post.inc                          (rev 0)
+++ mrbs/trunk/web/upgrade/26/post.inc  2011-01-26 16:04:51 UTC (rev 1753)
@@ -0,0 +1,10 @@
+<?php
+
+// $Id$
+?>
+
+<script type="text/javascript">
+//<![CDATA[
+  alert('If you have just upgraded to MRBS 1.4.6 and had previously configured 
MRBS with $unicode_encoding = 0, you MUST read and follow the instructions in 
UPGRADE to convert your database to UTF-8');
+//]];
+</script>


Property changes on: mrbs/trunk/web/upgrade/26/post.inc
___________________________________________________________________
Added: svn:mime-type
   + text/x-php
Added: svn:keywords
   + Id
Added: svn:eol-style
   + native


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

------------------------------------------------------------------------------
Special Offer-- Download ArcSight Logger for FREE (a $49 USD value)!
Finally, a world-class log management solution at an even better price-free!
Download using promo code Free_Logger_4_Dev2Dev. Offer expires 
February 28th, so secure your free ArcSight Logger TODAY! 
http://p.sf.net/sfu/arcsight-sfd2d
_______________________________________________
Mrbs-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mrbs-commits

Reply via email to