users: migrations, queries, users crate: create user, get first admin user
This commit is contained in:
parent
8af226cd05
commit
3e168c19bc
13 changed files with 283 additions and 1 deletions
1
crates/database/migrations/20230305135630_users.down.sql
Normal file
1
crates/database/migrations/20230305135630_users.down.sql
Normal file
|
|
@ -0,0 +1 @@
|
|||
drop table if exists users;
|
||||
25
crates/database/migrations/20230305135630_users.up.sql
Normal file
25
crates/database/migrations/20230305135630_users.up.sql
Normal 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;
|
||||
Loading…
Add table
Add a link
Reference in a new issue