๐ฉโ๐ Firefighters API written in Gleam!
lustre
gleam
1-- types
2
3create type user_role_enum as enum (
4 'admin',
5 'analyst',
6 'captain',
7 'developer',
8 'firefighter',
9 'sargeant',
10 'none'
11);
12
13-- tables
14
15create table user_account (
16 id uuid default uuidv7(),
17 user_role user_role_enum not null,
18 full_name text not null,
19 password_hash text not null,
20 phone text unique not null,
21 email text unique not null,
22 is_active boolean not null default false,
23 created_at timestamp not null default current_timestamp,
24 updated_at timestamp not null default current_timestamp,
25
26 primary key (id)
27);
28
29create index idx_user_account_email
30on user_account (email);
31
32
33create table crew (
34 id uuid default uuidv7(),
35 crew_leader uuid not null references user_account (id)
36 on update cascade on delete cascade,
37 crew_name text unique not null,
38 is_active boolean not null default false,
39 created_at timestamp not null default current_timestamp,
40 updated_at timestamp not null default current_timestamp,
41
42 primary key (id)
43);
44
45create index idx_crew_leader
46on crew (crew_leader);
47
48
49create table crew_membership (
50 id uuid default uuidv7(),
51 crew_id uuid not null references crew (id)
52 on update cascade on delete cascade,
53 user_id uuid not null references user_account (id)
54 on update cascade on delete cascade,
55
56 primary key (id),
57 unique (crew_id, user_id)
58);
59
60create index idx_crew_membership_crew
61on crew_membership (crew_id);
62
63create index idx_crew_membership_user
64on crew_membership (user_id);