2022-05-27 20:53:12 +02:00
|
|
|
CREATE TABLE users (
|
|
|
|
id UUID NOT NULL PRIMARY KEY,
|
|
|
|
username VARCHAR UNIQUE NOT NULL,
|
|
|
|
email VARCHAR UNIQUE NOT NULL,
|
|
|
|
role VARCHAR NOT NULL
|
2022-03-29 19:32:21 +02:00
|
|
|
);
|
|
|
|
|
|
|
|
CREATE TABLE pwd (
|
2022-05-27 20:53:12 +02:00
|
|
|
user_id UUID NOT NULL PRIMARY KEY,
|
|
|
|
password VARCHAR NOT NULL,
|
|
|
|
CONSTRAINT FK_UserId FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE
|
2022-05-14 15:46:05 +02:00
|
|
|
);
|
|
|
|
|
|
|
|
--Initialize default admin user, with password "gamenight!"
|
2022-05-27 20:53:12 +02:00
|
|
|
CREATE EXTENSION IF NOT EXISTS "uuid-ossp";
|
|
|
|
DO $$
|
|
|
|
DECLARE
|
|
|
|
admin_uuid uuid = uuid_generate_v4();
|
|
|
|
BEGIN
|
|
|
|
INSERT INTO users (id, username, email, role)
|
|
|
|
values(admin_uuid, 'admin', '', 'admin');
|
|
|
|
|
|
|
|
insert INTO pwd (user_id, password)
|
|
|
|
values(admin_uuid, '$argon2id$v=19$m=4096,t=3,p=1$zEdUjCAnZqd8DziYWzlFHw$YBLQhKvYIZBY43B8zM6hyBvLKuqTeh0EM5pKOfbWQSI');
|
|
|
|
END $$;
|
2022-05-14 15:46:05 +02:00
|
|
|
|