Sample data
This commit is contained in:
parent
f5a914330f
commit
7ae6cce6b4
2 changed files with 48 additions and 7 deletions
|
@ -10,4 +10,4 @@ CREATE TABLE IF NOT EXISTS users (
|
||||||
|
|
||||||
-- Users are commonly searched by username and userId
|
-- Users are commonly searched by username and userId
|
||||||
CREATE INDEX IF NOT EXISTS users_username_index ON users (username);
|
CREATE INDEX IF NOT EXISTS users_username_index ON users (username);
|
||||||
CREATE INDEX IF NOT EXISTS users_userId_index ON users (userId);
|
CREATE INDEX IF NOT EXISTS users_userId_index ON users (Id);
|
|
@ -1,7 +1,48 @@
|
||||||
INSERT OR IGNORE INTO users (username, password) VALUES
|
INSERT OR IGNORE INTO users(username, password)
|
||||||
('admin', 'password'),
|
VALUES ("admin", "123");
|
||||||
('user', 'password');
|
|
||||||
|
|
||||||
INSERT OR IGNORE INTO projects (name, description, owner_user_id) VALUES
|
INSERT OR IGNORE INTO users(username, password)
|
||||||
('Project 1', 'Description 1', 1),
|
VALUES ("user", "123");
|
||||||
('Project 2', 'Description 2', 2);
|
|
||||||
|
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 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 = 'admin';
|
||||||
|
|
||||||
|
SELECT id FROM users WHERE username = "admin"
|
||||||
|
|
||||||
|
SELECT id FROM users WHERE username = "user"
|
||||||
|
|
||||||
|
SELECT id FROM users WHERE username = "user2"
|
||||||
|
|
Loading…
Reference in a new issue