diff --git a/.gitignore b/.gitignore index 2d89407..8f9be7b 100644 --- a/.gitignore +++ b/.gitignore @@ -6,6 +6,7 @@ *.dylib bin +database.txt db.sqlite3 *.png diff --git a/backend/Makefile b/backend/Makefile index d005846..2547900 100644 --- a/backend/Makefile +++ b/backend/Makefile @@ -54,6 +54,9 @@ migrate: db.sqlite3: make migrate +dbdump: + sqlite3 $(DB_FILE) .dump > database.txt + backup: mkdir -p backups sqlite3 $(DB_FILE) .dump | gzip -9 > ./backups/BACKUP_$(DB_FILE)_$(shell date +"%Y-%m-%d_%H:%M:%S").sql.gz diff --git a/backend/internal/database/db.go b/backend/internal/database/db.go index 820c1f2..5221e4d 100644 --- a/backend/internal/database/db.go +++ b/backend/internal/database/db.go @@ -19,6 +19,7 @@ type Database interface { GetUserId(username string) (int, error) AddProject(name string, description string, username string) error Migrate(dirname string) error + GetProjectId(projectname string) (int, error) AddTimeReport(projectName string, userName string, start time.Time, end time.Time) error AddUserToProject(username string, projectname string, role string) error ChangeUserRole(username string, projectname string, role string) error @@ -123,7 +124,7 @@ func (d *Db) GetUserId(username string) (int, error) { return id, err } -func (d *Db) GetProjectId(projectname string) (int, error) { // WIP, denna kan vara goof +func (d *Db) GetProjectId(projectname string) (int, error) { var id int err := d.Get(&id, "SELECT id FROM projects WHERE name = ?", projectname) return id, err diff --git a/backend/internal/database/migrations/0049_project_role.sql b/backend/internal/database/migrations/0049_project_role.sql index 8716800..f7e7151 100644 --- a/backend/internal/database/migrations/0049_project_role.sql +++ b/backend/internal/database/migrations/0049_project_role.sql @@ -5,5 +5,5 @@ CREATE TABLE IF NOT EXISTS project_role ( ); -- Insert the possible roles a user can have in a project. -INSERT OR IGNORE INTO project_role (p_role) VALUES ('admin'); +INSERT OR IGNORE INTO project_role (p_role) VALUES ('project_manager'); INSERT OR IGNORE INTO project_role (p_role) VALUES ('member'); diff --git a/backend/internal/database/migrations/0050_user_roles.sql b/backend/internal/database/migrations/0050_user_roles.sql index aad25f7..d3e614d 100644 --- a/backend/internal/database/migrations/0050_user_roles.sql +++ b/backend/internal/database/migrations/0050_user_roles.sql @@ -1,7 +1,7 @@ CREATE TABLE IF NOT EXISTS user_roles ( user_id INTEGER NOT NULL, project_id INTEGER NOT NULL, - p_role TEXT NOT NULL, -- 'admin' or 'member' + p_role TEXT NOT NULL, -- 'project_manager' or 'member' FOREIGN KEY (user_id) REFERENCES users (id) FOREIGN KEY (project_id) REFERENCES projects (id) FOREIGN KEY (p_role) REFERENCES project_role (p_role)