Skip to content

Commit bf14398

Browse files
committed
Fix database migration issues and update project item queries
1 parent 07f7208 commit bf14398

File tree

5 files changed

+10
-9
lines changed

5 files changed

+10
-9
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
* Fixed dispatching of `WorktimeAddedEvent` event with incorrect parameters
1010
* Added Database migration instructions when using Docker within the `README.md` `Database` section
1111
* Removed the `setup` folder entirely (deprecated)
12+
* Fixed DB migrations for Docker setups
1213

1314
## v8.2.3
1415

api/v1/class/projects/projects.arbeit.inc.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ public function getCurrentUserProjects()
163163

164164
public function addProjectItem($project_id, $title, $description, $assignee = null)
165165
{
166-
$sql = "INSERT INTO `projects_items` (id, title, description, assignee) VALUES (?, ?, ?, ?)";
166+
$sql = "INSERT INTO `projects_items` (pid, title, description, assignee) VALUES (?, ?, ?, ?)";
167167
$res = $this->db->sendQuery($sql)->execute([$project_id, $title, $description, $assignee]);
168168

169169
if (!$res) {
@@ -297,7 +297,7 @@ public function getProjectItems($project_id): array|bool
297297
{
298298
Exceptions::error_rep("[PROJECTS] Fetching project items for project '{$project_id}'...");
299299

300-
$sql = "SELECT * FROM projects_items WHERE id = ?";
300+
$sql = "SELECT * FROM projects_items WHERE pid = ?";
301301
$stmt = $this->db->sendQuery($sql);
302302
$res = $stmt->execute([$project_id]);
303303

@@ -320,7 +320,7 @@ public function getProjectItems($project_id): array|bool
320320
public function getUserProjectItems($project_id, $user)
321321
{
322322
Exceptions::error_rep("[PROJECTS] Fetching project items for user '{$user}' and project '{$project_id}'...");
323-
$sql = "SELECT * FROM projects_items WHERE assignee = ? AND id = ?";
323+
$sql = "SELECT * FROM projects_items WHERE assignee = ? AND pid = ?";
324324
$stmt = $this->db->sendQuery($sql);
325325

326326
if (!$stmt->execute([$user, $project_id])) {
@@ -336,7 +336,7 @@ public function getUserProjectItems($project_id, $user)
336336

337337
public function getItem($id): array|bool
338338
{
339-
$sql = "SELECT * FROM projects_items WHERE id = ?";
339+
$sql = "SELECT * FROM projects_items WHERE pid = ?";
340340
$stmt = $this->db->sendQuery($sql);
341341
$res = $stmt->execute([$id]);
342342

migrations/migrations/20250331164242_init_first_user.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ public function change(): void
1919
'isAdmin' => true,
2020
'state' => null,
2121
'easymode' => false,
22+
"active" => 1
2223
];
2324

2425
$users = $this->fetchRow("SELECT COUNT(*) as count FROM users WHERE username = 'admin'");

migrations/migrations/20250905190407_init_projects_scheme.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@ public function change(): void
1717
$this->execute("SET SQL_MODE = 'NO_AUTO_VALUE_ON_ZERO';");
1818
$this->execute("SET time_zone = '+00:00';");
1919

20-
$this->table("projects", ["id" => false, "primary_key" => "id"])
21-
->addColumn("id", "integer", ["identity" => true])
20+
$this->table("projects")
2221
->addColumn("name", "string", ["limit" => 255])
2322
->addColumn("description", "text", ["null" => true])
2423
->addColumn("members", "text", ["null" => true])

migrations/migrations/20250905190436_init_projects_items_scheme.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@ public function change(): void
1717
$this->execute("SET SQL_MODE = 'NO_AUTO_VALUE_ON_ZERO';");
1818
$this->execute("SET time_zone = '+00:00';");
1919

20-
$this->table("projects_items", ["id" => false])
21-
->addColumn("id", "integer") // PROJECT ID
20+
$this->table("projects_items", ["id" => true])
21+
->addColumn("pid", "integer") // PROJECT ID
2222
->addColumn("title", "string", ["limit" => 255])
2323
->addColumn("description", "text", ["null" => true])
2424
->addColumn("assignee", "integer") // USER ID
25-
->addColumn("itemid", "integer", ["id" => true])
25+
->addColumn("itemid", "integer")
2626
->addColumn("deadline", "date")
2727
->create();
2828
}

0 commit comments

Comments
 (0)