FOSSology  3.2.0rc1
Open Source License Compliance by Open Source Software
dbmigrate_2.0-2.5-pre.php
Go to the documentation of this file.
1 <?php
2 /***********************************************************
3  Copyright (C) 2014 Hewlett-Packard Development Company, L.P.
4 
5  This program is free software; you can redistribute it and/or
6  modify it under the terms of the GNU General Public License
7  version 2 as published by the Free Software Foundation.
8 
9  This program is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU General Public License for more details.
13 
14  You should have received a copy of the GNU General Public License along
15  with this program; if not, write to the Free Software Foundation, Inc.,
16  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17  ***********************************************************/
18 
34 function Migrate_20_25($Verbose)
35 {
36  global $PG_CONN;
37 
38  $sql = "select count(*) from pg_class where relname='copyright';";
39  $result = pg_query($PG_CONN, $sql);
40  DBCheckResult($result, $sql, __FILE__, __LINE__);
41  $row = pg_fetch_assoc($result);
42  pg_free_result($result);
43  if (1 > $row['count']) {
44  return 0; // fresh install, even no copyright table
45  }
46 
47  $sql = "delete from copyright where pfile_fk not in (select pfile_pk from pfile);";
48  $result = pg_query($PG_CONN, $sql);
49  DBCheckResult($result, $sql, __FILE__, __LINE__);
50  pg_free_result($result);
51 
53  $sql = "SELECT conname from pg_constraint where conname= 'copyright_pfile_fk_fkey';";
54  $conresult = pg_query($PG_CONN, $sql);
55  DBCheckResult($conresult, $sql, __FILE__, __LINE__);
56  if (pg_num_rows($conresult) == 0) {
57  $sql = "ALTER TABLE copyright ADD CONSTRAINT copyright_pfile_fk_fkey FOREIGN KEY (pfile_fk) REFERENCES pfile (pfile_pk) ON DELETE CASCADE; ";
58  $result = pg_query($PG_CONN, $sql);
59  DBCheckResult($result, $sql, __FILE__, __LINE__);
60  pg_free_result($result);
61  print "add contr\n";
62  }
63  pg_free_result($conresult);
64  return 0;
65 } // Migrate_20_25()
66 
67 ?>
Migrate_20_25($Verbose)
Delete from copyright where pfile_fk not in (select pfile_pk from pfile) add foreign constraint on co...
foreach($Options as $Option=> $OptVal) if(0==$reference_flag &&0==$nomos_flag) $PG_CONN
DBCheckResult($result, $sql, $filenm, $lineno)
Check the postgres result for unexpected errors. If found, treat them as fatal.
Definition: common-db.php:198