Previous: Creating Tables and Roles, Up: PostgreSQL Setup [Contents][Index]
An initial admin user needs to be created in the database. Thereafter,
that user maintains other users using the web application. Creating the
initial admin user fundamentally consists of making entries in the
usertable
, role
and user_role
tables.
Firstly, if the roles have not previously been created, create the
entries in the role
table by running the following script using
psql
:
SELECT * FROM role; INSERT INTO role (name) VALUES ('Admin'), ('User');
If the application has been built with the --enable-tui
configure
option, an admin user can be created by running the application with the
--interactive
option, which provides a Text-based User Interface
(TUI) suitable to run within a terminal session. E.g.
$ trip-server --interactive
Select the option to create a new user from the menu.
Alternatively, an initial admin user can be created similarly to the following, replacing each value appropriately:
INSERT INTO usertable (firstname, lastname, email, uuid, password, nickname) VALUES ('admin', '', 'admin@trip.test', gen_random_uuid(), crypt('SECRET', gen_salt('bf')), 'admin'); INSERT INTO user_role (user_id, role_id) VALUES ( (SELECT id FROM usertable u WHERE u.nickname='admin'), (SELECT id FROM role WHERE name='Admin') );