[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Phpgroupware-cvs] anthill/etc upgrade-0.2.3-0.3.0-mysql.php,1.2
From: |
powerstat |
Subject: |
[Phpgroupware-cvs] anthill/etc upgrade-0.2.3-0.3.0-mysql.php,1.2 |
Date: |
Mon, 18 Apr 2005 09:37:00 +0200 |
Update of anthill/etc
Modified Files:
Branch: MAIN
upgrade-0.2.3-0.3.0-mysql.php lines: +161 -161
Log Message:
Fixed syntax error; missing ';'
====================================================
Index: anthill/etc/upgrade-0.2.3-0.3.0-mysql.php
diff -u anthill/etc/upgrade-0.2.3-0.3.0-mysql.php:1.1
anthill/etc/upgrade-0.2.3-0.3.0-mysql.php:1.2
--- anthill/etc/upgrade-0.2.3-0.3.0-mysql.php:1.1 Sun Jul 20 01:23:01 2003
+++ anthill/etc/upgrade-0.2.3-0.3.0-mysql.php Mon Apr 18 07:37:20 2005
@@ -1,162 +1,162 @@
-<?php
- /****************************************************************************
- * Anthill 2.3 -> phpGroupWare Anthill Upgrade Script *
- * http://phpgroupware.org *
- * *
- * Written by Dave Hall [skwashd AT phpgroupware.org] *
- * Copyright 2003 Free Software Founation *
- * ------------------------------------------------------------------------ *
- * This program is free software; you can redistribute it and/or modify it *
- * under the terms of the GNU General Public License as published by the *
- * Free Software Foundation; either version 2 of the License, or (at your *
- * option) any later version. *
- * ------------------------------------------------------------------------ *
-
****************************************************************************/
- // $Id$
-
- //SQL upgrade script for Anthill 0.2.3 -> 0.3.0alpha
-
- $GLOBALS['update'] = intval($_GET['update']);
-
- //Fix config table
- $sql[] = 'ALTER TABLE config RENAME anthill_config';
- $sql[] = 'ALTER TABLE anthill_config DROP PRIMARY KEY';
- $sql[] = 'ALTER TABLE anthill_config DROP id';
- $sql[] = "ALTER TABLE anthill_config ADD PRIMARY KEY('name')";
- $sql[] = "INSERT INTO anthill_config('def_severity', 2)";
- $sql[] = "INSERT INTO anthill_config('def_priority', 2)";
-
- //Create New Sessions Table
- $sql[] = 'DROP TABLE sessions';
-
- // Alter User Table
- $sql[] = 'ALTER TABLE users RENAME anthill_users';
- $sql[] = "ALTER TABLE anthill_users CHANGE epref email_updates INT(1)
DEFAULT '1'";
- $sql[] = 'ALTER TABLE anthill_users MODIFY laston INT(11)';
- $sql[] = 'ALTER TABLE anthill_users MODIFY thison INT(11)';
-
- // Alter severity Table
- $sql[]= 'ALTER TABLE severity_d RENAME anthill_severity_d';
- $sql[]= 'ALTER TABLE anthill_severity_d DROP s_def';
-
- // Alter priority Table
- $sql[] = 'ALTER TABLE severity_d RENAME anthill_priority_d';
- $sql[] = 'ALTER TABLE anthill_priority_d DROP s_def';
-
- // Rename Remaining Tables
- $sql[] = 'ALTER TABLE bugs RENAME anthill_bugs';
- $sql[] = 'ALTER TABLE bugdesc RENAME anthill_bugdesc';
- $sql[] = 'ALTER TABLE products RENAME anthill_products';
- $sql[] = 'ALTER TABLE components RENAME anthill_components';
- $sql[] = 'ALTER TABLE status_d RENAME anthill_status_d';
- $sql[] = 'ALTER TABLE priority_d RENAME anthill_priority_d'
- $sql[] = 'ALTER TABLE resolve_d RENAME anthill_resolve_d';
- $sql[] = 'ALTER TABLE bugactivity RENAME anthill_bugactivity';
- $sql[] = 'ALTER TABLE attachidx RENAME anthill_attachidx';
-
- // get the basic changes out the way
- foreach($sql as $query)
- {
- if($GLOBALS['update'])
- {
- $db->query($query);
- }
- else
- {
- echo "SQL: $query <br>\n";
- }
- }
- // free up some memory :)
- unset($sql);
-
- $changes[] = array('tbl' => 'anthill_bugs',
- 'col' => 'modified',
- 'pk' => 'bid'
- );
-
- $changes[] = array('tbl' => 'anthill_bugs',
- 'col' => 'creation',
- 'pk' => 'bid'
- );
-
- $changes[] = array('tbl' => 'anthill_bugdesc',
- 'col' => 'date',
- 'pk' => 'did'
- );
-
- $changes[] = array('tbl' => 'anthill_bugactivity',
- 'col' => 'modified',
- 'pk' => 'aid'
- );
-
- $changes[] = array('tbl' => 'anthill_attachidx',
- 'col' => 'modified',
- 'pk' => 'atid'
- );
-
- function convert_timestamp_cols($changes)
- {
- foreach($changes as $change)
- {
- // rename the old modified col
- $sql = 'ALTER TABLE ' . $change['tbl'] . ' CHANGE ' . $change['col'] .
' ' . $change['col'] . '_ts TIMESTAMP(14)';
- if($GLOBALS['update'])
- {
- $db->query($query);
- }
- else
- {
- echo "SQL: $sql <br>\n";
- }
-
- // add the new timestamp col
- $sql = 'ALTER TABLE ' . $change['tbl'] . 'ADD ' . $change['col'] . '
INT(11)';
- if($GLOBALS['update'])
- {
- $db->query($query);
- }
- else
- {
- echo "SQL: $sql <br>\n";
- }
-
-
- // get all the old values from modified
- $sql = 'SELECT ' . $change['pk'] . ', UNIX_TIMESTAMP(' . $change['col']
. '_ts) as epoch_ts FROM '. $change['tbl'];
- $db->query($sql);
- while($db->next_record())
- {
- $new_vals[$db->f($change['pk'])] = $db->f('epoch_ts');
- }
-
- foreach($news_vals as $new_val)
- {
- $sql = 'UPDATE ' . $change['tbl'] . ' '
- . 'SET modified=' . $new_val['epoch_ts'] . ' '
- . 'WHERE bid=' . $new_val[$change['pk']];
-
- if($GLOBALS['update'])
- {
- $db->query($query);
- }
- else
- {
- echo "SQL: $sql <br>\n";
- }
- }
- $sql = 'ALTER TABLE ' . $change['tbl'] . ' DROP ' . $change['col'] .
'_ts';
- if($GLOBALS['update'])
- {
- $db->query($query);
- }
- else
- {
- echo "SQL: $sql <br>\n";
- }
- }
- }
-
- echo '</p>please check the above output<br></p>';
- echo '<p>If all appears to be correct <a href="' . $_SERVER['PHP_SELF'] .
'?update=1">run it in update mode</a></p>';
-
+<?php
+ /****************************************************************************
+ * Anthill 2.3 -> phpGroupWare Anthill Upgrade Script *
+ * http://phpgroupware.org *
+ * *
+ * Written by Dave Hall [skwashd AT phpgroupware.org] *
+ * Copyright 2003 Free Software Founation *
+ * ------------------------------------------------------------------------ *
+ * This program is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU General Public License as published by the *
+ * Free Software Foundation; either version 2 of the License, or (at your *
+ * option) any later version. *
+ * ------------------------------------------------------------------------ *
+
****************************************************************************/
+ // $Id$
+
+ //SQL upgrade script for Anthill 0.2.3 -> 0.3.0alpha
+
+ $GLOBALS['update'] = intval($_GET['update']);
+
+ //Fix config table
+ $sql[] = 'ALTER TABLE config RENAME anthill_config';
+ $sql[] = 'ALTER TABLE anthill_config DROP PRIMARY KEY';
+ $sql[] = 'ALTER TABLE anthill_config DROP id';
+ $sql[] = "ALTER TABLE anthill_config ADD PRIMARY KEY('name')";
+ $sql[] = "INSERT INTO anthill_config('def_severity', 2)";
+ $sql[] = "INSERT INTO anthill_config('def_priority', 2)";
+
+ //Create New Sessions Table
+ $sql[] = 'DROP TABLE sessions';
+
+ // Alter User Table
+ $sql[] = 'ALTER TABLE users RENAME anthill_users';
+ $sql[] = "ALTER TABLE anthill_users CHANGE epref email_updates INT(1)
DEFAULT '1'";
+ $sql[] = 'ALTER TABLE anthill_users MODIFY laston INT(11)';
+ $sql[] = 'ALTER TABLE anthill_users MODIFY thison INT(11)';
+
+ // Alter severity Table
+ $sql[]= 'ALTER TABLE severity_d RENAME anthill_severity_d';
+ $sql[]= 'ALTER TABLE anthill_severity_d DROP s_def';
+
+ // Alter priority Table
+ $sql[] = 'ALTER TABLE severity_d RENAME anthill_priority_d';
+ $sql[] = 'ALTER TABLE anthill_priority_d DROP s_def';
+
+ // Rename Remaining Tables
+ $sql[] = 'ALTER TABLE bugs RENAME anthill_bugs';
+ $sql[] = 'ALTER TABLE bugdesc RENAME anthill_bugdesc';
+ $sql[] = 'ALTER TABLE products RENAME anthill_products';
+ $sql[] = 'ALTER TABLE components RENAME anthill_components';
+ $sql[] = 'ALTER TABLE status_d RENAME anthill_status_d';
+ $sql[] = 'ALTER TABLE priority_d RENAME anthill_priority_d';
+ $sql[] = 'ALTER TABLE resolve_d RENAME anthill_resolve_d';
+ $sql[] = 'ALTER TABLE bugactivity RENAME anthill_bugactivity';
+ $sql[] = 'ALTER TABLE attachidx RENAME anthill_attachidx';
+
+ // get the basic changes out the way
+ foreach($sql as $query)
+ {
+ if($GLOBALS['update'])
+ {
+ $db->query($query);
+ }
+ else
+ {
+ echo "SQL: $query <br>\n";
+ }
+ }
+ // free up some memory :)
+ unset($sql);
+
+ $changes[] = array('tbl' => 'anthill_bugs',
+ 'col' => 'modified',
+ 'pk' => 'bid'
+ );
+
+ $changes[] = array('tbl' => 'anthill_bugs',
+ 'col' => 'creation',
+ 'pk' => 'bid'
+ );
+
+ $changes[] = array('tbl' => 'anthill_bugdesc',
+ 'col' => 'date',
+ 'pk' => 'did'
+ );
+
+ $changes[] = array('tbl' => 'anthill_bugactivity',
+ 'col' => 'modified',
+ 'pk' => 'aid'
+ );
+
+ $changes[] = array('tbl' => 'anthill_attachidx',
+ 'col' => 'modified',
+ 'pk' => 'atid'
+ );
+
+ function convert_timestamp_cols($changes)
+ {
+ foreach($changes as $change)
+ {
+ // rename the old modified col
+ $sql = 'ALTER TABLE ' . $change['tbl'] . ' CHANGE ' . $change['col'] .
' ' . $change['col'] . '_ts TIMESTAMP(14)';
+ if($GLOBALS['update'])
+ {
+ $db->query($query);
+ }
+ else
+ {
+ echo "SQL: $sql <br>\n";
+ }
+
+ // add the new timestamp col
+ $sql = 'ALTER TABLE ' . $change['tbl'] . 'ADD ' . $change['col'] . '
INT(11)';
+ if($GLOBALS['update'])
+ {
+ $db->query($query);
+ }
+ else
+ {
+ echo "SQL: $sql <br>\n";
+ }
+
+
+ // get all the old values from modified
+ $sql = 'SELECT ' . $change['pk'] . ', UNIX_TIMESTAMP(' . $change['col']
. '_ts) as epoch_ts FROM '. $change['tbl'];
+ $db->query($sql);
+ while($db->next_record())
+ {
+ $new_vals[$db->f($change['pk'])] = $db->f('epoch_ts');
+ }
+
+ foreach($news_vals as $new_val)
+ {
+ $sql = 'UPDATE ' . $change['tbl'] . ' '
+ . 'SET modified=' . $new_val['epoch_ts'] . ' '
+ . 'WHERE bid=' . $new_val[$change['pk']];
+
+ if($GLOBALS['update'])
+ {
+ $db->query($query);
+ }
+ else
+ {
+ echo "SQL: $sql <br>\n";
+ }
+ }
+ $sql = 'ALTER TABLE ' . $change['tbl'] . ' DROP ' . $change['col'] .
'_ts';
+ if($GLOBALS['update'])
+ {
+ $db->query($query);
+ }
+ else
+ {
+ echo "SQL: $sql <br>\n";
+ }
+ }
+ }
+
+ echo '</p>please check the above output<br></p>';
+ echo '<p>If all appears to be correct <a href="' . $_SERVER['PHP_SELF'] .
'?update=1">run it in update mode</a></p>';
+
?>
\ No newline at end of file
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Phpgroupware-cvs] anthill/etc upgrade-0.2.3-0.3.0-mysql.php,1.2,
powerstat <=