diff --git a/backend/internal/database/migrations/0010_users.sql b/backend/internal/database/migrations/0010_users.sql index 5c9d329..d2e2dd1 100644 --- a/backend/internal/database/migrations/0010_users.sql +++ b/backend/internal/database/migrations/0010_users.sql @@ -3,7 +3,7 @@ -- username is what is used for login -- password is the hashed password CREATE TABLE IF NOT EXISTS users ( - id INTEGER PRIMARY KEY, + id INTEGER PRIMARY KEY AUTOINCREMENT, userId TEXT DEFAULT (HEX(RANDOMBLOB(4))) NOT NULL UNIQUE, username VARCHAR(255) NOT NULL UNIQUE, password VARCHAR(255) NOT NULL diff --git a/backend/internal/database/migrations/0020_projects.sql b/backend/internal/database/migrations/0020_projects.sql index 58d8e97..99bce86 100644 --- a/backend/internal/database/migrations/0020_projects.sql +++ b/backend/internal/database/migrations/0020_projects.sql @@ -1,5 +1,5 @@ CREATE TABLE IF NOT EXISTS projects ( - id INTEGER PRIMARY KEY, + id INTEGER PRIMARY KEY AUTOINCREMENT, name VARCHAR(255) NOT NULL UNIQUE, description TEXT NOT NULL, owner_user_id INTEGER NOT NULL, diff --git a/backend/internal/database/migrations/0035_weekly_report.sql b/backend/internal/database/migrations/0035_weekly_report.sql index 47610b5..366d932 100644 --- a/backend/internal/database/migrations/0035_weekly_report.sql +++ b/backend/internal/database/migrations/0035_weekly_report.sql @@ -1,7 +1,8 @@ CREATE TABLE weekly_reports ( - user_id INTEGER, - project_id INTEGER, - week INTEGER, + report_id INTEGER PRIMARY KEY AUTOINCREMENT, + user_id INTEGER NOT NULL, + project_id INTEGER NOT NULL, + week INTEGER NOT NULL, development_time INTEGER, meeting_time INTEGER, admin_time INTEGER, @@ -11,6 +12,5 @@ CREATE TABLE weekly_reports ( signed_by INTEGER, FOREIGN KEY (user_id) REFERENCES users(id), FOREIGN KEY (project_id) REFERENCES projects(id), - FOREIGN KEY (signed_by) REFERENCES users(id), - PRIMARY KEY (user_id, project_id, week) -) \ No newline at end of file + FOREIGN KEY (signed_by) REFERENCES users(id) +); \ No newline at end of file diff --git a/backend/internal/types/WeeklyReport.go b/backend/internal/types/WeeklyReport.go index 43c19c6..a9a6264 100644 --- a/backend/internal/types/WeeklyReport.go +++ b/backend/internal/types/WeeklyReport.go @@ -26,19 +26,19 @@ type WeeklyReport struct { // The user id of the user who submitted the report UserId int `json:"userId" db:"user_id"` // The name of the project, as it appears in the database - ProjectName string `json:"projectName"` + ProjectId string `json:"projectId" db:"project_id"` // The week number - Week int `json:"week"` + Week int `json:"week" db:"week"` // Total time spent on development - DevelopmentTime int `json:"developmentTime"` + DevelopmentTime int `json:"developmentTime" db:"development_time"` // Total time spent in meetings - MeetingTime int `json:"meetingTime"` + MeetingTime int `json:"meetingTime" db:"meeting_time"` // Total time spent on administrative tasks - AdminTime int `json:"adminTime"` + AdminTime int `json:"adminTime" db:"admin_time"` // Total time spent on personal projects - OwnWorkTime int `json:"ownWorkTime"` + OwnWorkTime int `json:"ownWorkTime" db:"own_work_time"` // Total time spent on studying - StudyTime int `json:"studyTime"` + StudyTime int `json:"studyTime" db:"study_time"` // Total time spent on testing - TestingTime int `json:"testingTime"` + TestingTime int `json:"testingTime" db:"testing_time"` }