~evanj/cms

ref: 0ac69893cd1dd4e4cf2fa1498b99682d247e30cd cms/internal/s/db/sql/00008.sql -rw-r--r-- 594 bytes
0ac69893Evan M Jones Feat(invites and roles): Users can now set roles while inviting others. 2 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
DELETE FROM cms_invite;

CREATE TABLE cms_role (
	ID INTEGER PRIMARY KEY AUTO_INCREMENT,
	VALUE varchar(256) UNIQUE NOT NULL
);

{{range .Roles}}
INSERT INTO cms_role (VALUE) values ("{{.Name}}");
{{end}}

ALTER TABLE cms_invite ADD ROLE_ID INTEGER NOT NULL;
ALTER TABLE cms_invite ADD CONSTRAINT CMS_INVITE_ROLE_ID_FK FOREIGN KEY(ROLE_ID) REFERENCES cms_role(ID);

ALTER TABLE cms_user ADD ROLE_ID INTEGER NOT NULL;
UPDATE cms_user SET ROLE_ID=(SELECT ID FROM cms_role WHERE VALUE="Admin");
ALTER TABLE cms_user ADD CONSTRAINT CMS_USER_ROLE_ID_FK FOREIGN KEY(ROLE_ID) REFERENCES cms_role(ID);