You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
cacert-boardvoting/internal/migrations/2020041401_add_roles_table....

14 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;