ILIAS  release_10 Revision v10.1-43-ga1241a92c2f
class.ilIntroduceComponentArtifactDBUpdateSteps.php
Go to the documentation of this file.
1 <?php
2 
20 declare(strict_types=1);
21 
26 {
27  protected \ilDBInterface $db;
28 
29  public function prepare(\ilDBInterface $db): void
30  {
31  $this->db = $db;
32  }
33 
34  public function step_1(): void
35  {
36  if ($this->db->tableExists("il_compoment")) {
37  $this->db->dropTable("il_component");
38  }
39  }
40 
41  public function step_2(): void
42  {
43  $this->db->dropTable("il_pluginslot");
44  }
45 
46  public function step_3(): void
47  {
48  $this->db->manipulate("DELETE FROM il_plugin WHERE plugin_id IS NULL");
49  }
50 
51  public function step_4(): void
52  {
53  try {
54  $this->db->addPrimaryKey("il_plugin", ["plugin_id"]);
55  } catch (\PDOException $e) {
56  $this->db->dropPrimaryKey("il_plugin");
57  $this->db->addPrimaryKey("il_plugin", ["plugin_id"]);
58  }
59  }
60 
61  public function step_5(): void
62  {
63  if (!$this->db->tableColumnExists("il_plugin", "component_type")) {
64  return;
65  }
66 
67  $this->db->dropTableColumn("il_plugin", "component_type");
68  }
69 
70  public function step_6(): void
71  {
72  if (!$this->db->tableColumnExists("il_plugin", "component_name")) {
73  return;
74  }
75 
76  $this->db->dropTableColumn("il_plugin", "component_name");
77  }
78 
79  public function step_7(): void
80  {
81  if (!$this->db->tableColumnExists("il_plugin", "slot_id")) {
82  return;
83  }
84 
85  $this->db->dropTableColumn("il_plugin", "slot_id");
86  }
87 
88  public function step_8(): void
89  {
90  if (!$this->db->tableColumnExists("il_plugin", "name")) {
91  return;
92  }
93 
94  $this->db->dropTableColumn("il_plugin", "name");
95  }
96 }
prepare(\ilDBInterface $db)
Prepare the execution of the steps.