cacert-boardvoting/boardvoting/migrations/2020041401_add_roles_table.up.sql
Jan Dittberner 70cc0942ca Upgrade to Go 1.16 and newer libraries
- use embed from the standard library instead of packr
- upgrade to sprig v3
- upgrade gomail version
- use golang-migrate instead of sql-migrate to get embed support
- use statigz to deliver compressed static assets
2021-03-07 19:42:11 +01:00

13 lines
421 B
SQL

-- SQL in section 'Up' is executed when this migration is applied
CREATE TABLE user_roles
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
voter_id VARCHAR(255) NOT NULL REFERENCES voters (id),
role VARCHAR(8) NOT NULL,
created TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
UNIQUE (voter_id, role)
);
INSERT INTO user_roles (voter_id, role)
SELECT id, 'VOTER'
FROM voters
WHERE enabled = true;