Fix for bug #2074 + #2075: Postgres update error to 1.6

This commit is contained in:
Ralf Becker 2009-07-18 12:57:21 +00:00
parent 52dbb060d2
commit a34f7faec5

View File

@ -92,21 +92,27 @@ $test[] = '1.5.003';
function phpgwapi_upgrade1_5_003() function phpgwapi_upgrade1_5_003()
{ {
// import the current egw_vfs into egw_sqlfs // import the current egw_vfs into egw_sqlfs
// ToDo: moving /infolog and /infolog/$app to /apps in the files dir!!!
$debug = $GLOBALS['DEBUG']; $debug = $GLOBALS['DEBUG'];
// delete the table in case this update runs multiple times
$GLOBALS['egw_setup']->db->query('DELETE FROM egw_sqlfs',__LINE__,__FILE__);
if ($GLOBALS['egw_setup']->db->Type == 'mysql')
{
$GLOBALS['egw_setup']->db->query('ALTER TABLE egw_sqlfs AUTO_INCREMENT=1',__LINE__,__FILE__);
}
// make sure the required dirs are there and have the following id's // make sure the required dirs are there and have the following id's
$dirs = array( $dirs = array(
'/' => 1, '/' => 1,
'/home' => 2, '/home' => 2,
'/apps' => 3, '/apps' => 3,
); );
// delete the table in case this update runs multiple times
$GLOBALS['egw_setup']->db->query('DELETE FROM egw_sqlfs',__LINE__,__FILE__);
if ($GLOBALS['egw_setup']->db->Type == 'mysql')
{
$GLOBALS['egw_setup']->db->query('ALTER TABLE egw_sqlfs AUTO_INCREMENT=1',__LINE__,__FILE__);
}
elseif ( $GLOBALS['egw_setup']->db->Type == 'pgsql' )
{
$GLOBALS['egw_setup']->db->query('ALTER SEQUENCE egw_sqlfs_fs_id_seq RESTART WITH '.(count($dirs) + 1),__LINE__,__FILE__);
}
foreach($dirs as $path => $id) foreach($dirs as $path => $id)
{ {
$nrow = array( $nrow = array(
@ -127,7 +133,8 @@ function phpgwapi_upgrade1_5_003()
); );
$GLOBALS['egw_setup']->db->insert('egw_sqlfs',$nrow,false,__LINE__,__FILE__,'phpgwapi'); $GLOBALS['egw_setup']->db->insert('egw_sqlfs',$nrow,false,__LINE__,__FILE__,'phpgwapi');
} }
$query = $GLOBALS['egw_setup']->db->select('egw_vfs','*',"vfs_mime_type != 'journal' AND vfs_mime_type != 'journal-deleted'",__LINE__,__FILE__,false,'ORDER BY length(vfs_directory) ASC','phpgwapi');
$query = $GLOBALS['egw_setup']->db->select('egw_vfs','*',"vfs_mime_type != 'journal' AND vfs_mime_type != 'journal-deleted'",__LINE__,__FILE__,false,'ORDER BY vfs_file_id ASC','phpgwapi');
if ($debug) echo "rows=<pre>\n"; if ($debug) echo "rows=<pre>\n";
foreach($query as $row) foreach($query as $row)