2 -- Add users and role tables, along with a many-to-many join table
4 PRAGMA foreign_keys = ON;
6 id INTEGER PRIMARY KEY,
15 id INTEGER PRIMARY KEY,
18 CREATE TABLE user_role (
19 user_id INTEGER REFERENCES users(id) ON DELETE CASCADE ON UPDATE CASCADE,
20 role_id INTEGER REFERENCES role(id) ON DELETE CASCADE ON UPDATE CASCADE,
21 PRIMARY KEY (user_id, role_id)
24 -- Load up some initial test data
26 INSERT INTO users VALUES (1, 'test01', 'mypass', 't01@na.com', 'Joe', 'Blow', 1);
27 INSERT INTO users VALUES (2, 'test02', 'mypass', 't02@na.com', 'Jane', 'Doe', 1);
28 INSERT INTO users VALUES (3, 'test03', 'mypass', 't03@na.com', 'No', 'Go', 0);
29 INSERT INTO role VALUES (1, 'user');
30 INSERT INTO role VALUES (2, 'admin');
31 INSERT INTO user_role VALUES (1, 1);
32 INSERT INTO user_role VALUES (1, 2);
33 INSERT INTO user_role VALUES (2, 1);
34 INSERT INTO user_role VALUES (3, 1);