FOSSology  3.2.0rc1
Open Source License Compliance by Open Source Software
dbmigrate_clearing-event.php
Go to the documentation of this file.
1 <?php
2 /***********************************************************
3  Copyright (C) 2015 Siemens AG
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 
29 echo "Ensure that every user had chosen an active group";
30 $dbManager->queryOnce('UPDATE users SET group_fk=gum.group_fk FROM group_user_member gum WHERE users.group_fk is null and user_pk=user_fk');
31 
32 echo "Link decisions with groups\n";
33 $dbManager->queryOnce('UPDATE clearing_decision cd SET group_fk=u.group_fk FROM users u WHERE cd.user_fk=u.user_pk');
34 
35 echo "Fill clearing event table with old decisions...";
36 $dbManager->queryOnce('
37  INSERT INTO clearing_event ( uploadtree_fk,
38  rf_fk,
39  removed,
40  user_fk,
41  group_fk,
42  job_fk,
43  type_fk,
44  comment,
45  reportinfo,
46  date_added)
47  SELECT
48  cd.uploadtree_fk,
49  cl.rf_fk,
50  (0=1) removed,
51  cd.user_fk,
52  cd.group_fk,
53  null job_fk,
54  type_fk,
55  cd.comment,
56  cd.reportinfo,
57  cd.date_added
58  FROM clearing_decision cd, clearing_licenses cl
59  WHERE cd.clearing_pk=cl.clearing_fk');
60 
61 echo " and link them with decisions\n";
62 $dbManager->queryOnce('
63  INSERT INTO clearing_decision_event
64  SELECT cd.clearing_pk clearing_fk,ce.clearing_event_pk clearing_event_fk
65  FROM clearing_decision cd, clearing_event ce
66  WHERE cd.date_added=ce.date_added');