Merge branch 'BumBranch' into dev
This commit is contained in:
commit
bed9381509
3 changed files with 46 additions and 10 deletions
|
@ -64,9 +64,10 @@ const addWeeklyReport = `WITH UserLookup AS (SELECT id FROM users WHERE username
|
|||
const addUserToProject = "INSERT INTO user_roles (user_id, project_id, p_role) VALUES (?, ?, ?)" // WIP
|
||||
const changeUserRole = "UPDATE user_roles SET p_role = ? WHERE user_id = ? AND project_id = ?"
|
||||
|
||||
const getProjectsForUser = `SELECT projects.id, projects.name, projects.description, projects.owner_user_id
|
||||
FROM projects JOIN user_roles ON projects.id = user_roles.project_id
|
||||
JOIN users ON user_roles.user_id = users.id WHERE users.username = ?;`
|
||||
const getProjectsForUser = `SELECT p.id, p.name, p.description FROM projects p
|
||||
JOIN user_roles ur ON p.id = ur.project_id
|
||||
JOIN users u ON ur.user_id = u.id
|
||||
WHERE u.username = ?`
|
||||
|
||||
// DbConnect connects to the database
|
||||
func DbConnect(dbpath string) Database {
|
||||
|
|
|
@ -1,7 +1,42 @@
|
|||
INSERT OR IGNORE INTO users (username, password) VALUES
|
||||
('admin', 'password'),
|
||||
('user', 'password');
|
||||
INSERT OR IGNORE INTO users(username, password)
|
||||
VALUES ("admin", "123");
|
||||
|
||||
INSERT OR IGNORE INTO projects (name, description, owner_user_id) VALUES
|
||||
('Project 1', 'Description 1', 1),
|
||||
('Project 2', 'Description 2', 2);
|
||||
INSERT OR IGNORE INTO users(username, password)
|
||||
VALUES ("user", "123");
|
||||
|
||||
INSERT OR IGNORE INTO users(username, password)
|
||||
VALUES ("user2", "123");
|
||||
|
||||
INSERT OR IGNORE INTO projects(name,description,owner_user_id)
|
||||
VALUES ("projecttest","test project", 1)
|
||||
|
||||
INSERT OR IGNORE INTO projects(name,description,owner_user_id)
|
||||
VALUES ("projecttest2","test project2", 1)
|
||||
|
||||
INSERT OR IGNORE INTO projects(name,description,owner_user_id)
|
||||
VALUES ("projecttest3","test project3", 1)
|
||||
|
||||
INSERT OR IGNORE INTO user_roles(user_id,project_id,p_role)
|
||||
VALUES (1,1,"project_manager");
|
||||
|
||||
INSERT INTO user_roles(user_id,project_id,p_role)
|
||||
VALUES (2,1,"member");
|
||||
|
||||
INSERT INTO user_roles(user_id,project_id,p_role)
|
||||
VALUES (3,1,"member");
|
||||
|
||||
INSERT INTO user_roles(user_id,project_id,p_role)
|
||||
VALUES (3,2,"member");
|
||||
|
||||
INSERT INTO user_roles(user_id,project_id,p_role)
|
||||
VALUES (3,3,"member");
|
||||
|
||||
INSERT INTO user_roles(user_id,project_id,p_role)
|
||||
VALUES (2,1,"project_manager");
|
||||
|
||||
|
||||
SELECT id FROM users WHERE username = "admin"
|
||||
|
||||
SELECT id FROM users WHERE username = "user"
|
||||
|
||||
SELECT id FROM users WHERE username = "user2"
|
||||
|
|
Loading…
Add table
Reference in a new issue