users: migrations, queries, users crate: create user, get first admin user

This commit is contained in:
Philippe Loctaux 2023-03-05 23:31:10 +01:00
parent 8af226cd05
commit 3e168c19bc
13 changed files with 283 additions and 1 deletions

View file

@ -0,0 +1 @@
drop table if exists users;

View file

@ -0,0 +1,25 @@
create table if not exists users
(
id TEXT not null primary key,
created_at TEXT not null default CURRENT_TIMESTAMP,
updated_at TEXT not null default CURRENT_TIMESTAMP,
is_admin INTEGER not null,
username TEXT not null unique,
name TEXT,
email TEXT unique,
password TEXT,
password_recover TEXT,
paper_key TEXT,
is_archived INTEGER not null default 0
);
-- update "updated_at"
create trigger if not exists users_updated_at
after update
on users
for each row
begin
update users
set updated_at = CURRENT_TIMESTAMP
where id is NEW.id;
end;