make it work with latest update script

This commit is contained in:
Uwe Steinmann 2013-02-20 09:44:20 +01:00
parent f1617e7d1a
commit a3f9b1d672
6 changed files with 41 additions and 9 deletions

View File

@ -1,12 +1,22 @@
START TRANSACTION;
ALTER TABLE tblUsers ADD COLUMN `role` smallint(1) NOT NULL default '0' AFTER `isAdmin`;
UPDATE tblUsers SET `role` = 1 WHERE `isAdmin` = 1;
UPDATE tblUsers SET `role` = 2 WHERE `id` = 2;
ALTER TABLE tblUsers DROP COLUMN isAdmin;
ALTER TABLE tblFolders ADD COLUMN `date` int(12) default NULL AFTER `comment`;
CREATE TABLE `tblVersion` (
`date` datetime,
`major` smallint,
`minor` smallint,
`subminor` smallint
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
INSERT INTO tblVersion VALUES (NOW(), 3, 0, 0);
COMMIT;

View File

@ -1,10 +1,18 @@
START TRANSACTION;
CREATE TABLE `tblCategory` (
`id` int(11) NOT NULL auto_increment,
`name` text NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
INSERT INTO tblCategory VALUES (0, '');
CREATE TABLE `tblDocumentCategory` (
`categoryID` int(11) NOT NULL default 0,
`documentID` int(11) NOT NULL default 0
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
UPDATE tblVersion set major=3, minor=1, subminor=0;
COMMIT;

View File

@ -1 +1,5 @@
START TRANSACTION;
UPDATE tblVersion set major=3, minor=2, subminor=0;
COMMIT;

View File

@ -46,12 +46,12 @@ function check($doupdate=0) { /* {{{ */
$queryStr = "SELECT ".$schema['key'].", `".implode('`,`', $schema['fields'])."` FROM ".$tblname;
elseif(isset($schema['keys']))
$queryStr = "SELECT ".implode(',', $schema['keys']).", `".implode('`,`', $schema['fields'])."` FROM ".$tblname;
$res = $db->Execute($queryStr);
$recs = $res->GetArray();
$res = $db->query($queryStr);
$recs = $res->fetchAll(PDO::FETCH_ASSOC);
foreach($recs as $rec) {
foreach($schema['fields'] as $field) {
if($rec[$field] !== mydmsDecodeString($rec[$field])) {
$updateSql = "UPDATE ".$tblname." SET `".$field."`=".$db->qstr(mydmsDecodeString($rec[$field]))." where ";
$updateSql = "UPDATE ".$tblname." SET `".$field."`=".$db->quote(mydmsDecodeString($rec[$field]))." where ";
if(isset($schema['key']))
$updateSql .= $schema['key']."=".$rec[$schema['key']];
elseif(isset($schema['keys'])) {
@ -64,7 +64,7 @@ function check($doupdate=0) { /* {{{ */
$allupdates[] = $updateSql;
echo "<tr><td>".$tblname."</td><td>".$field."</td><td>".htmlspecialchars($rec[$field])."</td><td>".htmlspecialchars(mydmsDecodeString($rec[$field]))."</td><td><pre>".htmlspecialchars($updateSql)."</pre></td></tr>\n";
if($doupdate) {
$res = $db->Execute($updateSql);
$res = $db->exec($updateSql);
if(!$res) {
$errormsg = 'Could not execute update statement';
echo "<tr><td colspan=\"5\"><span style=\"color: red;\">".$errormsg."</span></td></tr>\n";

View File

@ -1,11 +1,19 @@
START TRANSACTION;
CREATE TABLE `tblUserPasswordRequest` (
`id` int(11) NOT NULL auto_increment,
`userID` int(11) NOT NULL default '0',
`hash` varchar(50) default NULL,
`date` datetime NOT NULL default '0000-00-00 00:00:00',
PRIMARY KEY (`id`)
) DEFAULT CHARSET=utf8;
UPDATE tblVersion set major=3, minor=3, subminor=7;
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
UPDATE tblVersion set major=3, minor=3, subminor=0;
ALTER TABLE tblDocumentContent MODIFY mimeType varchar(100);
ALTER TABLE tblDocumentFiles MODIFY mimeType varchar(100);
ALTER TABLE tblFolders ADD COLUMN `folderList` text NOT NULL;
COMMIT;

View File

@ -6,6 +6,7 @@ DROP PROCEDURE IF EXISTS DROPFK;
-- uncomment the following if run in mysql client
-- DELIMITER $$ ;
CREATE PROCEDURE DROPFK (
IN parm_table_name VARCHAR(100),
IN parm_key_name VARCHAR(100)
@ -21,6 +22,7 @@ BEGIN
DEALLOCATE PREPARE stmt;
END IF;
END
-- place a $$ after the last END if run the file in mysql client
-- uncomment the following if run in mysql client
-- DELIMITER ; $$