This commit is contained in:
borean 2024-03-08 14:56:24 +01:00
parent 0b23c5f8f1
commit 6acfdd36b2

View file

@ -16,7 +16,6 @@ type Database interface {
AddUser(username string, password string) error
RemoveUser(username string) error
PromoteToAdmin(username string) error
PromoteToAdmin(username string) error
GetUserId(username string) (int, error)
AddProject(name string, description string, username string) error
Migrate(dirname string) error
@ -40,11 +39,6 @@ var scripts embed.FS
const userInsert = "INSERT INTO users (username, password) VALUES (?, ?)"
const projectInsert = "INSERT INTO projects (name, description, user_id) SELECT ?, ?, id FROM users WHERE username = ?"
const promoteToAdmin = "INSERT INTO site_admin (admin_id) SELECT id FROM users WHERE username = ?"
// const addTimeReport = ""
// const addUserToProject = ""
// const changeUserRole = ""
const promoteToAdmin = "INSERT INTO site_admin (admin_id) SELECT id FROM users WHERE username = ?"
const addTimeReport = "INSERT INTO activity (report_id, activity_nbr, start_time, end_time, break, comment) VALUES (?, ?, ?, ?, ?, ?)" // WIP
const addUserToProject = "INSERT INTO project_member (project_id, user_id, role) VALUES (?, ?, ?)" // WIP
// const changeUserRole = ""
@ -66,14 +60,6 @@ func DbConnect(dbpath string) Database {
return &Db{db}
}
// func (d *Db) AddTimeReport(projectname string, start time.Time, end time.Time) error {
// }
// func (d *Db) AddUserToProject(username string, projectname string) error {
// }
// func (d *Db) ChangeUserRole(username string, projectname string, role string) error {
// }
@ -121,11 +107,6 @@ func (d *Db) PromoteToAdmin(username string) error {
return err
}
func (d *Db) PromoteToAdmin(username string) error {
_, err := d.Exec(promoteToAdmin, username)
return err
}
func (d *Db) GetUserId(username string) (int, error) {
var id int
err := d.Get(&id, "SELECT id FROM users WHERE username = ?", username) // Borde det inte vara "user" i singular