FOSSology  4.4.0
Open Source License Compliance by Open Source Software
dbmigrate_clearing-event.php
Go to the documentation of this file.
1 <?php
2 /*
3  SPDX-FileCopyrightText: © 2015 Siemens AG
4 
5  SPDX-License-Identifier: GPL-2.0-only
6 */
7 
18 echo "Ensure that every user had chosen an active group";
19 $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');
20 
21 echo "Link decisions with groups\n";
22 $dbManager->queryOnce('UPDATE clearing_decision cd SET group_fk=u.group_fk FROM users u WHERE cd.user_fk=u.user_pk');
23 
24 echo "Fill clearing event table with old decisions...";
25 $dbManager->queryOnce('
26  INSERT INTO clearing_event ( uploadtree_fk,
27  rf_fk,
28  removed,
29  user_fk,
30  group_fk,
31  job_fk,
32  type_fk,
33  comment,
34  reportinfo,
35  date_added)
36  SELECT
37  cd.uploadtree_fk,
38  cl.rf_fk,
39  (0=1) removed,
40  cd.user_fk,
41  cd.group_fk,
42  null job_fk,
43  type_fk,
44  cd.comment,
45  cd.reportinfo,
46  cd.date_added
47  FROM clearing_decision cd, clearing_licenses cl
48  WHERE cd.clearing_pk=cl.clearing_fk');
49 
50 echo " and link them with decisions\n";
51 $dbManager->queryOnce('
52  INSERT INTO clearing_decision_event
53  SELECT cd.clearing_pk clearing_fk,ce.clearing_event_pk clearing_event_fk
54  FROM clearing_decision cd, clearing_event ce
55  WHERE cd.date_added=ce.date_added');