ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
class.ilFileServicesDatabaseObjective.php
Go to the documentation of this file.
1 <?php
2 
18 declare(strict_types=1);
19 
24 {
25  protected ?ilDBInterface $database = null;
26 
27  public function prepare(ilDBInterface $db): void
28  {
29  $this->database = $db;
30  }
31 
35  public function step_1(): void
36  {
37  $this->abortIfNotPrepared();
38 
39  if ($this->database->tableExists("il_upload_policy")) {
40  return;
41  }
42 
43  $this->database->createTable("il_upload_policy", [
44  "policy_id" => [
45  'type' => 'integer',
46  'length' => 8,
47  'notnull' => true,
48  ],
49  "title" => [
50  'type' => 'text',
51  'length' => 256,
52  'notnull' => true,
53  ],
54  "upload_limit_in_mb" => [
55  'type' => 'integer',
56  'length' => 8,
57  'notnull' => true,
58  ],
59  "audience" => [
60  'type' => 'text',
61  'length' => 512,
62  'notnull' => true,
63  ],
64  "audience_type" => [
65  'type' => 'integer',
66  'length' => 2,
67  'notnull' => true,
68  ],
69  "scope_definition" => [
70  'type' => 'text',
71  'length' => 512,
72  'notnull' => true,
73  ],
74  "active" => [
75  'type' => 'integer',
76  'length' => 1,
77  'notnull' => true,
78  ],
79  "valid_from" => [
80  'type' => 'date',
81  'notnull' => false,
82  ],
83  "valid_until" => [
84  'type' => 'date',
85  'notnull' => false,
86  ],
87  "owner" => [
88  'type' => 'integer',
89  'length' => 8,
90  'notnull' => true,
91  ],
92  "create_date" => [
93  'type' => 'timestamp',
94  'notnull' => true,
95  ],
96  "last_update" => [
97  'type' => 'timestamp',
98  'notnull' => true,
99  ]
100  ]);
101 
102  $this->database->createSequence("il_upload_policy");
103  }
104 
109  protected function abortIfNotPrepared(): void
110  {
111  if (null === $this->database) {
112  throw new LogicException(self::class . "::prepare() must be called before db-update-steps execution.");
113  }
114  }
115 }
step_1()
adds a new table to store data of file upload policies